File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,32 @@ uint32_t us_ticker_read()
68
68
69
69
tim_it_update = 0 ; // Clear TIM_IT_UPDATE event flag
70
70
71
+ #if defined(TARGET_STM32L0 )
72
+ volatile uint16_t cntH_old , cntH , cntL ;
73
+ do {
74
+ // For some reason on L0xx series we need to read and clear the
75
+ // overflow flag which give extra time to propelry handle possible
76
+ // hiccup after ~60s
77
+ if (__HAL_TIM_GET_FLAG (& TimMasterHandle , TIM_FLAG_CC1OF ) == SET ) {
78
+ __HAL_TIM_CLEAR_FLAG (& TimMasterHandle , TIM_FLAG_CC1OF );
79
+ }
80
+ cntH_old = SlaveCounter ;
81
+ if (__HAL_TIM_GET_FLAG (& TimMasterHandle , TIM_FLAG_UPDATE ) == SET ) {
82
+ cntH_old += 1 ;
83
+ }
84
+ cntL = TIM_MST -> CNT ;
85
+
86
+ cntH = SlaveCounter ;
87
+ if (__HAL_TIM_GET_FLAG (& TimMasterHandle , TIM_FLAG_UPDATE ) == SET ) {
88
+ cntH += 1 ;
89
+ }
90
+ } while (cntH_old != cntH );
91
+
92
+ // Glue the upper and lower part together to get a 32 bit timer
93
+ counter = (uint32_t )(cntH << 16 | cntL );
94
+ #else
71
95
counter = TIM_MST -> CNT + (uint32_t )(SlaveCounter << 16 ); // Calculate new time stamp
96
+ #endif
72
97
73
98
if (tim_it_update == 1 ) {
74
99
return tim_it_counter ; // In case of TIM_IT_UPDATE return the time stamp that was calculated in timer_irq_handler()
You can’t perform that action at this time.
0 commit comments