1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 18:52:44 +01:00

cc2538_rf: fix race condition when changing state

This commit is contained in:
Jose Alamos 2021-08-16 14:31:34 +02:00
parent 3c1909b443
commit 0b5b896e70
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9

View File

@ -69,8 +69,7 @@ static int _confirm_transmit(ieee802154_dev_t *dev, ieee802154_tx_info_t *info)
{ {
(void) dev; (void) dev;
if (RFCORE->XREG_FSMSTAT1bits.TX_ACTIVE != 0 if (cc2538_tx_busy) {
|| !(RFCORE_XREG_CSPCTRL & CC2538_CSP_MCU_CTRL_MASK)) {
return -EAGAIN; return -EAGAIN;
} }
@ -296,7 +295,9 @@ static int _request_set_trx_state(ieee802154_dev_t *dev, ieee802154_trx_state_t
{ {
(void) dev; (void) dev;
int irq = irq_disable();
if (cc2538_tx_busy || cc2538_rx_busy) { if (cc2538_tx_busy || cc2538_rx_busy) {
irq_restore(irq);
return -EBUSY; return -EBUSY;
} }
@ -306,6 +307,7 @@ static int _request_set_trx_state(ieee802154_dev_t *dev, ieee802154_trx_state_t
if (RFCORE->XREG_FSMSTAT0bits.FSM_FFCTRL_STATE != FSM_STATE_IDLE) { if (RFCORE->XREG_FSMSTAT0bits.FSM_FFCTRL_STATE != FSM_STATE_IDLE) {
RFCORE_SFR_RFST = ISRFOFF; RFCORE_SFR_RFST = ISRFOFF;
} }
cc2538_rx_busy = false;
break; break;
case IEEE802154_TRX_STATE_RX_ON: case IEEE802154_TRX_STATE_RX_ON:
RFCORE_XREG_RFIRQM0 |= RXPKTDONE; RFCORE_XREG_RFIRQM0 |= RXPKTDONE;
@ -316,6 +318,10 @@ static int _request_set_trx_state(ieee802154_dev_t *dev, ieee802154_trx_state_t
break; break;
} }
RFCORE_SFR_RFIRQF0 = 0;
RFCORE_SFR_RFIRQF1 = 0;
irq_restore(irq);
return 0; return 0;
} }