mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: platform/mbed_critical.c
- Revision:
- 189:f392fc9709a3
- Parent:
- 188:bcfe06ba3d64
--- a/platform/mbed_critical.c Thu Nov 08 11:46:34 2018 +0000 +++ b/platform/mbed_critical.c Wed Feb 20 22:31:08 2019 +0000 @@ -100,6 +100,11 @@ } } +void core_util_atomic_flag_clear(volatile core_util_atomic_flag *flagPtr) +{ + flagPtr->_flag = false; +} + #if MBED_EXCLUSIVE_ACCESS /* Supress __ldrex and __strex deprecated warnings - "#3731-D: intrinsic is deprecated" */ @@ -107,6 +112,15 @@ #pragma diag_suppress 3731 #endif +bool core_util_atomic_flag_test_and_set(volatile core_util_atomic_flag *flagPtr) +{ + uint8_t currentValue; + do { + currentValue = __LDREXB(&flagPtr->_flag); + } while (__STREXB(true, &flagPtr->_flag)); + return currentValue; +} + bool core_util_atomic_cas_u8(volatile uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue) { do { @@ -204,6 +218,15 @@ #else +bool core_util_atomic_flag_test_and_set(volatile core_util_atomic_flag *flagPtr) +{ + core_util_critical_section_enter(); + uint8_t currentValue = flagPtr->_flag; + flagPtr->_flag = true; + core_util_critical_section_exit(); + return currentValue; +} + bool core_util_atomic_cas_u8(volatile uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue) { bool success;