File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
libraries/SrcWrapper/src/stm32 Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -28,16 +28,17 @@ extern "C" {
28
28
*/
29
29
uint32_t getCurrentMicros (void )
30
30
{
31
- /* Ensure COUNTFLAG is reset by reading SysTick control and status register */
32
- LL_SYSTICK_IsActiveCounterFlag ();
33
- uint32_t m = HAL_GetTick ();
31
+ uint32_t m0 = HAL_GetTick ();
32
+ __IO uint32_t u0 = SysTick -> VAL ;
33
+ uint32_t m1 = HAL_GetTick ();
34
+ __IO uint32_t u1 = SysTick -> VAL ;
34
35
const uint32_t tms = SysTick -> LOAD + 1 ;
35
- __IO uint32_t u = tms - SysTick -> VAL ;
36
- if (LL_SYSTICK_IsActiveCounterFlag ()) {
37
- m = HAL_GetTick ();
38
- u = tms - SysTick -> VAL ;
36
+
37
+ if (m1 != m0 ) {
38
+ return ( m1 * 1000 + ((tms - u1 ) * 1000 ) / tms );
39
+ } else {
40
+ return ( m0 * 1000 + ((tms - u0 ) * 1000 ) / tms );
39
41
}
40
- return (m * 1000 + (u * 1000 ) / tms );
41
42
}
42
43
43
44
/**
You can’t perform that action at this time.
0 commit comments