aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/mbed/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/mbed/timer.c')
-rw-r--r--tmk_core/common/mbed/timer.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/tmk_core/common/mbed/timer.c b/tmk_core/common/mbed/timer.c
index c357ceb78..7e4070af2 100644
--- a/tmk_core/common/mbed/timer.c
+++ b/tmk_core/common/mbed/timer.c
@@ -5,37 +5,19 @@
5volatile uint32_t timer_count = 0; 5volatile uint32_t timer_count = 0;
6 6
7/* Timer interrupt handler */ 7/* Timer interrupt handler */
8void SysTick_Handler(void) { 8void SysTick_Handler(void) { timer_count++; }
9 timer_count++;
10}
11 9
12void timer_init(void) 10void timer_init(void) {
13{
14 timer_count = 0; 11 timer_count = 0;
15 SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */ 12 SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
16} 13}
17 14
18void timer_clear(void) 15void timer_clear(void) { timer_count = 0; }
19{
20 timer_count = 0;
21}
22 16
23uint16_t timer_read(void) 17uint16_t timer_read(void) { return (uint16_t)(timer_count & 0xFFFF); }
24{
25 return (uint16_t)(timer_count & 0xFFFF);
26}
27 18
28uint32_t timer_read32(void) 19uint32_t timer_read32(void) { return timer_count; }
29{
30 return timer_count;
31}
32 20
33uint16_t timer_elapsed(uint16_t last) 21uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); }
34{
35 return TIMER_DIFF_16(timer_read(), last);
36}
37 22
38uint32_t timer_elapsed32(uint32_t last) 23uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); }
39{
40 return TIMER_DIFF_32(timer_read32(), last);
41}