From 295afaaf6c91a32c7e7a53338a4cb4ac08c555e0 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 24 Jul 2019 16:31:25 -0400 Subject: [PATCH] Update SystemCoreClock macro --- ports/stm32f4/tick.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c index 2596e34d17..5bd2da6edc 100644 --- a/ports/stm32f4/tick.c +++ b/ports/stm32f4/tick.c @@ -55,12 +55,12 @@ void SysTick_Handler(void) { } void tick_init() { - uint32_t ticks_per_ms = 16000000/ 1000; + uint32_t ticks_per_ms = SystemCoreClock/ 1000; SysTick_Config(ticks_per_ms); // interrupt is enabled } void tick_delay(uint32_t us) { - uint32_t ticks_per_us = 16000000 / 1000 / 1000; + uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; uint32_t us_between_ticks = SysTick->VAL / ticks_per_us; uint64_t start_ms = ticks_ms; while (us > 1000) { @@ -74,12 +74,12 @@ void tick_delay(uint32_t us) { // us counts down! void current_tick(uint64_t* ms, uint32_t* us_until_ms) { - uint32_t ticks_per_us = 16000000 / 1000 / 1000; + uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; *ms = ticks_ms; *us_until_ms = SysTick->VAL / ticks_per_us; } void wait_until(uint64_t ms, uint32_t us_until_ms) { - uint32_t ticks_per_us = 16000000 / 1000 / 1000; + uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} }