Contiki-NG
Loading...
Searching...
No Matches
Timer library

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.
 
bool timer_expired (struct timer *t)
 Check if a timer has expired.
 
clock_time_t timer_remaining (struct timer *t)
 The time until the timer expires.
 

Detailed Description

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.

Note
The timer library is not able to post events when a timer expires. The Event timers should be used for this purpose.
The timer library uses the Clock library to measure time. Intervals should be specified in the format used by the clock library.
See also
Event timers

Function Documentation

◆ timer_expired()

bool timer_expired ( struct timer * t)

Check if a timer has expired.

This function tests if a timer has expired and returns true or false depending on its status.

Parameters
tA pointer to the timer
Returns
True if the timer has expired.

Definition at line 123 of file timer.c.

References clock_time().

Referenced by platform_idle(), timer_reset(), and uip_ds6_periodic().

◆ timer_remaining()

clock_time_t timer_remaining ( struct timer * t)

The time until the timer expires.

This function returns the time until the timer expires.

Parameters
tA pointer to the timer
Returns
The time until the timer expires

Definition at line 143 of file timer.c.

References clock_time().

◆ timer_reset()

void timer_reset ( struct timer * t)

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

Parameters
tA pointer to the timer.
See also
timer_restart()

Definition at line 84 of file timer.c.

References timer_expired().

Referenced by etimer_reset(), etimer_reset_with_new_interval(), and platform_idle().

◆ timer_restart()

void timer_restart ( struct timer * t)

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.

Note
A periodic timer will drift if this function is used to reset it. For preioric timers, use the timer_reset() function instead.
Parameters
tA pointer to the timer.
See also
timer_reset()

Definition at line 106 of file timer.c.

References clock_time().

Referenced by etimer_restart().

◆ timer_set()

void timer_set ( struct timer * t,
clock_time_t interval )

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.

Parameters
tA pointer to the timer
intervalThe interval before the timer expires.

Definition at line 64 of file timer.c.

References clock_time().

Referenced by etimer_set(), platform_init_stage_three(), uip_ds6_addr_add(), and uip_ds6_dad().