/home/epimerde/documents/tc11/CanFestival-3/src/timer.c File Reference

#include <applicfg.h>
#include "timer.h"

Include dependency graph for timer.c:

Go to the source code of this file.

Defines

#define min_val(a, b)   ((a<b)?a:b)

Functions

TIMER_HANDLE SetAlarm (CO_Data *d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)
TIMER_HANDLE DelAlarm (TIMER_HANDLE handle)
void TimeDispatch ()

Variables

s_timer_entry timers [MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},}
TIMEVAL total_sleep_time = TIMEVAL_MAX
TIMER_HANDLE last_timer_raw = -1


Detailed Description

Author:
Edouard TISSERANT and Francis DUPIN
Date:
Tue Jun 5 09:32:32 2007

Definition in file timer.c.


Define Documentation

#define min_val ( a,
 )     ((a<b)?a:b)

Definition at line 44 of file timer.c.

Referenced by TimeDispatch().


Function Documentation

TIMER_HANDLE DelAlarm ( TIMER_HANDLE  handle  ) 

----- Use this to remove an alarm ----

Parameters:
handle 
Returns:

Quick and dirty. system timer will continue to be trigged, but no action will be preformed.

Definition at line 112 of file timer.c.

References last_timer_raw, and timers.

Referenced by heartbeatStop(), proceedNODE_GUARD(), ProducerHearbeatAlarm(), and stopSYNC().

TIMER_HANDLE SetAlarm ( CO_Data *  d,
UNS32  id,
TimerCallback_t  callback,
TIMEVAL  value,
TIMEVAL  period 
)

------- Use this to declare a new alarm ------

Parameters:
d 
id 
callback 
value 
period 
Returns:

in order to decide new timer setting we have to run over all timer rows

if something to store

and empty row

just store

if successfull

set next wakeup alarm if new entry is sooner than others, or if it is alone

printf("elapsed_time=%d real_timer_value=%d total_sleep_time=%d\n", elapsed_time, real_timer_value, total_sleep_time);

printf("SetAlarm() return %d\n", row_number);

Definition at line 57 of file timer.c.

References last_timer_raw, and timers.

Referenced by heartbeatInit(), proceedNODE_GUARD(), and startSYNC().

void TimeDispatch (  ) 

------ TimeDispatch is called on each timer expiration ----

used to compute when should normaly occur next wakeup

First run : change timer state depending on time

Get time since timer signal

if row is active

to be trigged

if simply outdated

ask for trig

or period have expired

set val as interval, with overrun correction

Check if this new timer value is the soonest

Each armed timer value in decremented.

Check if this new timer value is the soonest

Remember how much time we should sleep.

Set timer to soonest occurence

Then trig them or not.

reset trig state (will be free if not periodic)

trig !

Definition at line 131 of file timer.c.

References last_timer_raw, min_val, timers, and total_sleep_time.


Variable Documentation

TIMER_HANDLE last_timer_raw = -1

Definition at line 42 of file timer.c.

Referenced by DelAlarm(), SetAlarm(), and TimeDispatch().

s_timer_entry timers[MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},}

Definition at line 39 of file timer.c.

Referenced by DelAlarm(), SetAlarm(), and TimeDispatch().

TIMEVAL total_sleep_time = TIMEVAL_MAX

Definition at line 41 of file timer.c.

Referenced by TimeDispatch().


Generated on Tue Jun 5 18:32:11 2007 for CanFestival by  doxygen 1.5.1