mbed library sources. Supersedes mbed-src. Fixed broken STM32F1xx RTC on rtc_api.c
Dependents: Nucleo_F103RB_RTC_battery_bkup_pwr_off_okay
Fork of mbed-dev by
Diff: targets/TARGET_STM/sleep.c
- Revision:
- 172:7d866c31b3c5
- Parent:
- 160:d5399cc887bb
diff -r 89b338f31ef1 -r 7d866c31b3c5 targets/TARGET_STM/sleep.c --- a/targets/TARGET_STM/sleep.c Wed Aug 16 18:27:13 2017 +0100 +++ b/targets/TARGET_STM/sleep.c Thu Aug 31 17:27:04 2017 +0100 @@ -34,23 +34,32 @@ #include "sleep_api.h" #include "rtc_api_hal.h" #include "hal_tick.h" +#include "mbed_critical.h" extern void HAL_SuspendTick(void); extern void HAL_ResumeTick(void); void hal_sleep(void) { + // Disable IRQs + core_util_critical_section_enter(); + // Stop HAL tick to avoid to exit sleep in 1ms HAL_SuspendTick(); // Request to enter SLEEP mode HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); - // Restart HAL tick HAL_ResumeTick(); + + // Enable IRQs + core_util_critical_section_exit(); } void hal_deepsleep(void) { + // Disable IRQs + core_util_critical_section_enter(); + // Stop HAL tick HAL_SuspendTick(); uint32_t EnterTimeUS = us_ticker_read(); @@ -82,6 +91,9 @@ // Restart HAL tick HAL_ResumeTick(); + // Enable IRQs + core_util_critical_section_exit(); + // After wake-up from STOP reconfigure the PLL SetSysClock();