mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
at86rf2xx: introduce pending TX counter
This counter is necessary for the current concept to tell the driver when to return to idle after sending.
This commit is contained in:
parent
5b386597c6
commit
252baecef7
@ -44,6 +44,7 @@ void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params)
|
||||
memcpy(&dev->params, params, sizeof(at86rf2xx_params_t));
|
||||
dev->idle_state = AT86RF2XX_STATE_TRX_OFF;
|
||||
dev->state = AT86RF2XX_STATE_SLEEP;
|
||||
dev->pending_tx = 0;
|
||||
/* initialise SPI */
|
||||
spi_init_master(dev->params.spi, SPI_CONF_FIRST_RISING, params->spi_speed);
|
||||
}
|
||||
@ -185,6 +186,7 @@ void at86rf2xx_tx_prepare(at86rf2xx_t *dev)
|
||||
{
|
||||
uint8_t state;
|
||||
|
||||
dev->pending_tx++;
|
||||
/* make sure ongoing transmissions are finished */
|
||||
do {
|
||||
state = at86rf2xx_get_status(dev);
|
||||
|
||||
@ -624,7 +624,15 @@ static void _isr(netdev2_t *netdev)
|
||||
}
|
||||
else if (state == AT86RF2XX_STATE_TX_ARET_ON ||
|
||||
state == AT86RF2XX_STATE_BUSY_TX_ARET) {
|
||||
at86rf2xx_set_state(dev, dev->idle_state);
|
||||
/* check for more pending TX calls and return to idle state if
|
||||
* there are none */
|
||||
if (dev->pending_tx == 0) {
|
||||
at86rf2xx_set_state(dev, dev->idle_state);
|
||||
}
|
||||
else {
|
||||
dev->pending_tx--;
|
||||
}
|
||||
|
||||
DEBUG("[at86rf2xx] EVT - TX_END\n");
|
||||
DEBUG("[at86rf2xx] return to state 0x%x\n", dev->idle_state);
|
||||
|
||||
|
||||
@ -163,6 +163,9 @@ typedef struct {
|
||||
uint8_t page; /**< currently used channel page */
|
||||
#endif
|
||||
uint8_t idle_state; /**< state to return to after sending */
|
||||
uint8_t pending_tx; /**< keep track of pending TX calls
|
||||
this is required to know when to
|
||||
return to @ref at86rf2xx_t::idle_state */
|
||||
/** @} */
|
||||
} at86rf2xx_t;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user