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