static uint8_t ao_radio_abort; /* radio operation should abort */
static uint8_t ao_radio_mcu_wake; /* MARC status change */
static uint8_t ao_radio_marc_status; /* Last read MARC status value */
+static uint8_t ao_radio_tx_finished; /* MARC status indicates TX finished */
#define CC1120_DEBUG AO_FEC_DEBUG
#define CC1120_TRACE 0
/* Anyt other than 'tx/rx finished' means an error occurred */
if (ao_radio_marc_status & ~(CC1120_MARC_STATUS1_TX_FINISHED|CC1120_MARC_STATUS1_RX_FINISHED))
ao_radio_abort = 1;
+ if (ao_radio_marc_status & (CC1120_MARC_STATUS1_TX_FINISHED))
+ ao_radio_tx_finished = 1;
}
static void
ao_exti_set_callback(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, ao_radio_isr);
ao_exti_enable(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);
ao_exti_enable(AO_CC1120_MCU_WAKEUP_PORT, AO_CC1120_MCU_WAKEUP_PIN);
+ ao_radio_tx_finished = 0;
ao_radio_strobe(CC1120_STX);
}
uint8_t state = ao_radio_strobe(CC1120_SIDLE);
if ((state >> CC1120_STATUS_STATE) == CC1120_STATUS_STATE_IDLE)
break;
+ if ((state >> CC1120_STATUS_STATE) == CC1120_STATUS_STATE_TX_FIFO_ERROR)
+ ao_radio_strobe(CC1120_SFTX);
}
/* Flush any pending TX bytes */
ao_radio_strobe(CC1120_SFTX);
uint8_t this_len;
uint8_t started = 0;
uint8_t fifo_space;
+ uint8_t q;
encode_len = ao_fec_encode(d, size, tx_data);
ao_radio_get(encode_len);
+ ao_radio_abort = 0;
+
+ /* Flush any pending TX bytes */
+ ao_radio_strobe(CC1120_SFTX);
+
started = 0;
fifo_space = CC1120_FIFO_SIZE;
while (encode_len) {
break;
}
}
+ while (started && !ao_radio_abort && !ao_radio_tx_finished)
+ ao_radio_wait_isr(0);
ao_radio_put();
}