File tree Expand file tree Collapse file tree 7 files changed +96
-11
lines changed
cmsis/TARGET_STM/TARGET_STM32F3
hal/TARGET_STM/TARGET_STM32F3 Expand file tree Collapse file tree 7 files changed +96
-11
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
106
106
return HAL_OK ;
107
107
}
108
108
109
+ void HAL_SuspendTick (void )
110
+ {
111
+ TimMasterHandle .Instance = TIM_MST ;
112
+
113
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
114
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
115
+ }
116
+
117
+ void HAL_ResumeTick (void )
118
+ {
119
+ TimMasterHandle .Instance = TIM_MST ;
120
+
121
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
122
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
123
+ }
109
124
/**
110
125
* @}
111
126
*/
Original file line number Diff line number Diff line change @@ -106,6 +106,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
106
106
return HAL_OK ;
107
107
}
108
108
109
+ void HAL_SuspendTick (void )
110
+ {
111
+ TimMasterHandle .Instance = TIM_MST ;
112
+
113
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
114
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
115
+ }
116
+
117
+ void HAL_ResumeTick (void )
118
+ {
119
+ TimMasterHandle .Instance = TIM_MST ;
120
+
121
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
122
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
123
+ }
109
124
/**
110
125
* @}
111
126
*/
Original file line number Diff line number Diff line change @@ -106,6 +106,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
106
106
return HAL_OK ;
107
107
}
108
108
109
+ void HAL_SuspendTick (void )
110
+ {
111
+ TimMasterHandle .Instance = TIM_MST ;
112
+
113
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
114
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
115
+ }
116
+
117
+ void HAL_ResumeTick (void )
118
+ {
119
+ TimMasterHandle .Instance = TIM_MST ;
120
+
121
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
122
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
123
+ }
109
124
/**
110
125
* @}
111
126
*/
Original file line number Diff line number Diff line change @@ -106,6 +106,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
106
106
return HAL_OK ;
107
107
}
108
108
109
+ void HAL_SuspendTick (void )
110
+ {
111
+ TimMasterHandle .Instance = TIM_MST ;
112
+
113
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
114
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
115
+ }
116
+
117
+ void HAL_ResumeTick (void )
118
+ {
119
+ TimMasterHandle .Instance = TIM_MST ;
120
+
121
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
122
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
123
+ }
109
124
/**
110
125
* @}
111
126
*/
Original file line number Diff line number Diff line change @@ -106,6 +106,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
106
106
return HAL_OK ;
107
107
}
108
108
109
+ void HAL_SuspendTick (void )
110
+ {
111
+ TimMasterHandle .Instance = TIM_MST ;
112
+
113
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
114
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
115
+ }
116
+
117
+ void HAL_ResumeTick (void )
118
+ {
119
+ TimMasterHandle .Instance = TIM_MST ;
120
+
121
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
122
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
123
+ }
109
124
/**
110
125
* @}
111
126
*/
Original file line number Diff line number Diff line change @@ -106,6 +106,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
106
106
return HAL_OK ;
107
107
}
108
108
109
+ void HAL_SuspendTick (void )
110
+ {
111
+ TimMasterHandle .Instance = TIM_MST ;
112
+
113
+ // Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
114
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
115
+ }
116
+
117
+ void HAL_ResumeTick (void )
118
+ {
119
+ TimMasterHandle .Instance = TIM_MST ;
120
+
121
+ // Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
122
+ __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
123
+ }
109
124
/**
110
125
* @}
111
126
*/
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 = TIM2 ;
41
-
42
- // Disable HAL tick interrupt
43
- __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
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 );
42
+ // Restart HAL systick
43
+ HAL_ResumeTick ();
50
44
}
51
45
46
+
52
47
void deepsleep (void )
53
48
{
54
49
// Request to enter STOP mode with regulator in low power mode
You can’t perform that action at this time.
0 commit comments