Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 7691a8e

Browse files
author
Jay Logue
authored
Merge pull request #420 from openweave/issue/nordic-freertos-assert
Fix for issue #419 : nRF52: Crash in FreeRTOS when configASSERT defined
2 parents 9238c86 + d7d19a6 commit 7691a8e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/adaptations/device-layer/nRF5/nRF5Config.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -716,19 +716,24 @@ void NRF5Config::HandleFDSEvent(const fds_evt_t * fdsEvent)
716716

717717
// Signal the Weave thread that the operation has completed.
718718
#if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
719-
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
720-
{
721-
BaseType_t yieldRequired = xSemaphoreGiveFromISR(sAsyncOpCompletionSem, &yieldRequired);
722-
if (yieldRequired == pdTRUE)
723-
{
724-
portYIELD_FROM_ISR(yieldRequired);
725-
}
726-
}
727-
else
728-
#endif // defined(SOFTDEVICE_PRESENT) || !SOFTDEVICE_PRESENT
719+
720+
// When using the Nodic SoftDevice, HandleFDSEvent() is called in a SoftDevice interrupt
721+
// context. Therefore, we must use xSemaphoreGiveFromISR() to signal completion.
722+
BaseType_t yieldRequired = xSemaphoreGiveFromISR(sAsyncOpCompletionSem, &yieldRequired);
723+
724+
// Yield to the next runnable task, but only if the FreeRTOS scheduler has been started.
725+
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED && yieldRequired == pdTRUE)
729726
{
730-
xSemaphoreGive(sAsyncOpCompletionSem);
727+
portYIELD_FROM_ISR(yieldRequired);
731728
}
729+
730+
#else // defined(SOFTDEVICE_PRESENT) || !SOFTDEVICE_PRESENT
731+
732+
// When NOT using the Nodic SoftDevice, HandleFDSEvent() is called in a non-interrupt
733+
// context. Therefore, use xSemaphoreGive() to signal completion.
734+
xSemaphoreGive(sAsyncOpCompletionSem);
735+
736+
#endif // !(defined(SOFTDEVICE_PRESENT) || !SOFTDEVICE_PRESENT)
732737
}
733738

734739
void NRF5Config::RunConfigUnitTest()

0 commit comments

Comments
 (0)