The timer library provides functions for setting, resetting and restarting timers, and for checking if a timer has expired. An application must "manually" check if its timers have expired; this is not done automatically.
A timer is declared as a struct timer and all access to the timer is made by a pointer to the declared timer.
Example:
static struct timer periodic; LOADER_INIT_FUNC(example_init, arg) { timer_set(&periodic, CLOCK_SECOND); } EK_POLLHANDLER(pollhandler) { if(timer_expired(&periodic)) { timer_restart(&periodic); do_periodic_stuff(); } }
Files | |
| file | timer.h |
| Timer library header file. | |
| file | timer.c |
| Timer library implementation. | |
Data Structures | |
| struct | timer |
| A timer. More... | |
Functions | |
| void | timer_set (struct timer *t, clock_time_t interval) |
| Set a timer. | |
| void | timer_reset (struct timer *t) |
| Reset the timer with the same interval. | |
| void | timer_restart (struct timer *t) |
| Restart the timer from the current point in time. | |
| int | timer_expired (struct timer *t) |
| Check if a timer has expired. | |
|
|
Check if a timer has expired. This function tests if a timer has expired and returns true or false depending on its status.
|
|
|
Reset the timer with the same interval. This function resets the timer with the same interval that was given to the timer_set() function. The start point of the interval is the exact time that the timer last expired. Therefore, this function will cause the timer to be stable over time, unlike the timer_rester() function.
|
|
|
Restart the timer from the current point in time. This function restarts a timer with the same interval that was given to the timer_set() function. The timer will start at the current time.
|
|
||||||||||||
|
Set a timer. This function is used to set a timer for a time sometime in the future. The function timer_expired() will evaluate to true after the timer has expired.
|
1.3.6