Contiki 2.6
|
The ctimer module provides a timer mechanism that calls a specified C function when a ctimer expires. More...
Files | |
file | ctimer.c |
Callback timer implementation. | |
file | ctimer.h |
Header file for the callback timer. | |
Functions | |
void | ctimer_init (void) |
Initialize the callback timer library. | |
void | ctimer_set (struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr) |
Set a callback timer. | |
void | ctimer_reset (struct ctimer *c) |
Reset a callback timer with the same interval as was previously set. | |
void | ctimer_restart (struct ctimer *c) |
Restart a callback timer from the current point in time. | |
void | ctimer_stop (struct ctimer *c) |
Stop a pending callback timer. | |
int | ctimer_expired (struct ctimer *c) |
Check if a callback timer has expired. |
The ctimer module provides a timer mechanism that calls a specified C function when a ctimer expires.
int ctimer_expired | ( | struct ctimer * | c | ) |
Check if a callback timer has expired.
c | A pointer to the callback timer |
This function tests if a callback timer has expired and returns true or false depending on its status.
Definition at line 158 of file ctimer.c.
References etimer_expired(), list_head(), and NULL.
void ctimer_init | ( | void | ) |
Initialize the callback timer library.
This function initializes the callback timer library and should be called from the system boot up code.
Definition at line 92 of file ctimer.c.
References list_init(), NULL, and process_start().
Referenced by main().
void ctimer_reset | ( | struct ctimer * | c | ) |
Reset a callback timer with the same interval as was previously set.
c | A pointer to the callback timer. |
This function resets the callback timer with the same interval that was given to the callback timer with the ctimer_set() function. The start point of the interval is the exact time that the callback timer last expired. Therefore, this function will cause the timer to be stable over time, unlike the ctimer_restart() function.
Definition at line 120 of file ctimer.c.
References etimer_reset(), list_add(), list_remove(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.
void ctimer_restart | ( | struct ctimer * | c | ) |
Restart a callback timer from the current point in time.
c | A pointer to the callback timer. |
This function restarts the callback timer with the same interval that was given to the ctimer_set() function. The callback timer will start at the current time.
Definition at line 133 of file ctimer.c.
References etimer_restart(), list_add(), list_remove(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.
void ctimer_set | ( | struct ctimer * | c, |
clock_time_t | t, | ||
void(*)(void *) | f, | ||
void * | ptr | ||
) |
Set a callback timer.
c | A pointer to the callback timer. |
t | The interval before the timer expires. |
f | A function to be called when the timer expires. |
ptr | An opaque pointer that will be supplied as an argument to the callback function. |
This function is used to set a callback timer for a time sometime in the future. When the callback timer expires, the callback function f will be called with ptr as argument.
Definition at line 100 of file ctimer.c.
References etimer_set(), list_add(), list_remove(), PROCESS_CONTEXT_BEGIN, PROCESS_CONTEXT_END, and PROCESS_CURRENT.
Referenced by ipolite_send(), packetqueue_enqueue_packetbuf(), polite_send(), and stbroadcast_set_timer().
void ctimer_stop | ( | struct ctimer * | c | ) |
Stop a pending callback timer.
c | A pointer to the pending callback timer. |
This function stops a callback timer that has previously been set with ctimer_set(), ctimer_reset(), or ctimer_restart(). After this function has been called, the callback timer will be expired and will not call the callback function.
Definition at line 146 of file ctimer.c.
References etimer_stop(), list_remove(), and NULL.
Referenced by ipolite_cancel(), ipolite_close(), packetqueue_dequeue(), polite_cancel(), polite_close(), and stbroadcast_cancel().