Browse Source

drivers/at86rf2xx: improve precondition checks on state transition

The rational behind this change is the following:
If the transceiver is in any *_BUSY state when `at86rf2xx_set_state()`
gets called this would bypass the `(state == old_state)` check and
unneeded state transitions could be triggered.
pr/spi.typo
Thomas Eichinger 7 years ago
parent
commit
4ebbda844c
  1. 7
      drivers/at86rf2xx/at86rf2xx_getset.c

7
drivers/at86rf2xx/at86rf2xx_getset.c

@ -429,9 +429,6 @@ void at86rf2xx_set_state(at86rf2xx_t *dev, uint8_t state)
{
uint8_t old_state = at86rf2xx_get_status(dev);
if (state == old_state) {
return;
}
/* make sure there is no ongoing transmission, or state transition already
* in progress */
while (old_state == AT86RF2XX_STATE_BUSY_RX_AACK ||
@ -440,6 +437,10 @@ void at86rf2xx_set_state(at86rf2xx_t *dev, uint8_t state)
old_state = at86rf2xx_get_status(dev);
}
if (state == old_state) {
return;
}
/* we need to go via PLL_ON if we are moving between RX_AACK_ON <-> TX_ARET_ON */
if ((old_state == AT86RF2XX_STATE_RX_AACK_ON &&
state == AT86RF2XX_STATE_TX_ARET_ON) ||

Loading…
Cancel
Save