File tree Expand file tree Collapse file tree 4 files changed +56
-14
lines changed
cmsis/TARGET_STM/TARGET_STM32L1
hal/TARGET_STM/TARGET_STM32L1 Expand file tree Collapse file tree 4 files changed +56
-14
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
107
107
return HAL_OK ;
108
108
}
109
109
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
+ }
110
125
/**
111
126
* @}
112
127
*/
Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
107
107
return HAL_OK ;
108
108
}
109
109
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
+ }
110
125
/**
111
126
* @}
112
127
*/
Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
107
107
return HAL_OK ;
108
108
}
109
109
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
+ }
110
125
/**
111
126
* @}
112
127
*/
Original file line number Diff line number Diff line change 28
28
*******************************************************************************
29
29
*/
30
30
#include "sleep_api.h"
31
+ #include "hal_tick.h"
31
32
32
33
#if DEVICE_SLEEP
33
34
34
35
#include "cmsis.h"
35
36
36
37
static TIM_HandleTypeDef TimMasterHandle ;
37
38
38
- void sleep (void )
39
- {
40
- // Disable HAL tick interrupt
41
- TimMasterHandle .Instance = TIM5 ;
42
- __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
43
-
39
+ void sleep (void ) {
40
+ // Stop HAL systick
41
+ HAL_SuspendTick ();
44
42
// Request to enter SLEEP mode
45
43
HAL_PWR_EnterSLEEPMode (PWR_MAINREGULATOR_ON , PWR_SLEEPENTRY_WFI );
46
-
47
- // Enable HAL tick interrupt
48
- __HAL_TIM_ENABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
44
+ // Restart HAL systick
45
+ HAL_ResumeTick ();
49
46
}
50
47
48
+
51
49
void deepsleep (void )
52
50
{
53
51
#if defined(TARGET_MOTE_L152RC )
54
52
int8_t STOPEntry = PWR_STOPENTRY_WFI ;
55
53
#endif
56
54
57
- // Disable HAL tick interrupt
58
- TimMasterHandle .Instance = TIM5 ;
59
- __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC2 );
55
+ // Stop HAL systick
56
+ TimMasterHandle .Instance = TIM_MST ;
60
57
61
58
#if defined(TARGET_MOTE_L152RC )
62
59
/* Select the regulator state in Stop mode: Set PDDS and LPSDSR bit according to PWR_Regulator value */
@@ -91,8 +88,8 @@ void deepsleep(void)
91
88
// After wake-up from STOP reconfigure the PLL
92
89
SetSysClock ();
93
90
94
- // Enable HAL tick interrupt
95
- __HAL_TIM_ENABLE_IT ( & TimMasterHandle , TIM_IT_CC2 );
91
+ // Restart HAL systick
92
+ HAL_ResumeTick ( );
96
93
}
97
94
98
95
#endif
You can’t perform that action at this time.
0 commit comments