[PATCH] Implementation for STM32 HAL_GetTick using RTEMS

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 23 09:48:40 UTC 2021


On 22/04/2021 19:17, Robin Mueller wrote:

> 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)

With this calculation the tick increments in one second steps. Maybe 
just use:

return rtems_clock_get_ticks_since_boot() * 
rtems_configuration_get_milliseconds_per_tick().

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/



More information about the devel mailing list