mirror of https://github.com/ARMmbed/mbed-os.git
Update critical section for NRF5x
parent
efa3461fd4
commit
cf61c240bf
|
@ -19,13 +19,13 @@
|
||||||
#include "app_util_platform.h"
|
#include "app_util_platform.h"
|
||||||
|
|
||||||
#if defined(SOFTDEVICE_PRESENT)
|
#if defined(SOFTDEVICE_PRESENT)
|
||||||
static volatile uint32_t nordic_cr_nested = 0;
|
static volatile bool state_saved = false;
|
||||||
|
|
||||||
static void nordic_nvic_critical_region_enter(void);
|
static void nordic_nvic_critical_region_enter(void);
|
||||||
static void nordic_nvic_critical_region_exit(void);
|
static void nordic_nvic_critical_region_exit(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void core_util_critical_section_enter()
|
void hal_critical_section_enter()
|
||||||
{
|
{
|
||||||
#ifdef NRF52
|
#ifdef NRF52
|
||||||
ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get())
|
ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get())
|
||||||
|
@ -39,7 +39,7 @@ void core_util_critical_section_enter()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void core_util_critical_section_exit()
|
void hal_critical_section_exit()
|
||||||
{
|
{
|
||||||
#ifdef NRF52
|
#ifdef NRF52
|
||||||
ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get())
|
ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get())
|
||||||
|
@ -53,6 +53,13 @@ void core_util_critical_section_exit()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool hal_in_critical_section(void)
|
||||||
|
{
|
||||||
|
return (state_saved != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(SOFTDEVICE_PRESENT)
|
#if defined(SOFTDEVICE_PRESENT)
|
||||||
/**@brief Enters critical region.
|
/**@brief Enters critical region.
|
||||||
*
|
*
|
||||||
|
@ -63,7 +70,7 @@ static inline void nordic_nvic_critical_region_enter(void)
|
||||||
{
|
{
|
||||||
int was_masked = __sd_nvic_irq_disable();
|
int was_masked = __sd_nvic_irq_disable();
|
||||||
|
|
||||||
if (nordic_cr_nested == 0) {
|
if (state_saved == false) {
|
||||||
nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 );
|
nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 );
|
||||||
NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0;
|
NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0;
|
||||||
#ifdef NRF52
|
#ifdef NRF52
|
||||||
|
@ -72,7 +79,7 @@ static inline void nordic_nvic_critical_region_enter(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nordic_cr_nested++;
|
state_saved = true;
|
||||||
|
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
__sd_nvic_irq_enable();
|
__sd_nvic_irq_enable();
|
||||||
|
@ -86,9 +93,8 @@ static inline void nordic_nvic_critical_region_enter(void)
|
||||||
*/
|
*/
|
||||||
static inline void nordic_nvic_critical_region_exit(void)
|
static inline void nordic_nvic_critical_region_exit(void)
|
||||||
{
|
{
|
||||||
nordic_cr_nested--;
|
state_saved = false;
|
||||||
|
|
||||||
if (nordic_cr_nested == 0) {
|
|
||||||
int was_masked = __sd_nvic_irq_disable();
|
int was_masked = __sd_nvic_irq_disable();
|
||||||
NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0];
|
NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0];
|
||||||
#ifdef NRF52
|
#ifdef NRF52
|
||||||
|
@ -98,5 +104,4 @@ static inline void nordic_nvic_critical_region_exit(void)
|
||||||
__sd_nvic_irq_enable();
|
__sd_nvic_irq_enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue