diff options
| author | Hierophect <hierophect@gmail.com> | 2019-07-24 16:31:25 -0400 |
|---|---|---|
| committer | Hierophect <hierophect@gmail.com> | 2019-07-24 16:31:25 -0400 |
| commit | 295afaaf6c91a32c7e7a53338a4cb4ac08c555e0 (patch) | |
| tree | 2d495f997be8923cc66a67061cb32540b200ec25 | |
| parent | a63df51893075b09a69beb40a3636fb9723b3b60 (diff) | |
Update SystemCoreClock macro
| -rw-r--r-- | ports/stm32f4/tick.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c index 2596e34d1..5bd2da6ed 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) {} } |
