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) {
107107 return HAL_OK ;
108108}
109109
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+ }
110125/**
111126 * @}
112127 */
Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
107107 return HAL_OK ;
108108}
109109
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+ }
110125/**
111126 * @}
112127 */
Original file line number Diff line number Diff line change 3232#if DEVICE_SLEEP
3333
3434#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 );
4435
36+ void sleep (void ) {
37+ // Stop HAL systick
38+ HAL_SuspendTick ();
4539 // Request to enter SLEEP mode
4640 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 ();
5043}
5144
5245void deepsleep (void )
5346{
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 ();
5749
5850 // Request to enter STOP mode with regulator in low power mode
5951 HAL_PWR_EnterSTOPMode (PWR_LOWPOWERREGULATOR_ON , PWR_STOPENTRY_WFI );
6052
6153 // After wake-up from STOP reconfigure the PLL
6254 SetSysClock ();
6355
64- // Enable HAL tick interrupt
65- __HAL_TIM_ENABLE_IT ( & TimMasterHandle , TIM_IT_CC2 );
56+ // Restart HAL systick
57+ HAL_ResumeTick ( );
6658}
6759
6860#endif
You can’t perform that action at this time.
0 commit comments