diff options
author | Fabian Topfstedt <topfstedt@schneevonmorgen.com> | 2017-07-20 08:22:44 +0200 |
---|---|---|
committer | Fabian Topfstedt <topfstedt@schneevonmorgen.com> | 2017-07-20 08:22:44 +0200 |
commit | ee43856ff7ba37ea89d1a8a4700efba4e4f69571 (patch) | |
tree | b0ed5b538396b0b2b027e69ad8ceac443c067c79 /tmk_core/common/test/timer.c | |
parent | 99b6e918eab31d4f53cabc04a995da945335ac7f (diff) | |
parent | 14c5160b1a94d5dc416002791b3c207ba0dca789 (diff) | |
download | qmk_firmware-ee43856ff7ba37ea89d1a8a4700efba4e4f69571.tar.gz |
Merge https://github.com/qmk/qmk_firmware
Diffstat (limited to 'tmk_core/common/test/timer.c')
-rw-r--r-- | tmk_core/common/test/timer.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tmk_core/common/test/timer.c b/tmk_core/common/test/timer.c index 09ea91a89..19e79e1f5 100644 --- a/tmk_core/common/test/timer.c +++ b/tmk_core/common/test/timer.c @@ -16,15 +16,20 @@ #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; } + +void wait_ms(uint32_t ms) { + advance_time(ms); +}
\ No newline at end of file |