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 34
34
#include "sleep_api.h"
35
35
#include "rtc_api_hal.h"
36
36
#include "hal_tick.h"
37
+ #include "mbed_critical.h"
37
38
38
39
extern void HAL_SuspendTick (void );
39
40
extern void HAL_ResumeTick (void );
40
41
41
42
void hal_sleep (void )
42
43
{
44
+ // Disable IRQs
45
+ core_util_critical_section_enter ();
46
+
43
47
// Stop HAL tick to avoid to exit sleep in 1ms
44
48
HAL_SuspendTick ();
45
49
// Request to enter SLEEP mode
46
50
HAL_PWR_EnterSLEEPMode (PWR_MAINREGULATOR_ON , PWR_SLEEPENTRY_WFI );
47
-
48
51
// Restart HAL tick
49
52
HAL_ResumeTick ();
53
+
54
+ // Enable IRQs
55
+ core_util_critical_section_exit ();
50
56
}
51
57
52
58
void hal_deepsleep (void )
53
59
{
60
+ // Disable IRQs
61
+ core_util_critical_section_enter ();
62
+
54
63
// Stop HAL tick
55
64
HAL_SuspendTick ();
56
65
uint32_t EnterTimeUS = us_ticker_read ();
@@ -82,6 +91,9 @@ void hal_deepsleep(void)
82
91
// Restart HAL tick
83
92
HAL_ResumeTick ();
84
93
94
+ // Enable IRQs
95
+ core_util_critical_section_exit ();
96
+
85
97
// After wake-up from STOP reconfigure the PLL
86
98
SetSysClock ();
87
99
You can’t perform that action at this time.
0 commit comments