Skip to content

Commit

Permalink
at86rf2xx: unroll tx_prepare in netdev->driver->send
Browse files Browse the repository at this point in the history
Otherwise, there can happen a state transition between the busy check
and the setting do TX_ARET_ON.
  • Loading branch information
miri64 committed Nov 11, 2019
1 parent 2b5d9b4 commit b247a1c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/at86rf2xx/at86rf2xx_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b247a1c

Please sign in to comment.