Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

at86rf2xx: do not try to send when device is busy #11264

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions drivers/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ endif

ifneq (,$(filter at86rf%, $(filter-out at86rf215%, $(USEMODULE))))
USEMODULE += at86rf2xx
ifneq (,$(filter gnrc_netif,$(USEMODULE)))
USEMODULE += gnrc_netif_pktq
endif
endif

ifneq (,$(filter bme680_%,$(USEMODULE)))
Expand Down
22 changes: 21 additions & 1 deletion drivers/at86rf2xx/at86rf2xx_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ static void _irq_handler(void *arg)
}
#endif

static inline bool _is_busy(at86rf2xx_t *dev)
{
uint8_t state = at86rf2xx_get_status(dev);

return (state == AT86RF2XX_STATE_BUSY_RX_AACK) ||
(state == AT86RF2XX_STATE_BUSY_TX_ARET) ||
(state == AT86RF2XX_STATE_IN_PROGRESS);
}

static int _init(netdev_t *netdev)
{
at86rf2xx_t *dev = (at86rf2xx_t *)netdev;
Expand Down Expand Up @@ -113,8 +122,19 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
{
at86rf2xx_t *dev = (at86rf2xx_t *)netdev;
size_t len = 0;
uint8_t state;

at86rf2xx_tx_prepare(dev);
if (_is_busy(dev)) {
return -EBUSY;
}
/* 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