I am migrating our mesh network stack to NRF 52840, which is based on 802.15.4.
I would like the code to be more efficient state machine so that I don't have to busy-wait for state transitions.
On the TX side, here is the code form Contiki:
/* Enable the SHORT between TXREADY and START before triggering TXRU */
nrf_radio_shorts_enable(NRF_RADIO_SHORT_TXREADY_START_MASK);
nrf_radio_task_trigger(NRF_RADIO_TASK_TXEN);
/*
* With fast rampup, the transition between TX and READY (TXRU duration)
* takes 40us. This means we will be in TX mode in less than 3 rtimer ticks
* (3x16=42 us). After this duration, we can busy wait for TX to finish.
*/
RTIMER_BUSYWAIT(TXRU_DURATION_TIMER);
/* Wait for TX to complete */
while(nrf_radio_state_get() == NRF_RADIO_STATE_TX);
If my understanding is correct, as soon as the TXEN is triggered, the RF state becomes TXRU, then after 40us, becomes TXREADY and start transmitting.
The code busy waited until state changed to TXIDLE.
My question, can I get the TXIDLE event from interrupt so that I don't have to busy wait? If so, what interrupt event shall I subscribe to?
Thanks