CTL with extended sleep modes
Since CTL is dependent on the SYSTICK timer like any common RTOS, it presents challenges in deep sleep modes that stop the core. What you really need to know is the next timeout event. If this was known, a real-time clock could be configured to wake the device at that time, load an accurate ctl_current_time, and proceed as normal.
Is there a way to discern the "next timeout event time" supported in the CTL library? I'm also open to other solutions.
-
Something like this should do it
CTL_TIME_t
ctl_next_wakeup_time()
{
CTL_TIME_t wakeup = -1;
int en = ctl_global_interrupts_disable();
CTL_TASK_t *t = ctl_task_list;
while (t)
if (t->state & CTL_STATE_TIMER_WAIT)
if (t->timeout < wakeup)
wakeup = t->timeout;
if (en)
ctl_global_interrupts_enable();
return wakeup;
}
Please sign in to leave a comment.
Comments
1 comment