The timer is intended to provide simple delay and timing functionality. Tasks are submitted to the timer together with the desired delay, after which the task will be executed.
The timer is set up by the
timer_init() function. This function will map a hardware Timer module to the timer struct, and initialize the Timer to give the desired resolution.
Before use, the timer tasks are set up with the
timer_init_task() function. When the task has been set up, it can be added to the timer by either the
timer_add_task_ticks() function or the convenience wrapper
timer_add_task_us(). When the given delay has passed, the tasks callback function will be called by the timer.
When the task has started execution (ie. its callback has been called), the task struct can be re-used and added to the timer again. If the callback or data should be changed, the task should be reinitialized by calling
timer_init_task() again. If only the delay is to change, the task can be re-used as soon as its callback is called.