File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 3434#include "sleep_api.h"
3535#include "rtc_api_hal.h"
3636#include "hal_tick.h"
37+ #include "mbed_critical.h"
3738
3839extern void HAL_SuspendTick (void );
3940extern void HAL_ResumeTick (void );
4041
4142void hal_sleep (void )
4243{
44+ // Disable IRQs
45+ core_util_critical_section_enter ();
46+
4347 // Stop HAL tick to avoid to exit sleep in 1ms
4448 HAL_SuspendTick ();
4549 // Request to enter SLEEP mode
4650 HAL_PWR_EnterSLEEPMode (PWR_MAINREGULATOR_ON , PWR_SLEEPENTRY_WFI );
47-
4851 // Restart HAL tick
4952 HAL_ResumeTick ();
53+
54+ // Enable IRQs
55+ core_util_critical_section_exit ();
5056}
5157
5258void hal_deepsleep (void )
5359{
60+ // Disable IRQs
61+ core_util_critical_section_enter ();
62+
5463 // Stop HAL tick
5564 HAL_SuspendTick ();
5665 uint32_t EnterTimeUS = us_ticker_read ();
@@ -82,6 +91,9 @@ void hal_deepsleep(void)
8291 // Restart HAL tick
8392 HAL_ResumeTick ();
8493
94+ // Enable IRQs
95+ core_util_critical_section_exit ();
96+
8597 // After wake-up from STOP reconfigure the PLL
8698 SetSysClock ();
8799
You can’t perform that action at this time.
0 commit comments