Timer functions
[IO Utility Library libio_<board>.a]


Detailed Description

Starting, stopping and execution of time triggered actions.

This group of functions provides a one shot timer implemenation.

It is inspired by Jörg Wunschs timer implementation, which can be found here: http://sax.sax.de/~joerg/avr-timer/


Data Structures

struct  time_stamp_tag

Defines

#define MSEC(v)   ((time_t)(v / (1.0e3 * TIMER_TICK)))
#define USEC(v)   ((time_t)(v / (1.0e6 * TIMER_TICK)))

Typedefs

typedef struct time_stamp_tag time_stamp_t
typedef uint32_t time_t
typedef uint32_t timer_arg_t
typedef time_ttimer_handler_t )(timer_arg_t p)
typedef uint16_t timer_hdl_t

Functions

void timer_init (void)
 Initialization of the timer module.
timer_hdl_t timer_restart (timer_hdl_t th, time_t duration)
 Restarting a running timer.
void timer_set_systime (time_t sec)
 Set the current system time given in seconds since 1.1.1970.
timer_hdl_t timer_start (timer_handler_t *thfunc, time_t duration, timer_arg_t arg)
 Start a timer with a given handler function.
timer_hdl_t timer_stop (timer_hdl_t th)
 Stop a running timer.
time_t timer_systime (void)
 Return the current system time in ticks.


Define Documentation

#define MSEC (  )     ((time_t)(v / (1.0e3 * TIMER_TICK)))

Macro that converts the millisecond value v into TIMER_IRQ_vect ticts

Definition at line 47 of file timer.h.

#define USEC (  )     ((time_t)(v / (1.0e6 * TIMER_TICK)))

Macro that converts the microsecond value v into TIMER_IRQ_vect ticts

Definition at line 49 of file timer.h.


Typedef Documentation

typedef uint32_t time_t

Data type for time values (measured in number of system ticks).

Definition at line 65 of file timer.h.

typedef uint32_t timer_arg_t

Data type for the argument of a timer handler function.

Definition at line 83 of file timer.h.

Data type for timer expiration action function. This function is called, when the expiration time is over. When luanched, the function is called with a parameter p of type .timer_arg_t. If the function returns a value, which is greate then 0, the timer is restarted again.

Definition at line 101 of file timer.h.

typedef uint16_t timer_hdl_t

Data type for a timer handle (a reference number to identify a running timer).

Definition at line 90 of file timer.h.


Function Documentation

void timer_init ( void   ) 

Initialization of the timer module.

timer_hdl_t timer_restart ( timer_hdl_t  th,
time_t  duration 
)

Restarting a running timer.

If the timer is found in the timer queue, then it is rstarted with the new duration value.

Parameters:
th Handle of the timer. The timer needs to exist in the timer queue, e.g. it is started with timer_start() and not yet expired.
duration time in system ticks from now, when the timer expires.
Returns:
the value of NONE_TIMER if the timer could not be found in the timer queue. Otherwise the value of th.

void timer_set_systime ( time_t  sec  ) 

Set the current system time given in seconds since 1.1.1970.

timer_hdl_t timer_start ( timer_handler_t thfunc,
time_t  duration,
timer_arg_t  arg 
)

Start a timer with a given handler function.

This function initially creates a timer and assigns a timer handle to it. The timer handle is reference number, which identifies the timer uniquely and is needed for restart and stop a running timer.

Parameters:
thfunc pointer to a function, which is called when the timer expires.
duration time in system ticks from now, when the timer expires.
arg argument, which is passed to the timer function.
Returns:
the value of NONE_TIMER if the timer could not be started. Otherwise a handle != NONE_TIMER, which is needed for restarting and stopping the timer.

timer_hdl_t timer_stop ( timer_hdl_t  th  ) 

Stop a running timer.

Parameters:
th Handle of the timer. The timer needs to exist in the timer queue, e.g. it is started with timer_start() and not yet expired.
Returns:
the value of NONE_TIMER if the timer could not be found in the timer queue. Otherwise the value of th.

time_t timer_systime ( void   ) 

Return the current system time in ticks.


This documentation for µracoli was generated on 21 Jan 2010 by  doxygen 1.5.5