Skip to content

Commit 6b8ff8f

Browse files
authored
Merge pull request #2192 from egostm/sleep_code_refactor
[STM32] Sleep code refactor
2 parents c8a5aae + f712041 commit 6b8ff8f

File tree

50 files changed

+664
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+664
-121
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F030R8/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
149149
return HAL_OK;
150150
}
151151

152+
void HAL_SuspendTick(void)
153+
{
154+
TimMasterHandle.Instance = TIM_MST;
155+
156+
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
157+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
158+
}
159+
160+
void HAL_ResumeTick(void)
161+
{
162+
TimMasterHandle.Instance = TIM_MST;
163+
164+
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
165+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
166+
}
152167
/**
153168
* @}
154169
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F031K6/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
113113
return HAL_OK;
114114
}
115115

116+
void HAL_SuspendTick(void)
117+
{
118+
TimMasterHandle.Instance = TIM_MST;
119+
120+
// Disable HAL tick
121+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
122+
}
123+
124+
void HAL_ResumeTick(void)
125+
{
126+
TimMasterHandle.Instance = TIM_MST;
127+
128+
// Enable HAL tick
129+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
130+
}
116131
/**
117132
* @}
118133
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F042K6/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
113113
return HAL_OK;
114114
}
115115

116+
void HAL_SuspendTick(void)
117+
{
118+
TimMasterHandle.Instance = TIM_MST;
119+
120+
// Disable HAL tick
121+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
122+
}
123+
124+
void HAL_ResumeTick(void)
125+
{
126+
TimMasterHandle.Instance = TIM_MST;
127+
128+
// Enable HAL tick
129+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
130+
}
116131
/**
117132
* @}
118133
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F070RB/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
161161
return HAL_OK;
162162
}
163163

164+
void HAL_SuspendTick(void)
165+
{
166+
TimMasterHandle.Instance = TIM_MST;
167+
168+
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
169+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
170+
}
171+
172+
void HAL_ResumeTick(void)
173+
{
174+
TimMasterHandle.Instance = TIM_MST;
175+
176+
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
177+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
178+
}
164179
/**
165180
* @}
166181
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
113113
return HAL_OK;
114114
}
115115

116+
void HAL_SuspendTick(void)
117+
{
118+
TimMasterHandle.Instance = TIM_MST;
119+
120+
// Disable HAL tick
121+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
122+
}
123+
124+
void HAL_ResumeTick(void)
125+
{
126+
TimMasterHandle.Instance = TIM_MST;
127+
128+
// Enable HAL tick
129+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
130+
}
116131
/**
117132
* @}
118133
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F091RC/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
113113
return HAL_OK;
114114
}
115115

116+
void HAL_SuspendTick(void)
117+
{
118+
TimMasterHandle.Instance = TIM_MST;
119+
120+
// Disable HAL tick
121+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
122+
}
123+
124+
void HAL_ResumeTick(void)
125+
{
126+
TimMasterHandle.Instance = TIM_MST;
127+
128+
// Enable HAL tick
129+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
130+
}
116131
/**
117132
* @}
118133
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_DISCO_F100RB/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
137137
return HAL_OK;
138138
}
139139

140+
void HAL_SuspendTick(void)
141+
{
142+
TimMasterHandle.Instance = TIM_MST;
143+
144+
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
145+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
146+
}
147+
148+
void HAL_ResumeTick(void)
149+
{
150+
TimMasterHandle.Instance = TIM_MST;
151+
152+
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
153+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
154+
}
140155
/**
141156
* @}
142157
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
138138
return HAL_OK;
139139
}
140140

141+
void HAL_SuspendTick(void)
142+
{
143+
TimMasterHandle.Instance = TIM_MST;
144+
145+
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
146+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
147+
}
148+
149+
void HAL_ResumeTick(void)
150+
{
151+
TimMasterHandle.Instance = TIM_MST;
152+
153+
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
154+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
155+
}
141156
/**
142157
* @}
143158
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_DISCO_F303VC/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
110110
return HAL_OK;
111111
}
112112

113+
void HAL_SuspendTick(void)
114+
{
115+
TimMasterHandle.Instance = TIM_MST;
116+
117+
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
118+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
119+
}
120+
121+
void HAL_ResumeTick(void)
122+
{
123+
TimMasterHandle.Instance = TIM_MST;
124+
125+
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
126+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
127+
}
113128
/**
114129
* @}
115130
*/

hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_DISCO_F334C8/hal_tick.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
110110
return HAL_OK;
111111
}
112112

113+
void HAL_SuspendTick(void)
114+
{
115+
TimMasterHandle.Instance = TIM_MST;
116+
117+
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
118+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
119+
}
120+
121+
void HAL_ResumeTick(void)
122+
{
123+
TimMasterHandle.Instance = TIM_MST;
124+
125+
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
126+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
127+
}
113128
/**
114129
* @}
115130
*/

0 commit comments

Comments
 (0)