kopia lustrzana https://github.com/DL7AD/pecanpico10
Multiple updates:
- Testing mutex for radio lock vs binary semaphore - Rename radio lock function - Minor tidy ups in codepull/4/head
rodzic
e8fc1f865e
commit
ed95350a29
|
@ -13,13 +13,13 @@ const conf_t conf_flash_default = {
|
|||
// Primary position app
|
||||
.pos_pri = {
|
||||
.beacon = {
|
||||
.active = false,
|
||||
.active = true,
|
||||
.cycle = TIME_S2I(60 * 5),
|
||||
.init_delay = TIME_S2I(60),
|
||||
.fixed = false // Add lat, lon alt fields if enabling fixed
|
||||
},
|
||||
.radio_conf = {
|
||||
.pwr = 0x7F,
|
||||
.pwr = 0x1F,
|
||||
.freq = FREQ_APRS_DYNAMIC,
|
||||
.mod = MOD_AFSK,
|
||||
.cca = 0x4F,
|
||||
|
@ -34,21 +34,21 @@ const conf_t conf_flash_default = {
|
|||
// Secondary position app
|
||||
.pos_sec = {
|
||||
.beacon = {
|
||||
.active = false,
|
||||
.cycle = TIME_S2I(180),
|
||||
.active = true,
|
||||
.cycle = TIME_S2I(60),
|
||||
.init_delay = TIME_S2I(60),
|
||||
.fixed = false // Add lat, lon alt fields if enabling fixed
|
||||
},
|
||||
.radio_conf = {
|
||||
.pwr = 0x7F,
|
||||
.freq = 145825000,
|
||||
.mod = MOD_AFSK,
|
||||
.cca = 0xFF
|
||||
.freq = 144800000,
|
||||
.mod = MOD_2FSK,
|
||||
.cca = 0x4F
|
||||
},
|
||||
// App identity
|
||||
.call = "VK2GJ-15",
|
||||
.path = "",
|
||||
.symbol = SYM_BALLOON,
|
||||
.symbol = SYM_CAR,
|
||||
.aprs_msg = true, // Enable APRS message reception on this call sign
|
||||
},
|
||||
|
||||
|
@ -57,7 +57,7 @@ const conf_t conf_flash_default = {
|
|||
.svc_conf = {
|
||||
.active = true,
|
||||
.cycle = TIME_S2I(60 * 5),
|
||||
.init_delay = TIME_S2I(90),
|
||||
.init_delay = TIME_S2I(60 * 1),
|
||||
.send_spacing = TIME_S2I(5)
|
||||
},
|
||||
.radio_conf = {
|
||||
|
@ -82,13 +82,13 @@ const conf_t conf_flash_default = {
|
|||
.img_sec = {
|
||||
.svc_conf = {
|
||||
.active = true,
|
||||
.cycle = TIME_S2I(60 * 15),
|
||||
.init_delay = TIME_S2I(60 * 1),
|
||||
.send_spacing = TIME_S2I(30)
|
||||
.cycle = TIME_S2I(60 * 0),
|
||||
.init_delay = TIME_S2I(30 * 1),
|
||||
.send_spacing = TIME_S2I(5)
|
||||
},
|
||||
.radio_conf = {
|
||||
.pwr = 0x7F,
|
||||
.freq = APRS_FREQ_AUSTRALIA,
|
||||
.pwr = 0x1F,
|
||||
.freq = FREQ_APRS_DYNAMIC,
|
||||
.mod = MOD_AFSK,
|
||||
.cca = 0x4F
|
||||
},
|
||||
|
|
|
@ -992,7 +992,7 @@ msg_t OV5640_LockResourcesForCapture(void) {
|
|||
/* TODO: have to make this a loop which would handle multiple receivers. */
|
||||
|
||||
/* Acquire radio after any active TX completes. */
|
||||
msg_t msg = pktAcquireRadio(PKT_RADIO_1, TIME_INFINITE);
|
||||
msg_t msg = pktLockRadioTransmit(PKT_RADIO_1, TIME_INFINITE);
|
||||
if(msg != MSG_OK) {
|
||||
return msg;
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ void OV5640_UnlockResourcesForCapture(void) {
|
|||
}
|
||||
//pktResumeDecoding(PKT_RADIO_1);
|
||||
/* Enable TX tasks to run. */
|
||||
pktReleaseRadio(PKT_RADIO_1);
|
||||
pktUnlockRadioTransmit(PKT_RADIO_1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1133,11 +1133,6 @@ uint32_t OV5640_Capture(uint8_t* buffer, uint32_t size) {
|
|||
rccEnableTIM8(FALSE);
|
||||
rccResetTIM8();
|
||||
|
||||
|
||||
/* TODO: deprecate ARR as not used for Input Capture mode. */
|
||||
//TIM8->ARR = 1;
|
||||
//dma_control.timer->CCR1 = 0;
|
||||
//dma_control.timer->CCER = 0;
|
||||
/*
|
||||
* Setup capture mode triggered from TI1.
|
||||
* What is captured isn't used just the DMA trigger.
|
||||
|
@ -1165,7 +1160,6 @@ uint32_t OV5640_Capture(uint8_t* buffer, uint32_t size) {
|
|||
} while(!dma_control.capture && !dma_control.dma_error && --timout);
|
||||
|
||||
palDisableLineEvent(LINE_CAM_VSYNC);
|
||||
OV5640_UnlockResourcesForCapture();
|
||||
|
||||
if(!timout) {
|
||||
TRACE_ERROR("CAM > Image sampling timeout");
|
||||
|
@ -1174,6 +1168,8 @@ uint32_t OV5640_Capture(uint8_t* buffer, uint32_t size) {
|
|||
dma_control.dma_error = true;
|
||||
}
|
||||
|
||||
OV5640_UnlockResourcesForCapture();
|
||||
|
||||
if(dma_control.dma_error) {
|
||||
if(dma_control.dma_flags & STM32_DMA_ISR_HTIF) {
|
||||
TRACE_ERROR("CAM > DMA abort - last buffer segment");
|
||||
|
|
|
@ -1015,8 +1015,10 @@ bool Si446x_receiveNoLock(const radio_unit_t radio,
|
|||
radio_ch_t channel,
|
||||
radio_squelch_t rssi,
|
||||
mod_t mod) {
|
||||
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(radio, freq,
|
||||
step, channel, RADIO_RX);
|
||||
step, channel,
|
||||
RADIO_RX);
|
||||
if(op_freq == FREQ_RADIO_INVALID) {
|
||||
TRACE_ERROR("SI > Frequency out of range");
|
||||
TRACE_ERROR("SI > abort transmission");
|
||||
|
@ -1029,16 +1031,15 @@ bool Si446x_receiveNoLock(const radio_unit_t radio,
|
|||
chThdSleep(TIME_MS2I(10));
|
||||
if(tot++ < 500)
|
||||
continue;
|
||||
|
||||
/* Remove TX state. */
|
||||
Si446x_setReadyState(radio);
|
||||
|
||||
TRACE_ERROR("SI > Timeout waiting for TX state end");
|
||||
TRACE_ERROR("SI > Attempt start of receive");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Initialize radio
|
||||
/* Configure radio for modulation type. */
|
||||
if(mod == MOD_AFSK) {
|
||||
Si446x_setModemAFSK_RX(radio);
|
||||
} else {
|
||||
|
@ -1049,8 +1050,11 @@ bool Si446x_receiveNoLock(const radio_unit_t radio,
|
|||
|
||||
TRACE_INFO("SI > Tune Si446x to %d.%03d MHz (RX)",
|
||||
op_freq/1000000, (op_freq%1000000)/1000);
|
||||
|
||||
/* Set squelch level. */
|
||||
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_THRESH, rssi);
|
||||
|
||||
/* Start the receiver. */
|
||||
Si446x_setRXState(radio, channel);
|
||||
|
||||
/* Wait for the receiver to start. */
|
||||
|
@ -1071,7 +1075,6 @@ bool Si4464_enableReceive(const radio_unit_t radio,
|
|||
const radio_ch_t rx_chan,
|
||||
const radio_squelch_t rx_rssi,
|
||||
const mod_t rx_mod) {
|
||||
//bool ret = true;
|
||||
|
||||
/* Get an absolute operating frequency in Hz. */
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(radio,
|
||||
|
@ -1099,7 +1102,7 @@ bool Si4464_enableReceive(const radio_unit_t radio,
|
|||
* If the receiver is active put it into standby.
|
||||
*/
|
||||
void Si446x_disableReceive(const radio_unit_t radio) {
|
||||
/* FIXME: */
|
||||
/* FIXME: Should have timeout. */
|
||||
if(Si446x_getState(radio) == Si446x_STATE_RX) {
|
||||
Si446x_radioStandby(radio);
|
||||
}
|
||||
|
@ -1119,12 +1122,13 @@ void Si446x_terminateReceive(const radio_unit_t radio) {
|
|||
/*
|
||||
*
|
||||
*/
|
||||
void Si446x_terminateTransmit(const radio_unit_t radio) {
|
||||
/* FIXME: Should provide have timeout. */
|
||||
void Si446x_waitTransmitEnd(const radio_unit_t radio) {
|
||||
/* FIXME: Should have timeout. */
|
||||
while(Si446x_getState(radio) == Si446x_STATE_TX);
|
||||
}
|
||||
|
||||
/*
|
||||
* AFSK Transmitter
|
||||
* AFSK Transmitter functions
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1181,7 +1185,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
|
||||
chDbgAssert(pp != NULL, "no packet in radio task");
|
||||
|
||||
if(pktAcquireRadio(radio, TIME_INFINITE) == MSG_RESET) {
|
||||
if(pktLockRadioTransmit(radio, TIME_INFINITE) == MSG_RESET) {
|
||||
TRACE_ERROR("SI > AFSK TX reset from radio acquisition");
|
||||
/* Free packet object memory. */
|
||||
pktReleaseBufferChain(pp);
|
||||
|
@ -1192,10 +1196,12 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
/* Exit thread. */
|
||||
chThdExit(MSG_RESET);
|
||||
/* We never arrive here. */
|
||||
chSysHalt("TX AFSK exit");
|
||||
}
|
||||
|
||||
/* Initialize radio. */
|
||||
Si446x_conditional_init(radio);
|
||||
/* TODO: This is redundant as the radio is initialized by the manager. */
|
||||
//Si446x_conditional_init(radio);
|
||||
|
||||
/* Base frequency is an absolute frequency in Hz. */
|
||||
Si446x_setBandParameters(radio, rto->base_frequency,
|
||||
|
@ -1203,6 +1209,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
|
||||
/* Set 446x back to READY. */
|
||||
Si446x_terminateReceive(radio);
|
||||
|
||||
/* Set the radio for AFSK upsampled mode. */
|
||||
Si446x_setModemAFSK_TX(radio);
|
||||
|
||||
|
@ -1246,7 +1253,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
pktLLDradioSendComplete(rto, chThdGetSelfX());
|
||||
|
||||
/* Unlock radio. */
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
|
||||
/* Exit thread. */
|
||||
chThdExit(MSG_ERROR);
|
||||
|
@ -1380,7 +1387,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
pktLLDradioSendComplete(rto, chThdGetSelfX());
|
||||
|
||||
/* Unlock radio. */
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
|
||||
/* Exit thread. */
|
||||
chThdExit(exit_msg);
|
||||
|
@ -1437,7 +1444,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
chDbgAssert(pp != NULL, "no packet in radio task");
|
||||
|
||||
/* Check for MSG_RESET which means system has forced radio release. */
|
||||
if(pktAcquireRadio(radio, TIME_INFINITE) == MSG_RESET) {
|
||||
if(pktLockRadioTransmit(radio, TIME_INFINITE) == MSG_RESET) {
|
||||
TRACE_ERROR("SI > 2FSK TX reset from radio acquisition");
|
||||
/* Free packet object memory. */
|
||||
pktReleaseBufferChain(pp);
|
||||
|
@ -1452,7 +1459,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
|
||||
/* Initialize radio.
|
||||
* TODO: This is redundant as the radio is initialized by the manager. */
|
||||
Si446x_conditional_init(radio);
|
||||
//Si446x_conditional_init(radio);
|
||||
|
||||
/* Set 446x back to READY from RX (if active). */
|
||||
Si446x_terminateReceive(radio);
|
||||
|
@ -1508,7 +1515,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
pktLLDradioSendComplete(rto, chThdGetSelfX());
|
||||
|
||||
/* Unlock radio. */
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
|
||||
/* Exit thread. */
|
||||
chThdExit(MSG_ERROR);
|
||||
|
@ -1632,7 +1639,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
pktLLDradioSendComplete(rto, chThdGetSelfX());
|
||||
|
||||
/* Unlock radio. */
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
|
||||
/* Exit thread. */
|
||||
chThdExit(exit_msg);
|
||||
|
@ -1712,7 +1719,7 @@ bool Si446x_detachPWM(const radio_unit_t radio) {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const ICUConfig *Si446x_startPWM(const radio_unit_t radio,
|
||||
const ICUConfig *Si446x_enablePWMevents(const radio_unit_t radio,
|
||||
palcallback_t cb) {
|
||||
/* Set callback for squelch events. */
|
||||
palSetLineCallback(Si446x_getConfig(radio)->nirq, cb,
|
||||
|
@ -1722,15 +1729,13 @@ const ICUConfig *Si446x_startPWM(const radio_unit_t radio,
|
|||
palEnableLineEvent(Si446x_getConfig(radio)->nirq,
|
||||
PAL_EVENT_MODE_BOTH_EDGES);
|
||||
|
||||
//extern const ICUConfig pwm_icucfg;
|
||||
//return &pwm_icucfg;
|
||||
return &Si446x_getConfig(radio)->cfg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void Si446x_stopPWM(radio_unit_t radio) {
|
||||
void Si446x_disablePWMevents(radio_unit_t radio) {
|
||||
palDisableLineEvent(Si446x_getConfig(radio)->nirq);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -331,8 +331,8 @@ extern "C" {
|
|||
radio_signal_t Si446x_getCurrentRSSI(const radio_unit_t radio);
|
||||
ICUDriver *Si446x_attachPWM(const radio_unit_t radio);
|
||||
bool Si446x_detachPWM(const radio_unit_t radio);
|
||||
const ICUConfig *Si446x_startPWM(const radio_unit_t radio, palcallback_t cb);
|
||||
void Si446x_stopPWM(const radio_unit_t radio);
|
||||
const ICUConfig *Si446x_enablePWMevents(const radio_unit_t radio, palcallback_t cb);
|
||||
void Si446x_disablePWMevents(const radio_unit_t radio);
|
||||
uint8_t Si446x_readCCA(const radio_unit_t radio);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -658,7 +658,6 @@ uint32_t getAPRSRegionFrequency() {
|
|||
|
||||
// Position unknown
|
||||
if(point == NULL || (point->gps_lat == 0 && point->gps_lon == 0))
|
||||
//return conf_sram.freq;
|
||||
// Return code and let pktradio figure out what to do.
|
||||
return FREQ_APRS_DEFAULT;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ void pktEnableRadioPWM(const radio_unit_t radio) {
|
|||
|
||||
chDbgAssert(myDemod->icudriver != NULL, "no ICU driver");
|
||||
|
||||
/* Enable IO can callbacks. */
|
||||
/* Enable CCA callback. */
|
||||
const ICUConfig *icucfg = pktLLDradioStartPWM(radio,
|
||||
(palcallback_t)pktRadioCCAInput);
|
||||
|
||||
|
@ -188,13 +188,14 @@ void pktDisableRadioPWM(const radio_unit_t radio) {
|
|||
|
||||
chDbgAssert(myDemod->icudriver != NULL, "no ICU driver");
|
||||
|
||||
/* Disable CCA line event. */
|
||||
//palDisableLineEvent(LINE_CCA);
|
||||
pktLLDradioStopPWM(radio);
|
||||
myDemod->icustate = PKT_PWM_STOP;
|
||||
|
||||
/* Stop ICU capture. */
|
||||
icuStopCapture(myDemod->icudriver);
|
||||
|
||||
/* Disable CCA line event. */
|
||||
pktLLDradioStopPWM(radio);
|
||||
|
||||
chSysLock();
|
||||
|
||||
/* Stop any timeouts in ICU PWM handling. */
|
||||
|
@ -203,8 +204,6 @@ void pktDisableRadioPWM(const radio_unit_t radio) {
|
|||
/* Close the PWM stream. */
|
||||
pktClosePWMchannelI(myDemod->icudriver, EVT_NONE, PWM_TERM_DECODE_STOP);
|
||||
|
||||
myDemod->icustate = PKT_PWM_STOP;
|
||||
|
||||
/*
|
||||
* Reschedule is required to avoid a "priority order violation".
|
||||
* TODO: Investigate the iclass time used. Might be systick related? */
|
||||
|
|
|
@ -164,16 +164,16 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
/* The function switches on mod type so no need for switch here. */
|
||||
switch(task_object->type) {
|
||||
case MOD_AFSK: {
|
||||
pktAcquireRadio(radio, TIME_INFINITE);
|
||||
pktLockRadioTransmit(radio, TIME_INFINITE);
|
||||
/* Enable receive. */
|
||||
if(!pktLLDradioEnableReceive(radio, task_object)) {
|
||||
TRACE_ERROR("RAD > Receive on radio %d failed to start", radio);
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
break;
|
||||
}
|
||||
pktLLDradioStartDecoder(radio);
|
||||
/* Unlock radio and allow transmit requests. */
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
break;
|
||||
} /* End case MOD_AFSK. */
|
||||
|
||||
|
@ -189,9 +189,9 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
switch(task_object->type) {
|
||||
case MOD_AFSK: {
|
||||
/* TODO: Abstract acquire and release in LLD. */
|
||||
pktAcquireRadio(radio, TIME_INFINITE);
|
||||
pktLockRadioTransmit(radio, TIME_INFINITE);
|
||||
pktLLDradioStopDecoder(radio);
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
break;
|
||||
} /* End case. */
|
||||
|
||||
|
@ -208,9 +208,9 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
++handler->radio_tx_config.tx_seq_num;
|
||||
if(pktIsReceiveActive(radio)) {
|
||||
/* Pause the decoder. */
|
||||
pktAcquireRadio(radio, TIME_INFINITE);
|
||||
pktLockRadioTransmit(radio, TIME_INFINITE);
|
||||
pktLLDradioPauseDecoding(radio);
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
}
|
||||
if(pktLLDradioSendPacket(task_object)) {
|
||||
/*
|
||||
|
@ -230,15 +230,15 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
packet_t pp = task_object->packet_out;
|
||||
pktReleaseBufferChain(pp);
|
||||
if(pktIsReceivePaused(radio)) {
|
||||
pktAcquireRadio(radio, TIME_INFINITE);
|
||||
pktLockRadioTransmit(radio, TIME_INFINITE);
|
||||
if(!pktLLDradioResumeReceive(radio)) {
|
||||
TRACE_ERROR("RAD > Receive on radio %d failed to "
|
||||
"resume after transmit", radio);
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
break;
|
||||
}
|
||||
pktLLDradioResumeDecoding(radio);
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
}
|
||||
break;
|
||||
} /* End case PKT_RADIO_TX. */
|
||||
|
@ -250,9 +250,9 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
switch(task_object->type) {
|
||||
case MOD_AFSK: {
|
||||
/* Stop receive. */
|
||||
pktAcquireRadio(radio, TIME_INFINITE);
|
||||
pktLockRadioTransmit(radio, TIME_INFINITE);
|
||||
pktLLDradioDisableReceive(radio);
|
||||
pktReleaseRadio(radio);
|
||||
pktUnlockRadioTransmit(radio);
|
||||
/* TODO: This should be a function back in pktservice or rxafsk. */
|
||||
esp = pktGetEventSource((AFSKDemodDriver *)handler->link_controller);
|
||||
pktRegisterEventListener(esp, &el, USR_COMMAND_ACK, DEC_CLOSE_EXEC);
|
||||
|
@ -589,7 +589,11 @@ void pktSubmitRadioTask(const radio_unit_t radio,
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Acquire exclusive access to radio.
|
||||
* @brief Lock radio.
|
||||
* @notes Used to lock radio when...
|
||||
* @notes a) transmitting or
|
||||
* @notes b) making changes where transmit should be blocked.
|
||||
* @pre Receive should be paused by calling routine if it is active.
|
||||
*
|
||||
* @param[in] radio radio unit ID.
|
||||
* @param[in] timeout time to wait for acquisition.
|
||||
|
@ -601,23 +605,34 @@ void pktSubmitRadioTask(const radio_unit_t radio,
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
msg_t pktAcquireRadio(const radio_unit_t radio,
|
||||
msg_t pktLockRadioTransmit(const radio_unit_t radio,
|
||||
const sysinterval_t timeout) {
|
||||
packet_svc_t *handler = pktGetServiceObject(radio);
|
||||
#if PKT_USE_RADIO_MUTEX == TRUE
|
||||
(void)timeout;
|
||||
chMtxLock(&handler->radio_mtx);
|
||||
return MSG_OK;
|
||||
#else
|
||||
return chBSemWaitTimeout(&handler->radio_sem, timeout);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release exclusive access to radio.
|
||||
* @notes returns when radio unit is released.
|
||||
* @brief Unlock radio.
|
||||
* @notes Returns when radio unit is unlocked.
|
||||
* @pre Receive should be resumed by calling routine if it was active.
|
||||
*
|
||||
* @param[in] radio radio unit ID.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void pktReleaseRadio(const radio_unit_t radio) {
|
||||
void pktUnlockRadioTransmit(const radio_unit_t radio) {
|
||||
packet_svc_t *handler = pktGetServiceObject(radio);
|
||||
#if PKT_USE_RADIO_MUTEX == TRUE
|
||||
chMtxUnlock(&handler->radio_mtx);
|
||||
#else
|
||||
chBSemSignal(&handler->radio_sem);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1058,7 +1073,7 @@ bool pktLLDradioResumeReceive(const radio_unit_t radio) {
|
|||
*/
|
||||
void pktLLDradioCaptureRSSI(const radio_unit_t radio) {
|
||||
packet_svc_t *handler = pktGetServiceObject(radio);
|
||||
handler->rx_stength = Si446x_getCurrentRSSI(radio);
|
||||
handler->rx_strength = Si446x_getCurrentRSSI(radio);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1144,7 +1159,7 @@ const ICUConfig *pktLLDradioStartPWM(const radio_unit_t radio,
|
|||
* - Then call VMT dispatcher inside radio driver.
|
||||
*/
|
||||
|
||||
return Si446x_startPWM(radio, cb);
|
||||
return Si446x_enablePWMevents(radio, cb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1156,7 +1171,7 @@ void pktLLDradioStopPWM(const radio_unit_t radio) {
|
|||
* - Lookup radio type from radio ID.
|
||||
* - Then call VMT dispatcher inside radio driver.
|
||||
*/
|
||||
Si446x_stopPWM(radio);
|
||||
Si446x_disablePWMevents(radio);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,10 +29,11 @@
|
|||
/* The number of radio task object the FIFO has. */
|
||||
#define RADIO_TASK_QUEUE_MAX 10
|
||||
|
||||
//#define NUM_BANDS_PER_RADIO 2
|
||||
|
||||
#define PKT_RADIO_MANAGER_TASK_KILL TRUE
|
||||
|
||||
/* Set TRUE to use mutex instead of bsem. */
|
||||
#define PKT_USE_RADIO_MUTEX TRUE
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
@ -138,9 +139,9 @@ extern "C" {
|
|||
radio_task_cb_t cb);
|
||||
void pktScheduleThreadRelease(const radio_unit_t radio,
|
||||
thread_t *thread);
|
||||
msg_t pktAcquireRadio(const radio_unit_t radio,
|
||||
msg_t pktLockRadioTransmit(const radio_unit_t radio,
|
||||
const sysinterval_t timeout);
|
||||
void pktReleaseRadio(const radio_unit_t radio);
|
||||
void pktUnlockRadioTransmit(const radio_unit_t radio);
|
||||
const radio_config_t *pktGetRadioList(void);
|
||||
uint8_t pktGetNumRadios(void);
|
||||
radio_band_t *pktCheckAllowedFrequency(const radio_unit_t radio,
|
||||
|
|
|
@ -133,6 +133,7 @@ bool pktServiceCreate(const radio_unit_t radio) {
|
|||
|
||||
if(handler->state != PACKET_IDLE)
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Initialize the packet common event object.
|
||||
*/
|
||||
|
@ -142,16 +143,18 @@ bool pktServiceCreate(const radio_unit_t radio) {
|
|||
memset(&handler->radio_tx_config, 0, sizeof(radio_task_object_t));
|
||||
|
||||
/* Set flags and radio ID. */
|
||||
//handler->rx_active = false;
|
||||
handler->radio_init = false;
|
||||
handler->radio = radio;
|
||||
|
||||
/* Set service semaphore to idle state. */
|
||||
chBSemObjectInit(&handler->close_sem, false);
|
||||
|
||||
#if PKT_USE_RADIO_MUTEX == TRUE
|
||||
chMtxObjectInit(&handler->radio_mtx);
|
||||
#else
|
||||
/* Set radio semaphore to free state. */
|
||||
chBSemObjectInit(&handler->radio_sem, false);
|
||||
|
||||
#endif
|
||||
/* Send request to create radio manager. */
|
||||
if (pktRadioManagerCreate(radio) == NULL)
|
||||
return false;
|
||||
|
|
|
@ -112,11 +112,18 @@ typedef struct packetHandlerData {
|
|||
*/
|
||||
bool radio_init;
|
||||
|
||||
#if PKT_USE_RADIO_MUTEX != TRUE
|
||||
/**
|
||||
* @brief Radio locked access semaphore.
|
||||
*/
|
||||
binary_semaphore_t radio_sem;
|
||||
#else
|
||||
|
||||
/**
|
||||
* @brief Radio locked access semaphore.
|
||||
*/
|
||||
mutex_t radio_mtx;
|
||||
#endif
|
||||
/**
|
||||
* @brief Radio receiver operating parameters.
|
||||
*/
|
||||
|
@ -125,7 +132,7 @@ typedef struct packetHandlerData {
|
|||
/**
|
||||
* @brief Radio signal strength captured on CCA.
|
||||
*/
|
||||
radio_signal_t rx_stength;
|
||||
radio_signal_t rx_strength;
|
||||
|
||||
/**
|
||||
* @brief Radio transmitter operating parameters.
|
||||
|
@ -169,7 +176,7 @@ typedef struct packetHandlerData {
|
|||
/**
|
||||
* @brief AX25 send buffer throttling semaphore.
|
||||
*/
|
||||
dyn_semaphore_t *tx_packet_sem;
|
||||
//dyn_semaphore_t *tx_packet_sem;
|
||||
|
||||
/**
|
||||
* @brief Packet buffer cb_func.
|
||||
|
|
|
@ -281,6 +281,8 @@ uint32_t gimage_id; // Global image ID (for all image threads)
|
|||
mutex_t camera_mtx;
|
||||
bool camera_mtx_init = false;
|
||||
|
||||
static bool camInitialized = false;
|
||||
|
||||
ssdv_packet_t packetRepeats[16];
|
||||
bool reject_pri;
|
||||
bool reject_sec;
|
||||
|
@ -341,7 +343,7 @@ static bool transmit_image_packet(const uint8_t *image,
|
|||
conf->radio_conf.mod,
|
||||
conf->radio_conf.cca)) {
|
||||
|
||||
TRACE_ERROR("IMG > Unable to send image packet TX on radio");
|
||||
TRACE_ERROR("IMG > Unable to send image packet on radio");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +520,7 @@ static bool analyze_image(uint8_t *image, uint32_t image_len) {
|
|||
#if !OV5640_USE_DMA_DBM
|
||||
if(image_len >= 65535) {
|
||||
TRACE_ERROR("CAM > Camera has %d bytes allocated but DMA DBM not activated", image_len);
|
||||
TRACE_ERROR("CAM > DMA can only use 65535 bytes only");
|
||||
TRACE_ERROR("CAM > DMA can only use 65535 bytes");
|
||||
image_len = 65535;
|
||||
}
|
||||
#endif
|
||||
|
@ -555,8 +557,9 @@ static bool analyze_image(uint8_t *image, uint32_t image_len) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool camInitialized = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
uint32_t takePicture(uint8_t* buffer, uint32_t size,
|
||||
resolution_t res, bool enableJpegValidation) {
|
||||
uint32_t size_sampled = 0;
|
||||
|
@ -571,7 +574,6 @@ uint32_t takePicture(uint8_t* buffer, uint32_t size,
|
|||
chMtxLock(&camera_mtx);
|
||||
|
||||
// Detect camera
|
||||
/* TODO: Detecting camera powers it up so refactor the below init code? */
|
||||
if(camInitialized || OV5640_isAvailable()) { // OV5640 available
|
||||
|
||||
TRACE_INFO("IMG > OV5640 found");
|
||||
|
@ -626,7 +628,8 @@ uint32_t takePicture(uint8_t* buffer, uint32_t size,
|
|||
|
||||
return size_sampled;
|
||||
}
|
||||
/*
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
THD_FUNCTION(imgThread, arg) {
|
||||
|
@ -668,7 +671,7 @@ THD_FUNCTION(imgThread, arg) {
|
|||
* History... compiler bug
|
||||
* If size is > 65535 the compiled code wraps address around and kills CMM heap.
|
||||
* Anyway clearing of the capture buffer is no longer needed.
|
||||
* SOI is now aligned at index 0 and length > EOI is returned by DMA.
|
||||
* SOI is now aligned at index 0 and length >= EOI is returned by DMA.
|
||||
*/
|
||||
/* uint32_t size = conf->buf_size;
|
||||
for(uint32_t i = 0; i < size ; i++)
|
||||
|
@ -695,7 +698,7 @@ THD_FUNCTION(imgThread, arg) {
|
|||
}
|
||||
|
||||
/* Find SOI in image buffer. */
|
||||
uint32_t soi;
|
||||
uint32_t soi = 0;
|
||||
bool soi_found = false;
|
||||
while(soi < (size_sampled - 1)) {
|
||||
if(buffer[soi] == 0xFF && buffer[soi + 1] == 0xD8) {
|
||||
|
@ -729,6 +732,7 @@ THD_FUNCTION(imgThread, arg) {
|
|||
}
|
||||
break;
|
||||
} /* End if SOI in buffer. */
|
||||
soi++;
|
||||
} /* End while soi < size_sampled - 1. */
|
||||
if(!soi_found) { /* No SOI found. */
|
||||
TRACE_INFO("IMG > No SOI found in image");
|
||||
|
|
Ładowanie…
Reference in New Issue