|Timer implementation (license: GPLv2). |
|Timer header (license: GPLv2). |
|Timer service configuration|
|typedef void(*||timer_callback )(int timer)|
|The type of callback function executed when a timer expires. |
|Global timeout handling function. |
|int||timer_alloc (timer_callback callback, uintptr_t user)|
|Allocates a timer. |
|void||timer_free (int timer)|
|Deallocates a timer. |
|bool||timer_set (int timer, uint32_t millis)|
|Starts or restarts a timer. |
|bool||timer_stop (int timer)|
|Stops the timer. |
|bool||timer_expired (int timer)|
|Checks wether a timer has expired or was stopped manually. |
|uintptr_t||timer_get_user (int timer)|
|Retrieves the user-defined data attached to a timer. |
|bool||timer_set_user (int timer, uintptr_t user)|
|Assigns user-defined data to a timer. |
Global timeout handling function.
This function must be continuously called once for every time slice. This is usually done from the application main loop. However, it should not be done from an interrupt service routine to avoid race conditions.
The accuracy of the timer service is principally dependent on the accuracy of the timer interval between calls of this function. So do your best to guarantee constant intervals.
The length of the time slice is configured with TIMER_MS_PER_TICK.
Allocates a timer.
The given callback function is executed whenever the timer expires. The user value is attached to the timer and given as an extra argument to the callback function. It is not used by the timer module in any way.
|[in]||callback||The function to execute whenever the timer expires.|
|[in]||user||The user-defined value.|
Deallocates a timer.
The timer being deallocated is stopped and marked as free.
|[in]||timer||The identifier of the timer which to deallocate.|
Starts or restarts a timer.
The timer expires after millis milliseconds.
|[in]||timer||The identifier of the timer which to start.|
|[in]||millis||The number of milliseconds after which the timer will expire.|
trueif the timer has successfully been started,
Stops the timer.
|[in]||timer||The identifier of the timer which to stop.|
trueif the timer has been stopped,
Checks wether a timer has expired or was stopped manually.
|[in]||timer||The identifier of the timer which to check.|
trueif the timer is not running,
Retrieves the user-defined data attached to a timer.
|[in]||timer||The identifier of the timer of which to retrieve the data.|
Assigns user-defined data to a timer.
|[in]||timer||The identifier of the timer which to assign the data to.|
|[in]||user||The data which to assign to the timer.|