mirror of
https://github.com/gosticks/RIOT.git
synced 2025-10-16 12:05:37 +00:00
Merge pull request #13788 from benpicco/drivers/at86rf215_shutdown_fix
drivers/at86rf215: return error when switching state while busy
This commit is contained in:
commit
750db2a910
@ -206,6 +206,8 @@ static bool _tx_ongoing(at86rf215_t *dev)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* we can still fill the TX buffer and queue TX
|
||||
when in AT86RF215_STATE_RX_SEND_ACK */
|
||||
if (dev->state == AT86RF215_STATE_TX ||
|
||||
dev->state == AT86RF215_STATE_TX_WAIT_ACK) {
|
||||
return true;
|
||||
@ -237,7 +239,7 @@ static void _block_while_busy(at86rf215_t *dev)
|
||||
gpio_irq_enable(dev->params.int_pin);
|
||||
}
|
||||
|
||||
void at86rf215_block_while_busy(at86rf215_t *dev)
|
||||
static void at86rf215_block_while_busy(at86rf215_t *dev)
|
||||
{
|
||||
if (_tx_ongoing(dev)) {
|
||||
DEBUG("[at86rf215] Block while TXing\n");
|
||||
|
||||
@ -52,6 +52,21 @@ const netdev_driver_t at86rf215_driver = {
|
||||
.set = _set,
|
||||
};
|
||||
|
||||
static bool _is_busy(at86rf215_t *dev)
|
||||
{
|
||||
if (dev->flags & AT86RF215_OPT_TX_PENDING) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dev->state == AT86RF215_STATE_TX ||
|
||||
dev->state == AT86RF215_STATE_TX_WAIT_ACK ||
|
||||
dev->state == AT86RF215_STATE_RX_SEND_ACK) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* executed in the GPIO ISR context */
|
||||
static void _irq_handler(void *arg)
|
||||
{
|
||||
@ -175,7 +190,9 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
|
||||
static int _set_state(at86rf215_t *dev, netopt_state_t state)
|
||||
{
|
||||
at86rf215_block_while_busy(dev);
|
||||
if (_is_busy(dev)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case NETOPT_STATE_STANDBY:
|
||||
|
||||
@ -373,13 +373,6 @@ void at86rf215_enable_rpc(at86rf215_t *dev);
|
||||
*/
|
||||
bool at86rf215_switch_mode(at86rf215_t *dev, uint8_t new_mode);
|
||||
|
||||
/**
|
||||
* @brief Block while the device is busy sending
|
||||
*
|
||||
* @param[in] dev device that might be TXing
|
||||
*/
|
||||
void at86rf215_block_while_busy(at86rf215_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Checks whether the device operates in the sub-GHz band.
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user