summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Župa <pavel.zupa@gmail.com>2020-02-01 10:17:28 +0100
committerFlorian Didron <fdidron@users.noreply.github.com>2020-02-26 10:15:12 +0900
commit7ed8cd4f17bef0392c56dfb2b6ddc20c9ab354ed (patch)
tree67d269c83f570172db80bccc5173899a70bc0308
parent4029f3ff509a967220c3a5671e3afd63bdd01d5a (diff)
Fix timer_elapsed() overflow issue for STM32F103 and other ChibiOS boards (#7595)
* fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
-rw-r--r--tmk_core/common/chibios/timer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tmk_core/common/chibios/timer.c b/tmk_core/common/chibios/timer.c
index 1ce9d1d17c..66c4a6458e 100644
--- a/tmk_core/common/chibios/timer.c
+++ b/tmk_core/common/chibios/timer.c
@@ -28,6 +28,10 @@ uint32_t timer_read32(void) {
return current_time_ms;
}
-uint16_t timer_elapsed(uint16_t last) { return timer_read() - last; }
+uint16_t timer_elapsed(uint16_t last) {
+ return TIMER_DIFF_16(timer_read(), last);
+}
-uint32_t timer_elapsed32(uint32_t last) { return timer_read32() - last; }
+uint32_t timer_elapsed32(uint32_t last) {
+ return TIMER_DIFF_32(timer_read32(), last);
+}