diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-04-12 14:01:47 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-04-20 11:19:37 -0400 |
commit | 06a4753f732cc3725a42a396a170a0a1317f741b (patch) | |
tree | af4d9ee53de4c743431c01ae3465ae001e0dfba5 /src/stm32f1 | |
parent | bf4e851e214878511a72f854f06eb921ca670837 (diff) | |
download | kutter-06a4753f732cc3725a42a396a170a0a1317f741b.tar.gz kutter-06a4753f732cc3725a42a396a170a0a1317f741b.tar.xz kutter-06a4753f732cc3725a42a396a170a0a1317f741b.zip |
stm32f1: Prefer uint32_t over uint16_t in timer.c
The ARM architecture handles 32bit values faster than 16bit values -
use uint32_t where possible.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32f1')
-rw-r--r-- | src/stm32f1/timer.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/stm32f1/timer.c b/src/stm32f1/timer.c index 76b683b3..c3b13989 100644 --- a/src/stm32f1/timer.c +++ b/src/stm32f1/timer.c @@ -27,20 +27,20 @@ union u32_u { uint32_t val; }; -static inline uint16_t +static inline uint32_t timer_get(void) { return LL_TIM_GetCounter(TIM2); } static inline void -timer_set(uint16_t next) +timer_set(uint32_t next) { LL_TIM_OC_SetCompareCH1(TIM2, next); } static inline void -timer_repeat_set(uint16_t next) +timer_repeat_set(uint32_t next) { LL_TIM_OC_SetCompareCH2(TIM2, next); LL_TIM_ClearFlag_CC2(TIM2); @@ -89,7 +89,7 @@ DECL_INIT(timer_init); * 32bit timer wrappers ****************************************************************/ -static uint16_t timer_high; +static uint32_t timer_high; // Return the current time (in absolute clock ticks). uint32_t @@ -140,7 +140,7 @@ TIM2_IRQHandler(void) { irq_disable(); LL_TIM_ClearFlag_CC1(TIM2); - uint16_t next; + uint32_t next; for (;;) { // Run the next software timer next = sched_timer_dispatch(); @@ -169,7 +169,7 @@ TIM2_IRQHandler(void) check_defer: // Check if there are too many repeat timers irq_disable(); - uint16_t now = timer_get(); + uint32_t now = timer_get(); if ((int16_t)(next - now) < (int16_t)(-timer_from_us(1000))) try_shutdown("Rescheduled timer in the past"); if (sched_tasks_busy()) { |