From 1e9303cf6b0cafe7be66bf913cf7ca85328e7633 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 16 Jan 2018 09:21:36 +0100 Subject: [PATCH 1/2] clean unuseful comments Signed-off-by: Frederic Pillon --- cores/arduino/stm32/clock.c | 66 ------------------------------------- 1 file changed, 66 deletions(-) diff --git a/cores/arduino/stm32/clock.c b/cores/arduino/stm32/clock.c index f5ee4d2de4..29a445ad1b 100644 --- a/cores/arduino/stm32/clock.c +++ b/cores/arduino/stm32/clock.c @@ -35,67 +35,12 @@ * ****************************************************************************** */ -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32f4xx_system - * @{ - */ - -/** @addtogroup STM32F4xx_System_Private_Includes - * @{ - */ #include "stm32_def.h" #ifdef __cplusplus extern "C" { #endif -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Variables - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - /** * @brief Function called to read the current micro second * @param None @@ -176,17 +121,6 @@ void delayInsideIT(uint32_t delay_us) #endif } -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ #ifdef __cplusplus } #endif From 15dc04b0a0ceaa612e80f7c26d78c4fb68aa8b56 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 16 Jan 2018 17:50:34 +0100 Subject: [PATCH 2/2] Improves micros() accuracy using SysTick COUNTFLAG Signed-off-by: Frederic Pillon --- cores/arduino/stm32/clock.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cores/arduino/stm32/clock.c b/cores/arduino/stm32/clock.c index 29a445ad1b..18856903d1 100644 --- a/cores/arduino/stm32/clock.c +++ b/cores/arduino/stm32/clock.c @@ -48,16 +48,15 @@ */ uint32_t GetCurrentMicro(void) { - uint32_t m0 = HAL_GetTick(); - uint32_t u0 = SysTick->LOAD - SysTick->VAL; - uint32_t m1 = HAL_GetTick(); - uint32_t u1 = SysTick->LOAD - SysTick->VAL; - - if (m1 > m0) { - return ( m1 * 1000 + (u1 * 1000) / SysTick->LOAD); - } else { - return ( m0 * 1000 + (u0 * 1000) / SysTick->LOAD); + /* Ensure COUNTFLAG is reset by reading SysTick control and status register */ + LL_SYSTICK_IsActiveCounterFlag(); + uint32_t m = HAL_GetTick(); + uint32_t u = SysTick->LOAD - SysTick->VAL; + if(LL_SYSTICK_IsActiveCounterFlag()) { + m = HAL_GetTick(); + u = SysTick->LOAD - SysTick->VAL; } + return ( m * 1000 + (u * 1000) / SysTick->LOAD); } /**