File tree Expand file tree Collapse file tree 3 files changed +39
-17
lines changed
cmsis/TARGET_STM/TARGET_STM32L4
hal/TARGET_STM/TARGET_STM32L4 Expand file tree Collapse file tree 3 files changed +39
-17
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
107
107
return HAL_OK ;
108
108
}
109
109
110
+ void HAL_SuspendTick (void )
111
+ {
112
+ TimMasterHandle .Instance = TIM_MST ;
113
+
114
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
115
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
116
+ }
117
+
118
+ void HAL_ResumeTick (void )
119
+ {
120
+ TimMasterHandle .Instance = TIM_MST ;
121
+
122
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
123
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
124
+ }
110
125
/**
111
126
* @}
112
127
*/
Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
107
107
return HAL_OK ;
108
108
}
109
109
110
+ void HAL_SuspendTick (void )
111
+ {
112
+ TimMasterHandle .Instance = TIM_MST ;
113
+
114
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
115
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
116
+ }
117
+
118
+ void HAL_ResumeTick (void )
119
+ {
120
+ TimMasterHandle .Instance = TIM_MST ;
121
+
122
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
123
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
124
+ }
110
125
/**
111
126
* @}
112
127
*/
Original file line number Diff line number Diff line change 32
32
#if DEVICE_SLEEP
33
33
34
34
#include "cmsis.h"
35
- #include "hal_tick.h"
36
-
37
- static TIM_HandleTypeDef TimMasterHandle ;
38
-
39
- void sleep (void )
40
- {
41
- // Disable HAL tick interrupt
42
- TimMasterHandle .Instance = TIM_MST ;
43
- __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
44
35
36
+ void sleep (void ) {
37
+ // Stop HAL systick
38
+ HAL_SuspendTick ();
45
39
// Request to enter SLEEP mode
46
40
HAL_PWR_EnterSLEEPMode (PWR_MAINREGULATOR_ON , PWR_SLEEPENTRY_WFI );
47
-
48
- // Enable HAL tick interrupt
49
- __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
41
+ // Restart HAL systick
42
+ HAL_ResumeTick ();
50
43
}
51
44
52
45
void deepsleep (void )
53
46
{
54
- // Disable HAL tick interrupt
55
- TimMasterHandle .Instance = TIM_MST ;
56
- __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
47
+ // Stop HAL systick
48
+ HAL_SuspendTick ();
57
49
58
50
// Request to enter STOP mode with regulator in low power mode
59
51
HAL_PWR_EnterSTOPMode (PWR_LOWPOWERREGULATOR_ON , PWR_STOPENTRY_WFI );
60
52
61
53
// After wake-up from STOP reconfigure the PLL
62
54
SetSysClock ();
63
55
64
- // Enable HAL tick interrupt
65
- __HAL_TIM_ENABLE_IT ( & TimMasterHandle , TIM_IT_CC2 );
56
+ // Restart HAL systick
57
+ HAL_ResumeTick ( );
66
58
}
67
59
68
60
#endif
You can’t perform that action at this time.
0 commit comments