From 082481864686abebab7b0f04790200f872b92bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Duda?= Date: Tue, 15 May 2018 17:42:42 +0200 Subject: [PATCH] [nrf52840] fix race condition when reporting channel busy event (#2700) Signed-off-by: Duda, Lukasz --- examples/platforms/nrf52840/radio.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c index 515fb88c6..50bcb2204 100644 --- a/examples/platforms/nrf52840/radio.c +++ b/examples/platforms/nrf52840/radio.c @@ -157,10 +157,6 @@ static inline void clearPendingEvents(void) volatile uint32_t pendingEvents; uint32_t bitsToRemain = ~(0UL); - bitsToRemain &= ~(1UL << kPendingEventFrameTransmitted); - bitsToRemain &= ~(1UL << kPendingEventChannelAccessFailure); - bitsToRemain &= ~(1UL << kPendingEventInvalidOrNoAck); - bitsToRemain &= ~(1UL << kPendingEventSleep); do @@ -548,6 +544,8 @@ void nrf5RadioProcess(otInstance *aInstance) if (isPendingEventSet(kPendingEventFrameTransmitted)) { + resetPendingEvent(kPendingEventFrameTransmitted); + #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) @@ -566,12 +564,12 @@ void nrf5RadioProcess(otInstance *aInstance) nrf_802154_buffer_free_raw(sAckFrame.mPsdu - 1); sAckFrame.mPsdu = NULL; } - - resetPendingEvent(kPendingEventFrameTransmitted); } if (isPendingEventSet(kPendingEventChannelAccessFailure)) { + resetPendingEvent(kPendingEventChannelAccessFailure); + #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) @@ -583,12 +581,12 @@ void nrf5RadioProcess(otInstance *aInstance) { otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_CHANNEL_ACCESS_FAILURE); } - - resetPendingEvent(kPendingEventChannelAccessFailure); } if (isPendingEventSet(kPendingEventInvalidOrNoAck)) { + resetPendingEvent(kPendingEventInvalidOrNoAck); + #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) @@ -600,12 +598,12 @@ void nrf5RadioProcess(otInstance *aInstance) { otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NO_ACK); } - - resetPendingEvent(kPendingEventInvalidOrNoAck); } if (isPendingEventSet(kPendingEventReceiveFailed)) { + resetPendingEvent(kPendingEventReceiveFailed); + #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) @@ -617,15 +615,13 @@ void nrf5RadioProcess(otInstance *aInstance) { otPlatRadioReceiveDone(aInstance, NULL, sReceiveError); } - - resetPendingEvent(kPendingEventReceiveFailed); } if (isPendingEventSet(kPendingEventEnergyDetected)) { - otPlatRadioEnergyScanDone(aInstance, sEnergyDetected); - resetPendingEvent(kPendingEventEnergyDetected); + + otPlatRadioEnergyScanDone(aInstance, sEnergyDetected); } if (isPendingEventSet(kPendingEventSleep))