25#define GRTC_IRQ_PRIORITY 6
27static nrfx_grtc_channel_t rtimer_channel;
28static bool rtimer_channel_active;
31rtimer_grtc_handler(int32_t
id, uint64_t cc_value,
void *context)
41ensure_grtc_started(
void)
43 if(!nrfx_grtc_init_check()) {
44 nrfx_err_t err = nrfx_grtc_init(GRTC_IRQ_PRIORITY);
45 if(err != NRFX_SUCCESS && err != NRFX_ERROR_ALREADY) {
54 ensure_grtc_started();
56 if(rtimer_channel_active) {
61 if(nrfx_grtc_channel_alloc(&channel) != NRFX_SUCCESS) {
65 rtimer_channel.channel = channel;
66 rtimer_channel.handler = rtimer_grtc_handler;
67 rtimer_channel.p_context = NULL;
69 rtimer_channel_active =
true;
76 nrfx_grtc_syscounter_get(&counter);
77 return (rtimer_clock_t)counter;
83 if(!rtimer_channel_active) {
87 uint64_t target = (uint64_t)t;
89 nrfx_grtc_syscounter_get(&now);
91 if((int64_t)(target - now) <= 0) {
96 nrfx_grtc_syscounter_cc_absolute_set(&rtimer_channel, target,
true);
void rtimer_arch_init(void)
We don't need to explicitly initialise anything but this routine is required by the API.
rtimer_clock_t rtimer_arch_now()
Returns the current real-time clock time.
void rtimer_arch_schedule(rtimer_clock_t t)
Schedules an rtimer task to be triggered at time t.
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.
Header file for the real-time timer module.