OpenWSN Firmware
OpenTimers

Data Structures

struct  opentimers_t
 
struct  opentimers_vars_t
 

Macros

#define MAX_NUM_TIMERS   10
 Maximum number of timers that can run concurrently. More...
 
#define MAX_TICKS_IN_SINGLE_CLOCK   ((PORT_TIMER_WIDTH)0xFFFFFFFF)
 
#define TOO_MANY_TIMERS_ERROR   255
 
#define opentimer_id_t   uint8_t
 

Typedefs

typedef void(* opentimers_cbt )(void)
 

Enumerations

enum  timer_type_t { TIMER_PERIODIC, TIMER_ONESHOT }
 
enum  time_type_t { TIME_MS, TIME_TICS }
 

Functions

void opentimers_init (void)
 Initialize this module. More...
 
opentimer_id_t opentimers_start (uint32_t duration, timer_type_t type, time_type_t timetype, opentimers_cbt callback)
 Start a timer. More...
 
void opentimers_setPeriod (opentimer_id_t id, time_type_t timetype, uint32_t newPeriod)
 Replace the period of a running timer. More...
 
void opentimers_stop (opentimer_id_t id)
 Stop a running timer. More...
 
void opentimers_restart (opentimer_id_t id)
 Restart a stop timer. More...
 
void opentimers_sleepTimeCompesation (uint16_t sleepTime)
 

Detailed Description

Macro Definition Documentation

#define MAX_NUM_TIMERS   10

Maximum number of timers that can run concurrently.

#define MAX_TICKS_IN_SINGLE_CLOCK   ((PORT_TIMER_WIDTH)0xFFFFFFFF)
#define opentimer_id_t   uint8_t
#define TOO_MANY_TIMERS_ERROR   255

Typedef Documentation

typedef void(* opentimers_cbt)(void)

Enumeration Type Documentation

Enumerator
TIME_MS 
TIME_TICS 
Enumerator
TIMER_PERIODIC 
TIMER_ONESHOT 

Function Documentation

void opentimers_init ( void  )

Initialize this module.

Initializes data structures and hardware timer.

void opentimers_restart ( opentimer_id_t  id)

Restart a stop timer.

Sets the timer to " running".

void opentimers_setPeriod ( opentimer_id_t  id,
time_type_t  timetype,
uint32_t  newPeriod 
)

Replace the period of a running timer.

void opentimers_sleepTimeCompesation ( uint16_t  sleepTime)
opentimer_id_t opentimers_start ( uint32_t  duration,
timer_type_t  type,
time_type_t  timetype,
opentimers_cbt  callback 
)

Start a timer.

The timer works as follows:

  • currentTimeout is the number of ticks before the next timer expires.
  • if a new timer is inserted, we check that it is not earlier than the soonest
  • if it is earliest, replace it
  • if not, insert it in the list
Parameters
durationNumber milli-seconds after which the timer will fire.
typeType of timer:
timetypeUnits of the duration:
callbackThe function to call when the timer fires.
Returns
The id of the timer (which serves as a handler to stop it) if the timer could be started.
TOO_MANY_TIMERS_ERROR if the timer could NOT be started.
void opentimers_stop ( opentimer_id_t  id)

Stop a running timer.

Sets the timer to "not running". the system recovers even if this was the next timer to expire.