Contiki-NG
Loading...
Searching...
No Matches
Callback timer

Functions

void ctimer_init (void)
 Initialize the callback timer library.
 
void ctimer_set_with_process (struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr, struct process *p)
 Set a callback timer.
 
void ctimer_reset (struct ctimer *c)
 Reset a callback timer with the same interval as was previously set.
 
void ctimer_reset_with_new_interval (struct ctimer *c, clock_time_t interval)
 Reset a callback timer with a new interval.
 
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.
 
bool ctimer_expired (struct ctimer *c)
 Check if a callback timer has expired.
 
static void ctimer_set (struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr)
 Set a callback timer.
 
static clock_time_t ctimer_expiration_time (struct ctimer *c)
 Get the expiration time for the callback timer.
 
static clock_time_t ctimer_start_time (struct ctimer *c)
 Get the start time for the callback timer.
 

Detailed Description

The ctimer module provides a timer mechanism that calls a specified C function when a ctimer expires.

It is not safe to manipulate callback timers within an interrupt context.

Function Documentation

◆ ctimer_expiration_time()

static clock_time_t ctimer_expiration_time ( struct ctimer * c)
inlinestatic

Get the expiration time for the callback timer.

Parameters
cA pointer to the callback timer
Returns
The expiration time for the callback timer.
        This function returns the expiration time for a callback timer.

Definition at line 175 of file ctimer.h.

References etimer_expiration_time().

◆ ctimer_expired()

bool ctimer_expired ( struct ctimer * c)

Check if a callback timer has expired.

Parameters
cA pointer to the callback timer
Returns
True if the timer has expired.
        This function tests if a callback timer has expired and
        returns true or false depending on its status.

Definition at line 162 of file ctimer.c.

References etimer_expired(), and list_contains().

Referenced by rpl_timers_schedule_leaving(), rpl_timers_schedule_periodic_dis(), rpl_timers_unschedule_leaving(), and sixp_trans_abort().

◆ ctimer_init()

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 86 of file ctimer.c.

References list_init(), and process_start().

◆ ctimer_reset()

void ctimer_reset ( struct ctimer * c)

Reset a callback timer with the same interval as was previously set.

Parameters
cA 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. If this is executed before the timer expired,
        this function has no effect.
See also
ctimer_restart()

Definition at line 112 of file ctimer.c.

References etimer_reset(), list_add(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.

◆ ctimer_reset_with_new_interval()

void ctimer_reset_with_new_interval ( struct ctimer * c,
clock_time_t interval )

Reset a callback timer with a new interval.

Parameters
cA pointer to the callback timer.
intervalThe interval before the timer expires.
        This function very similar to ctimer_reset(). Opposed to
        ctimer_reset() it is possible to change the timout.
        This allows accurate, non-periodic timers without drift.
See also
ctimer_reset()

Definition at line 124 of file ctimer.c.

References etimer_reset_with_new_interval(), list_add(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.

◆ ctimer_restart()

void ctimer_restart ( struct ctimer * c)

Restart a callback timer from the current point in time.

Parameters
cA 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.
See also
ctimer_reset()

Definition at line 138 of file ctimer.c.

References etimer_restart(), list_add(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.

◆ ctimer_set()

static void ctimer_set ( struct ctimer * c,
clock_time_t t,
void(*)(void *) f,
void * ptr )
inlinestatic

Set a callback timer.

Parameters
cA pointer to the callback timer.
tThe interval before the timer expires.
fA function to be called when the timer expires.
ptrAn 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.

        This essentially does ctimer_set_process(c, t, f, ptr, PROCESS_CURRENT());

Definition at line 150 of file ctimer.h.

References ctimer_set_with_process(), and PROCESS_CURRENT.

Referenced by configure(), configure(), configure(), configure(), configure(), notify_ready_cb(), rf_core_rat_init(), rpl_timers_init(), rpl_timers_schedule_dao(), rpl_timers_schedule_leaving(), rpl_timers_schedule_periodic_dis(), rpl_timers_schedule_state_update(), and rpl_timers_schedule_unicast_dio().

◆ ctimer_set_with_process()

void ctimer_set_with_process ( struct ctimer * c,
clock_time_t t,
void(*)(void *) f,
void * ptr,
struct process * p )

Set a callback timer.

Parameters
cA pointer to the callback timer.
tThe interval before the timer expires.
fA function to be called when the timer expires.
ptrAn opaque pointer that will be supplied as an argument to the callback function.
pA pointer to the process the timer belongs to
        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 93 of file ctimer.c.

References etimer_set(), list_add(), PROCESS_CONTEXT_BEGIN, and PROCESS_CONTEXT_END.

Referenced by ctimer_set().

◆ ctimer_start_time()

static clock_time_t ctimer_start_time ( struct ctimer * c)
inlinestatic

Get the start time for the callback timer.

Parameters
cA pointer to the callback timer
Returns
The start time for the callback timer.
        This function returns the start time (when the timer
        was last set) for a callback timer.

Definition at line 189 of file ctimer.h.

References etimer_start_time().

◆ ctimer_stop()

void ctimer_stop ( struct ctimer * c)

Stop a pending callback timer.

Parameters
cA 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 150 of file ctimer.c.

References etimer_stop(), and list_remove().

Referenced by configure(), configure(), configure(), configure(), configure(), rpl_timers_stop_dag_timers(), rpl_timers_unschedule_leaving(), rpl_timers_unschedule_state_update(), sixp_trans_abort(), sixp_trans_free(), and sixp_trans_init().