Browse Source

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.
pr/spi.typo
Thomas Eichinger 6 years ago
parent
commit
66db33b662
  1. 11
      drivers/at86rf2xx/at86rf2xx_getset.c

11
drivers/at86rf2xx/at86rf2xx_getset.c

@ -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;
}

Loading…
Cancel
Save