aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/arm_atsam/timer.c20
-rw-r--r--tmk_core/common/wait.h4
2 files changed, 6 insertions, 18 deletions
diff --git a/tmk_core/common/arm_atsam/timer.c b/tmk_core/common/arm_atsam/timer.c
index bcfe5002c..6c3905e30 100644
--- a/tmk_core/common/arm_atsam/timer.c
+++ b/tmk_core/common/arm_atsam/timer.c
@@ -9,7 +9,7 @@ void set_time(uint64_t tset)
9 9
10void timer_init(void) 10void timer_init(void)
11{ 11{
12 ms_clk = 0; 12 timer_clear();
13} 13}
14 14
15uint16_t timer_read(void) 15uint16_t timer_read(void)
@@ -37,23 +37,7 @@ uint32_t timer_elapsed32(uint32_t tlast)
37 return TIMER_DIFF_32(timer_read32(), tlast); 37 return TIMER_DIFF_32(timer_read32(), tlast);
38} 38}
39 39
40uint32_t timer_elapsed64(uint32_t tlast)
41{
42 uint64_t tnow = timer_read64();
43 return (tnow >= tlast ? tnow - tlast : UINT64_MAX - tlast + tnow);
44}
45
46void timer_clear(void) 40void timer_clear(void)
47{ 41{
48 ms_clk = 0; 42 set_time(0);
49}
50
51void wait_ms(uint64_t msec)
52{
53 CLK_delay_ms(msec);
54}
55
56void wait_us(uint16_t usec)
57{
58 CLK_delay_us(usec);
59} 43}
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h
index a7cded942..a77840bce 100644
--- a/tmk_core/common/wait.h
+++ b/tmk_core/common/wait.h
@@ -15,6 +15,10 @@ extern "C" {
15# include "ch.h" 15# include "ch.h"
16# define wait_ms(ms) chThdSleepMilliseconds(ms) 16# define wait_ms(ms) chThdSleepMilliseconds(ms)
17# define wait_us(us) chThdSleepMicroseconds(us) 17# define wait_us(us) chThdSleepMicroseconds(us)
18#elif defined PROTOCOL_ARM_ATSAM
19# include "clks.h"
20# define wait_ms(ms) CLK_delay_ms(ms)
21# define wait_us(us) CLK_delay_us(us)
18#elif defined(__arm__) 22#elif defined(__arm__)
19# include "wait_api.h" 23# include "wait_api.h"
20#else // Unit tests 24#else // Unit tests