From 4e69a8bda6c4003c6b9e33de7db89fe073c970f5 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 1 Jul 2017 22:25:06 +0300 Subject: Add basic timing support, and SFT_T tests Also expose some bugs... --- tmk_core/common/test/timer.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tmk_core/common/test') diff --git a/tmk_core/common/test/timer.c b/tmk_core/common/test/timer.c index 09ea91a891..49efc1c1e4 100644 --- a/tmk_core/common/test/timer.c +++ b/tmk_core/common/test/timer.c @@ -16,15 +16,16 @@ #include "timer.h" -// TODO: the timer should work, but at a much faster rate than realtime -// It should also have some kind of integration with the testing system +static uint32_t current_time = 0; -void timer_init(void) {} +void timer_init(void) {current_time = 0;} -void timer_clear(void) {} +void timer_clear(void) {current_time = 0;} -uint16_t timer_read(void) { return 0; } -uint32_t timer_read32(void) { return 0; } -uint16_t timer_elapsed(uint16_t last) { return 0; } -uint32_t timer_elapsed32(uint32_t last) { return 0; } +uint16_t timer_read(void) { return current_time & 0xFFFF; } +uint32_t timer_read32(void) { return current_time; } +uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } +uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); } +void set_time(uint32_t t) { current_time = t; } +void advance_time(uint32_t ms) { current_time += ms; } \ No newline at end of file -- cgit v1.2.1