[PATCH] Implementation for STM32 HAL_GetTick using RTEMS

Robin Mueller robin.mueller.m at gmail.com
Thu Apr 22 17:17:21 UTC 2021


Accounts for the tick base not being 1ms now.
Perform division first to reduce chance of arithmetic overflow.
---
 bsps/arm/stm32h7/start/bspstart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bsps/arm/stm32h7/start/bspstart.c b/bsps/arm/stm32h7/start/bspstart.c
index 7ae39f1410..536325293d 100644
--- a/bsps/arm/stm32h7/start/bspstart.c
+++ b/bsps/arm/stm32h7/start/bspstart.c
@@ -35,8 +35,7 @@
 /* Get number of milliseconds elapsed since startup */
 uint32_t HAL_GetTick(void)
 {
-  uint64_t temp = rtems_clock_get_uptime_nanoseconds() / (1000 * 1000);
-  return temp;
+  return (rtems_clock_get_ticks_since_boot() / rtems_clock_get_ticks_per_second()) * 1000;
 }
 
 uint32_t stm32h7_systick_frequency(void)
-- 
2.25.1



More information about the devel mailing list