From 5782e93a194296252466e8c9e844a6c2503c5c70 Mon Sep 17 00:00:00 2001 From: Steve Cartmell Date: Wed, 21 Nov 2018 17:56:14 +0000 Subject: [PATCH] fix(pan-cordio): Wrap call to wsfOsReadyToSleep in a critical section The function wsfOsReadyToSleep should only be called when interrupts are disabled. Entering a critical section before calling the function fixes any potential issues. --- .../FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp index 144d1bf76d..c13b0228f9 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp @@ -17,6 +17,7 @@ #include "mbed.h" #include "us_ticker_api.h" #include "BLE.h" +#include "CriticalSectionLock.h" #include "wsf_types.h" #include "wsf_msg.h" #include "wsf_os.h" @@ -412,6 +413,8 @@ void BLE::callDispatcher() wsfOsDispatcher(); + CriticalSectionLock critical_section; + if (wsfOsReadyToSleep()) { static Timeout nextTimeout; // setup an mbed timer for the next Cordio timeout