Name

timer_setcb — Sets callback to be invoked

Synopsis

#include <timer.h>   
void timer_setcb (timer,  
 cb); 
timer_t * timer;
event_xhandle_t cb;
 

Arguments

timer

pointer to the timer object.

cb

callback function to be invoked when the timer expires.

Description

Sets the callback to be invoked when a timer expires. To remove a previous callback set on the timer, set cb to NULL.

It is the caller's responsibility to ensure that the timer structure is not de-allocated as long as the callback is registered. It is generally better to make the timer structure instance a global or a static local.

The callback accepts a pointer to a timer (the timer for which the callback was registered) as argument and does not return values. An example callback is shown below.

Example


   void timer_callback(timer_t *tmr)
   {
   ...
   ...
   }
   ...
   timer_setcb(timer, timer_callback);