nico@207: nico@207: nico@207: CanFestival: /home/epimerde/documents/tc11/CanFestival-3/src/timer.c File Reference nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@207:

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

#include <applicfg.h>
nico@207: #include "timer.h"
nico@207: nico@207:

nico@210: Include dependency graph for timer.c:

nico@210: nico@210:

nico@207: Go to the source code of this file. nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207:

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
nico@210:


Detailed Description

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

nico@210: Definition in file timer.c.


Define Documentation

nico@207: nico@207:
nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207:
#define min_val (a,
 )    ((a<b)?a:b)
nico@207:
nico@207:
nico@207: nico@207:

nico@207: nico@207:

nico@210: Definition at line 44 of file timer.c. nico@210:

nico@210: Referenced by TimeDispatch(). nico@207:

nico@207:

nico@207:


Function Documentation

nico@207: nico@207:
nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207:
TIMER_HANDLE DelAlarm (TIMER_HANDLE  handle  ) 
nico@207:
nico@207:
nico@207: nico@207:

nico@210: ----- Use this to remove an alarm ----

nico@210:

Parameters:
nico@210: nico@210: nico@210:
handle 
nico@210:
nico@210:
Returns:
nico@210: nico@210:

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

nico@210: Definition at line 112 of file timer.c. nico@210:

nico@210: References last_timer_raw, and timers. nico@210:

nico@210: Referenced by heartbeatStop(), proceedNODE_GUARD(), ProducerHearbeatAlarm(), and stopSYNC(). nico@207:

nico@207:

nico@207: nico@207:

nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207:
TIMER_HANDLE SetAlarm (CO_Data *  d,
UNS32  id,
TimerCallback_t  callback,
TIMEVAL  value,
TIMEVAL  period 
)
nico@207:
nico@207:
nico@207: nico@207:

nico@210: ------- Use this to declare a new alarm ------

nico@210:

Parameters:
nico@210: nico@210: nico@210: nico@210: nico@210: nico@210: nico@210:
d 
id 
callback 
value 
period 
nico@210:
nico@210:
Returns:
nico@210: nico@210:

nico@210: in order to decide new timer setting we have to run over all timer rows

nico@210: if something to store

nico@210: and empty row

nico@210: just store

nico@210: if successfull

nico@210: set next wakeup alarm if new entry is sooner than others, or if it is alone

nico@210: printf("elapsed_time=%d real_timer_value=%d total_sleep_time=%d\n", elapsed_time, real_timer_value, total_sleep_time);

nico@210: printf("SetAlarm() return %d\n", row_number); nico@210:

nico@210: Definition at line 57 of file timer.c. nico@210:

nico@210: References last_timer_raw, and timers. nico@210:

nico@210: Referenced by heartbeatInit(), proceedNODE_GUARD(), and startSYNC(). nico@207:

nico@207:

nico@207: nico@207:

nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207: nico@207:
void TimeDispatch (  ) 
nico@207:
nico@207:
nico@207: nico@207:

nico@210: ------ TimeDispatch is called on each timer expiration ---- nico@210:

nico@210: used to compute when should normaly occur next wakeup

nico@210: First run : change timer state depending on time

nico@210: Get time since timer signal

nico@210: if row is active

nico@210: to be trigged

nico@210: if simply outdated

nico@210: ask for trig

nico@210: or period have expired

nico@210: set val as interval, with overrun correction

nico@210: Check if this new timer value is the soonest

nico@210: Each armed timer value in decremented.

nico@210: Check if this new timer value is the soonest

nico@210: Remember how much time we should sleep.

nico@210: Set timer to soonest occurence

nico@210: Then trig them or not.

nico@210: reset trig state (will be free if not periodic)

nico@210: trig ! nico@210:

nico@210: Definition at line 131 of file timer.c. nico@210:

nico@210: References last_timer_raw, min_val, timers, and total_sleep_time. nico@207:

nico@207:

nico@207:


Variable Documentation

nico@207: nico@207:
nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207:
TIMER_HANDLE last_timer_raw = -1
nico@207:
nico@207:
nico@207: nico@207:

nico@207: nico@207:

nico@210: Definition at line 42 of file timer.c. nico@210:

nico@210: Referenced by DelAlarm(), SetAlarm(), and TimeDispatch(). nico@207:

nico@207:

nico@207: nico@207:

nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207:
s_timer_entry timers[MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},}
nico@207:
nico@207:
nico@207: nico@207:

nico@207: nico@207:

nico@210: Definition at line 39 of file timer.c. nico@210:

nico@210: Referenced by DelAlarm(), SetAlarm(), and TimeDispatch(). nico@207:

nico@207:

nico@207: nico@207:

nico@207:
nico@207: nico@207: nico@207: nico@207: nico@207:
TIMEVAL total_sleep_time = TIMEVAL_MAX
nico@207:
nico@207:
nico@207: nico@207:

nico@207: nico@207:

nico@210: Definition at line 41 of file timer.c. nico@210:

nico@210: Referenced by TimeDispatch(). nico@210:

nico@210:

nico@210:


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