File tree Expand file tree Collapse file tree 6 files changed +80
-11
lines changed
cmsis/TARGET_STM/TARGET_STM32L0
hal/TARGET_STM/TARGET_STM32L0 Expand file tree Collapse file tree 6 files changed +80
-11
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
131
131
return HAL_OK ;
132
132
}
133
133
134
+ void HAL_SuspendTick (void )
135
+ {
136
+ TimMasterHandle .Instance = TIM_MST ;
137
+
138
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
139
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
140
+ }
141
+
142
+ void HAL_ResumeTick (void )
143
+ {
144
+ TimMasterHandle .Instance = TIM_MST ;
145
+
146
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
147
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
148
+ }
134
149
/**
135
150
* @}
136
151
*/
Original file line number Diff line number Diff line change @@ -140,6 +140,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
140
140
return HAL_OK ;
141
141
}
142
142
143
+ void HAL_SuspendTick (void )
144
+ {
145
+ TimMasterHandle .Instance = TIM_MST ;
146
+
147
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
148
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
149
+ }
150
+
151
+ void HAL_ResumeTick (void )
152
+ {
153
+ TimMasterHandle .Instance = TIM_MST ;
154
+
155
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
156
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
157
+ }
143
158
/**
144
159
* @}
145
160
*/
Original file line number Diff line number Diff line change @@ -131,6 +131,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
131
131
return HAL_OK ;
132
132
}
133
133
134
+ void HAL_SuspendTick (void )
135
+ {
136
+ TimMasterHandle .Instance = TIM_MST ;
137
+
138
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
139
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
140
+ }
141
+
142
+ void HAL_ResumeTick (void )
143
+ {
144
+ TimMasterHandle .Instance = TIM_MST ;
145
+
146
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
147
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
148
+ }
134
149
/**
135
150
* @}
136
151
*/
Original file line number Diff line number Diff line change @@ -131,6 +131,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
131
131
return HAL_OK ;
132
132
}
133
133
134
+ void HAL_SuspendTick (void )
135
+ {
136
+ TimMasterHandle .Instance = TIM_MST ;
137
+
138
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
139
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
140
+ }
141
+
142
+ void HAL_ResumeTick (void )
143
+ {
144
+ TimMasterHandle .Instance = TIM_MST ;
145
+
146
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
147
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
148
+ }
134
149
/**
135
150
* @}
136
151
*/
Original file line number Diff line number Diff line change @@ -131,6 +131,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
131
131
return HAL_OK ;
132
132
}
133
133
134
+ void HAL_SuspendTick (void )
135
+ {
136
+ TimMasterHandle .Instance = TIM_MST ;
137
+
138
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
139
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
140
+ }
141
+
142
+ void HAL_ResumeTick (void )
143
+ {
144
+ TimMasterHandle .Instance = TIM_MST ;
145
+
146
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
147
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
148
+ }
134
149
/**
135
150
* @}
136
151
*/
Original file line number Diff line number Diff line change 33
33
34
34
#include "cmsis.h"
35
35
36
- static TIM_HandleTypeDef TimMasterHandle ;
37
-
38
- void sleep (void )
39
- {
40
- TimMasterHandle .Instance = TIM21 ;
41
-
42
- // Disable HAL tick interrupt
43
- __HAL_TIM_DISABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
44
36
37
+ void sleep (void ) {
38
+ // Stop HAL systick
39
+ HAL_SuspendTick ();
45
40
// Request to enter SLEEP mode
46
41
HAL_PWR_EnterSLEEPMode (PWR_MAINREGULATOR_ON , PWR_SLEEPENTRY_WFI );
47
-
48
- // Enable HAL tick interrupt
49
- __HAL_TIM_ENABLE_IT (& TimMasterHandle , (TIM_IT_CC2 | TIM_IT_UPDATE ));
42
+ // Restart HAL systick
43
+ HAL_ResumeTick ();
50
44
}
51
45
52
46
void deepsleep (void )
You can’t perform that action at this time.
0 commit comments