Skip to content
Snippets Groups Projects
Commit 66db33b6 authored by Thomas Eichinger's avatar Thomas Eichinger
Browse files

drivers/at86rf2xx: prevent a possible race condition after state change

It was pointed out that after a state change to RX_AACK_ON reading back
the state to confirm the transition can fail due to an imidiate change
into BUSY_RX_AACK between the successful change on the transceiver and
querying the state.
For this we exclude the readback of the state for transitions to
RX_AACK_ON.
parent 4ebbda84
No related branches found
No related tags found
No related merge requests found
......@@ -421,7 +421,16 @@ void at86rf2xx_set_option(at86rf2xx_t *dev, uint16_t option, bool state)
static inline void _set_state(at86rf2xx_t *dev, uint8_t state)
{
at86rf2xx_reg_write(dev, AT86RF2XX_REG__TRX_STATE, state);
while (at86rf2xx_get_status(dev) != state);
/* To prevent a possible race condition when changing to
* RX_AACK_ON state the state doesn't get read back in that
* case. See discussion
* in https://github.com/RIOT-OS/RIOT/pull/5244
*/
if (state != AT86RF2XX_STATE_RX_AACK_ON) {
while (at86rf2xx_get_status(dev) != state);
}
dev->state = state;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment