diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 20:51:36 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 20:51:36 -0600 |
commit | 3c3e9e2c62ad9a83ab9b0e1255204d57894c20ff (patch) | |
tree | 3ad8898edb89eba0e62ac0c27487949bfa72c135 /libhw/rp2040_hwtimer.c | |
parent | 6c114930eef133293856189a93f7ca7ca3751268 (diff) |
host alarmclock
Diffstat (limited to 'libhw/rp2040_hwtimer.c')
-rw-r--r-- | libhw/rp2040_hwtimer.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libhw/rp2040_hwtimer.c b/libhw/rp2040_hwtimer.c index 6daa69d..54bdab3 100644 --- a/libhw/rp2040_hwtimer.c +++ b/libhw/rp2040_hwtimer.c @@ -16,7 +16,7 @@ #include <libhw/generic/alarmclock.h> #include <libhw/rp2040_hwtimer.h> -/* Init ***********************************************************************/ +/* Types **********************************************************************/ struct rp2040_hwtimer { implements_alarmclock; @@ -25,6 +25,8 @@ struct rp2040_hwtimer { struct alarmclock_trigger *queue; }; +/* Globals ********************************************************************/ + static uint64_t rp2040_hwtimer_get_time_ns(implements_alarmclock *self); static bool rp2040_hwtimer_add_trigger(implements_alarmclock *self, struct alarmclock_trigger *trigger, @@ -48,12 +50,15 @@ static struct rp2040_hwtimer hwtimers[] = { }; static_assert(sizeof(hwtimers)/sizeof(hwtimers[0]) == _RP2040_HWALARM_NUM); +implements_alarmclock *bootclock = &hwtimers[0]; + +/* Main implementation ********************************************************/ + implements_alarmclock *rp2040_hwtimer(enum rp2040_hwalarm_instance alarm_num) { assert(alarm_num < _RP2040_HWALARM_NUM); return &hwtimers[alarm_num]; } -/* Main implementation ********************************************************/ static uint64_t rp2040_hwtimer_get_time_ns(implements_alarmclock *) { return timer_time_us_64(timer_hw) * (NS_PER_S/US_PER_S); @@ -159,7 +164,3 @@ static void rp2040_hwtimer_del_trigger(implements_alarmclock *_alarmclock, } cr_enable_interrupts(); } - -/* Globals ********************************************************************/ - -const implements_alarmclock *bootclock = &hwtimers[0]; |