A received frame is stored as follows in the SRAM of the radio transceiver:
0 1 2 L-2 L-1 L +---+---+---+---+---+---+/.../+---+---+---+ | D | D | D | D | D | D | | F | F |LQI| +-o-+---+---+---+---+---+/.../+-o-+-o-+-o-+ +---+ | | | L | |<-- access via SRAM Access Mode" --->| +-o-+ | | | |<---- access via "Frame Receive Mode" ----->|
L = length byte, D = data byte, F = FCS byte, LQI = link quality indication value for the received frame
The length byte L of a received frame is stored in an internal register of the radio transceiver and has a range from L = [1...127]
. It can only be read from the MCU with a SPI "Frame Receive Mode" access (see trx_frame_read).
If needed, the RG_PHY_ED_LEVEL can be read out after reception of the frame, refer to PHY_ED_FRAME_END.
/* TRX_IRQ_RX_START occurs here */ /* TRX_IRQ_TRX_END occurs here */ frame = trx_frame_read();
Because the TRX_IRQ_RX_START interrupt is generated right after the reception of the SFD, a wait period of 32 us is necessary before the frame length byte can be read.
The duration twait
is computed with the function frame_rx_delay()
after the frame length is available. The value of twait
depends on the SPI transfer rate and the frame length itself. It denotes the point in time, when the frame upload can be started. When the TRX_IRQ_TRX_END interrupt occurs, the uploaded frame is available in a buffer and the acknowledge procedure can be started.
/* TRX_IRQ_RX_START occurs here */ delay_us(32); flen = trx_frame_length_read(); twait = frame_rx_delay(flen); frame = trx_frame_read(); /* TRX_IRQ_TRX_END occurs here */ generate_ack(frame);