20
20
21
21
TIM_HandleTypeDef TimMasterHandle ;
22
22
23
+ bool us_ticker_initialized = false;
24
+
23
25
const ticker_info_t * us_ticker_get_info ()
24
26
{
25
27
static const ticker_info_t info = {
@@ -53,7 +55,7 @@ void timer_oc_irq_handler(void)
53
55
if (__HAL_TIM_GET_FLAG (& TimMasterHandle , TIM_FLAG_CC1 ) == SET ) {
54
56
if (__HAL_TIM_GET_IT_SOURCE (& TimMasterHandle , TIM_IT_CC1 ) == SET ) {
55
57
__HAL_TIM_CLEAR_IT (& TimMasterHandle , TIM_IT_CC1 );
56
- us_ticker_irq_handler ();
58
+ us_ticker_irq_handler ();
57
59
}
58
60
}
59
61
}
@@ -76,6 +78,11 @@ void timer_irq_handler(void)
76
78
77
79
void us_ticker_init (void )
78
80
{
81
+ if (us_ticker_initialized ) {
82
+ __HAL_TIM_DISABLE_IT (& TimMasterHandle , TIM_IT_CC1 );
83
+ __HAL_TIM_CLEAR_FLAG (& TimMasterHandle , TIM_FLAG_CC1 );
84
+ return ;
85
+ }
79
86
80
87
// ************************************ 16-bit timer ************************************
81
88
#if TIM_MST_BIT_WIDTH == 16
@@ -195,6 +202,8 @@ void us_ticker_init(void)
195
202
196
203
#endif // 16-bit/32-bit timer
197
204
205
+ us_ticker_initialized = true;
206
+
198
207
}
199
208
200
209
uint32_t us_ticker_read ()
0 commit comments