Alarm callback functions are invoked on the interrupt level whenever the associated alarm expires. The programming model for callback functions is similar to that of interrupt service routines.
This function must not be invoked with interrupts disabled, i.e. from an interrupt handler (or generally, from the ISR level) or a critical section of the application.
This function can be used to set single shot, as well as repeating timers. The function uses the malloc-function. Therefore setting too many alarms in parallel may cause unexpected behavior.
Parameters:
callback
callback function that will be invoked whenever the alarm expires
alarmtime
time in ms relative to the current time when the alarm shall expire the first time. If set to 0 cycle time will be used.
cycle
time in ms for alarms that periodically expire after the first regular expiry. Set to 0 for single shot timers.
Returns:
the identifier of the alarm, or NULL if creating the alarm failed.
Note:
Canceling a timer twice or canceling a single shot timer after its expiry may cause unexpected results.