nico@207: nico@207:
nico@207:#include <applicfg.h>
#include "timer.h"
nico@210: Include dependency graph for timer.c:
nico@207: 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 |
nico@210: Definition in file timer.c.
#define min_val | nico@207:( | nico@207:a, | |||
nico@207: | nico@207: | b | nico@207:nico@207: | ) | nico@207:((a<b)?a:b) | 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:
TIMER_HANDLE DelAlarm | nico@207:( | nico@207:TIMER_HANDLE | nico@207:handle | nico@207:) | nico@207:nico@207: |
nico@210: ----- Use this to remove an alarm ----
nico@210:
handle |
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:
TIMER_HANDLE SetAlarm | nico@207:( | nico@207:CO_Data * | nico@207:d, | nico@207:|
nico@207: | nico@207: | UNS32 | nico@207:id, | nico@207:|
nico@207: | nico@207: | TimerCallback_t | nico@207:callback, | nico@207:|
nico@207: | nico@207: | TIMEVAL | nico@207:value, | nico@207:|
nico@207: | nico@207: | TIMEVAL | nico@207:period | nico@207: |
nico@207: | ) | nico@207:nico@207: |
nico@210: ------- Use this to declare a new alarm ------
nico@210:
d | ||
id | ||
callback | ||
value | ||
period |
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:
void TimeDispatch | nico@207:( | 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:
TIMER_HANDLE last_timer_raw = -1 | 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:
s_timer_entry timers[MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},} | 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:
TIMEVAL total_sleep_time = TIMEVAL_MAX | 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: