An event timer is declared as a struct etimer and all access to the event timer is made by a pointer to the declared event timer.
Example:
static struct etimer periodic; EK_EVENTHANDLER(eventhandler, ev, data); EK_PROCESS(p, "Example process", EK_PRIO_NORMAL, eventhandler, NULL, NULL); LOADER_INIT_FUNC(example_init, arg) { ek_start(&p); } EK_EVENTHANDLER(eventhandler, ev, data) { if(ev == EK_EVENT_INIT) { etimer_set(&periodic, CLOCK_SECOND); } else if(ev == EK_EVENT_TIMER) { etimer_restart(&periodic); do_timed_processing(); } }
Clock library (used by the timer library)
Files | |
| file | etimer.h |
| Event timer library header file. | |
| file | etimer.c |
| Event timer library implementation. | |
Data Structures | |
| struct | etimer |
| A timer. More... | |
Functions | |
| void | etimer_set (struct etimer *t, clock_time_t interval) |
| Set an event timer. | |
| void | etimer_reset (struct etimer *t) |
| Reset an event timer with the same interval as was previously set. | |
| void | etimer_restart (struct etimer *t) |
| Restart an event timer from the current point in time. | |
| int | etimer_expired (struct etimer *t) |
| Check if an event timer has expired. | |
| int | etimer_pending (void) |
| Check if there are any non-expired event timers. | |
|
|
Check if an event timer has expired. This function tests if an event timer has expired and returns true or false depending on its status.
|
|
|
Check if there are any non-expired event timers. This function checks if there are any active event timers that have not expired.
|
|
|
Reset an event timer with the same interval as was previously set. This function resets the event timer with the same interval that was given to the event timer with the etimer_set() function. The start point of the interval is the exact time that the event timer last expired. Therefore, this function will cause the timer to be stable over time, unlike the etimer_restart() function.
|
|
|
Restart an event timer from the current point in time. This function restarts the event timer with the same interval that was given to the etimer_set() function. The event timer will start at the current time.
|
|
||||||||||||
|
Set an event timer. This function is used to set an event timer for a time sometime in the future. When the event timer expires, the event EK_EVENT_TIMER will be posted to the process that called the etimer_set() function.
|
1.3.6