From b247a1c9da0dd8ecd58a440ab59673ae8abf3336 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 25 Apr 2019 09:52:59 +0200 Subject: [PATCH] at86rf2xx: unroll tx_prepare in netdev->driver->send Otherwise, there can happen a state transition between the busy check and the setting do TX_ARET_ON. --- drivers/at86rf2xx/at86rf2xx_netdev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/at86rf2xx/at86rf2xx_netdev.c b/drivers/at86rf2xx/at86rf2xx_netdev.c index 693eddc8f071..6edb6a3fc759 100644 --- a/drivers/at86rf2xx/at86rf2xx_netdev.c +++ b/drivers/at86rf2xx/at86rf2xx_netdev.c @@ -123,11 +123,19 @@ static int _send(netdev_t *netdev, const iolist_t *iolist) { at86rf2xx_t *dev = (at86rf2xx_t *)netdev; size_t len = 0; + uint8_t state; if (_is_busy(dev)) { return -EBUSY; } - at86rf2xx_tx_prepare(dev); + /* at86rf2xx_tx_prepare unrolled and re-ordered for quick state + * transition */ + state = at86rf2xx_set_state(dev, AT86RF2XX_STATE_TX_ARET_ON); + if (state != AT86RF2XX_STATE_TX_ARET_ON) { + dev->idle_state = state; + } + dev->pending_tx++; + dev->tx_frame_len = IEEE802154_FCS_LEN; /* load packet data into FIFO */ for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {