The ctimer module provides a timer mechanism that calls a specified C function when a ctimer expires.
Data Structures | |
struct | ctimer |
Files | |
file | ctimer.c |
Callback timer implementation | |
file | ctimer.h |
Header file for the callback timer | |
Macros | |
#define | _DEBUG_ 0 |
#define | PRINTF(...) |
Functions | |
int | ctimer_expired (struct ctimer *c) |
Check if a callback timer has expired. More... | |
void | ctimer_init (void) |
Initialize the callback timer library. More... | |
void | ctimer_reset (struct ctimer *c) |
Reset a callback timer with the same interval as was previously set. More... | |
void | ctimer_restart (struct ctimer *c) |
Restart a callback timer from the current point in time. More... | |
void | ctimer_set (struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr) |
Set a callback timer. More... | |
void | ctimer_stop (struct ctimer *c) |
Stop a pending callback timer. More... | |
LIST (ctimer_list) | |
PROCESS (ctimer_process,"Ctimer process") | |
PROCESS_THREAD (ctimer_process, ev, data) | |
Variables | |
static char | initialized |
#define _DEBUG_ 0 |
#define PRINTF | ( | ... | ) |
Referenced by ctimer_set().
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.
References etimer, etimer_expired(), initialized, list_head(), next, 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.
References initialized, 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. |
References etimer, etimer_reset(), initialized, list_add(), list_remove(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.
Referenced by handle_periodic_timer().
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. \note A periodic timer will drift if this function is used to reset it. For periodic timers, use the ctimer_reset() function instead. |
References etimer, etimer_restart(), initialized, 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. |
References etimer, etimer_set(), f, initialized, timer::interval, list_add(), list_remove(), p, PRINTF, PROCESS_CONTEXT_BEGIN, PROCESS_CONTEXT_END, PROCESS_CURRENT, ptr, ptr, and etimer::timer.
Referenced by create_dag_callback(), double_interval(), free_packet(), handle_dao_timer(), handle_dio_timer(), input_packet(), new_dio_interval(), new_interval(), packet_sent(), packetqueue_enqueue_packetbuf(), phase_wait(), route_callback(), rpl_reset_periodic_timer(), schedule_dao(), schedule_for_end(), send_packet(), set_dao_lifetime_timer(), simple_rpl_init_dag(), and uip_packetqueue_alloc().
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. |
References etimer, etimer_stop(), initialized, list_remove(), etimer::next, NULL, etimer::p, and PROCESS_NONE.
Referenced by free_packet(), handle_dao_timer(), input_packet(), packetqueue_dequeue(), remove_queued_packet(), rpl_cancel_dao(), rpl_free_instance(), and uip_packetqueue_free().
LIST | ( | ctimer_list | ) |
PROCESS | ( | ctimer_process | , |
"Ctimer process" | |||
) |
PROCESS_THREAD | ( | ctimer_process | , |
ev | , | ||
data | |||
) |
References c, data, etimer, etimer_set(), f, initialized, timer::interval, list_head(), list_remove(), next, NULL, p, PROCESS_BEGIN, PROCESS_CONTEXT_BEGIN, PROCESS_CONTEXT_END, PROCESS_END, PROCESS_EVENT_TIMER, PROCESS_YIELD_UNTIL, ptr, and etimer::timer.
|
static |
Referenced by ctimer_expired(), ctimer_init(), ctimer_reset(), ctimer_restart(), ctimer_set(), ctimer_stop(), PROCESS_THREAD(), and send_packet().