The current time is held as a 32 bit value in the ctl_current_time variable. This variable is incremented by a periodic interrupt that is started using the ctl_start_timer function. When you start the timer you must pass it a function to call when the periodic interrupt occurs. The interrupt function can be a user defined function that calls ctl_increment_tick_from_isr.
void myfn{void) { ... ctl_increment_tick_from_isr(); ... } void main(...) .. ctl_start_timer(myfn); ..
Alternatively you can pass the ctl_increment_tick_from_isr function as the parameter
void main(...) { .. ctl_start_timer(ctl_increment_tick_from_isr); ..
You can atomically read ctl_current_time using the ctl_get_current_time function on systems whose word size is not 32 bit.
You can find out the resolution of the timer using the ctl_get_ticks_per_second function.
You can suspend execution of a task for a fixed period using the ctl_timeout_wait function.
Note that this function takes the timeout not the duration as a parameter, so you should always call this function with ctl_get_current_time()+duration.
ctl_timeout_wait(ctl_get_current_time()+100);
This example suspends execution of the calling task for 100 increments of the ctl_current_time variable.