207
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
2 |
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
3 |
<title>CanFestival: /home/epimerde/documents/tc11/CanFestival-3/src/timer.c File Reference</title>
|
|
4 |
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
5 |
<link href="tabs.css" rel="stylesheet" type="text/css">
|
|
6 |
</head><body>
|
|
7 |
<!-- Generated by Doxygen 1.5.1 -->
|
|
8 |
<div class="tabs">
|
|
9 |
<ul>
|
|
10 |
<li><a href="main.html"><span>Main Page</span></a></li>
|
|
11 |
<li id="current"><a href="files.html"><span>Files</span></a></li>
|
|
12 |
</ul></div>
|
|
13 |
<div class="tabs">
|
|
14 |
<ul>
|
|
15 |
<li><a href="files.html"><span>File List</span></a></li>
|
|
16 |
<li><a href="globals.html"><span>Globals</span></a></li>
|
|
17 |
</ul></div>
|
|
18 |
<h1>/home/epimerde/documents/tc11/CanFestival-3/src/timer.c File Reference</h1><code>#include <applicfg.h></code><br>
|
|
19 |
<code>#include "timer.h"</code><br>
|
|
20 |
|
|
21 |
<p>
|
210
|
22 |
Include dependency graph for timer.c:<p><center><img src="timer_8c__incl.png" border="0" usemap="#/home/epimerde/documents/tc11/CanFestival-3/src/timer.c_map" alt=""></center>
|
|
23 |
|
|
24 |
<p>
|
207
|
25 |
<a href="timer_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
|
|
26 |
<tr><td></td></tr>
|
|
27 |
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
|
|
28 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#8536312cebeeea3a23dc0027800122c9">min_val</a>(a, b) ((a<b)?a:b)</td></tr>
|
|
29 |
|
|
30 |
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
|
|
31 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">TIMER_HANDLE </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#11c2616d78f06ed9144ef662f757b128">SetAlarm</a> (CO_Data *d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)</td></tr>
|
|
32 |
|
|
33 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">TIMER_HANDLE </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#991b3cfaac2f201b14d5530f75985c21">DelAlarm</a> (TIMER_HANDLE handle)</td></tr>
|
|
34 |
|
|
35 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#fa75192a3238525618f8cb83004930cc">TimeDispatch</a> ()</td></tr>
|
|
36 |
|
|
37 |
<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
|
|
38 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">s_timer_entry </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#a74e2cf2504bfd18b12f112c7aaad845">timers</a> [MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},}</td></tr>
|
|
39 |
|
|
40 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">TIMEVAL </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#5e9651eed13d70bcce9bdf3489a72a3d">total_sleep_time</a> = TIMEVAL_MAX</td></tr>
|
|
41 |
|
|
42 |
<tr><td class="memItemLeft" nowrap align="right" valign="top">TIMER_HANDLE </td><td class="memItemRight" valign="bottom"><a class="el" href="timer_8c.html#1dab7b9a29bdee8b1931f8ea90685c6f">last_timer_raw</a> = -1</td></tr>
|
|
43 |
|
|
44 |
</table>
|
210
|
45 |
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
|
46 |
<dl class="author" compact><dt><b>Author:</b></dt><dd>Edouard TISSERANT and Francis DUPIN </dd></dl>
|
|
47 |
<dl class="date" compact><dt><b>Date:</b></dt><dd>Tue Jun 5 09:32:32 2007 </dd></dl>
|
|
48 |
|
|
49 |
<p>
|
|
50 |
Definition in file <a class="el" href="timer_8c-source.html">timer.c</a>.<hr><h2>Define Documentation</h2>
|
207
|
51 |
<a class="anchor" name="8536312cebeeea3a23dc0027800122c9"></a><!-- doxytag: member="timer.c::min_val" ref="8536312cebeeea3a23dc0027800122c9" args="(a, b)" -->
|
|
52 |
<div class="memitem">
|
|
53 |
<div class="memproto">
|
|
54 |
<table class="memname">
|
|
55 |
<tr>
|
|
56 |
<td class="memname">#define min_val </td>
|
|
57 |
<td>(</td>
|
|
58 |
<td class="paramtype">a, <tr>
|
|
59 |
<td class="paramkey"></td>
|
|
60 |
<td></td>
|
|
61 |
<td class="paramtype">b </td>
|
|
62 |
<td class="paramname"> </td>
|
|
63 |
<td> ) </td>
|
|
64 |
<td width="100%"> ((a<b)?a:b)</td>
|
|
65 |
</tr>
|
|
66 |
</table>
|
|
67 |
</div>
|
|
68 |
<div class="memdoc">
|
|
69 |
|
|
70 |
<p>
|
|
71 |
|
|
72 |
<p>
|
210
|
73 |
Definition at line <a class="el" href="timer_8c-source.html#l00044">44</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
74 |
<p>
|
|
75 |
Referenced by <a class="el" href="timer_8c-source.html#l00131">TimeDispatch()</a>.
|
207
|
76 |
</div>
|
|
77 |
</div><p>
|
|
78 |
<hr><h2>Function Documentation</h2>
|
|
79 |
<a class="anchor" name="991b3cfaac2f201b14d5530f75985c21"></a><!-- doxytag: member="timer.c::DelAlarm" ref="991b3cfaac2f201b14d5530f75985c21" args="(TIMER_HANDLE handle)" -->
|
|
80 |
<div class="memitem">
|
|
81 |
<div class="memproto">
|
|
82 |
<table class="memname">
|
|
83 |
<tr>
|
|
84 |
<td class="memname">TIMER_HANDLE DelAlarm </td>
|
|
85 |
<td>(</td>
|
|
86 |
<td class="paramtype">TIMER_HANDLE </td>
|
|
87 |
<td class="paramname"> <em>handle</em> </td>
|
|
88 |
<td> ) </td>
|
|
89 |
<td width="100%"></td>
|
|
90 |
</tr>
|
|
91 |
</table>
|
|
92 |
</div>
|
|
93 |
<div class="memdoc">
|
|
94 |
|
|
95 |
<p>
|
210
|
96 |
----- Use this to remove an alarm ----<p>
|
|
97 |
<dl compact><dt><b>Parameters:</b></dt><dd>
|
|
98 |
<table border="0" cellspacing="2" cellpadding="0">
|
|
99 |
<tr><td valign="top"></td><td valign="top"><em>handle</em> </td><td></td></tr>
|
|
100 |
</table>
|
|
101 |
</dl>
|
|
102 |
<dl class="return" compact><dt><b>Returns:</b></dt><dd></dd></dl>
|
|
103 |
|
|
104 |
<p>
|
|
105 |
Quick and dirty. system timer will continue to be trigged, but no action will be preformed.
|
|
106 |
<p>
|
|
107 |
Definition at line <a class="el" href="timer_8c-source.html#l00112">112</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
108 |
<p>
|
|
109 |
References <a class="el" href="timer_8c-source.html#l00042">last_timer_raw</a>, and <a class="el" href="timer_8c-source.html#l00039">timers</a>.
|
|
110 |
<p>
|
|
111 |
Referenced by <a class="el" href="lifegrd_8c-source.html#l00236">heartbeatStop()</a>, <a class="el" href="lifegrd_8c-source.html#l00081">proceedNODE_GUARD()</a>, <a class="el" href="lifegrd_8c-source.html#l00161">ProducerHearbeatAlarm()</a>, and <a class="el" href="sync_8c-source.html#l00105">stopSYNC()</a>.
|
207
|
112 |
</div>
|
|
113 |
</div><p>
|
|
114 |
<a class="anchor" name="11c2616d78f06ed9144ef662f757b128"></a><!-- doxytag: member="timer.c::SetAlarm" ref="11c2616d78f06ed9144ef662f757b128" args="(CO_Data *d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)" -->
|
|
115 |
<div class="memitem">
|
|
116 |
<div class="memproto">
|
|
117 |
<table class="memname">
|
|
118 |
<tr>
|
|
119 |
<td class="memname">TIMER_HANDLE SetAlarm </td>
|
|
120 |
<td>(</td>
|
|
121 |
<td class="paramtype">CO_Data * </td>
|
|
122 |
<td class="paramname"> <em>d</em>, </td>
|
|
123 |
</tr>
|
|
124 |
<tr>
|
|
125 |
<td class="paramkey"></td>
|
|
126 |
<td></td>
|
|
127 |
<td class="paramtype">UNS32 </td>
|
|
128 |
<td class="paramname"> <em>id</em>, </td>
|
|
129 |
</tr>
|
|
130 |
<tr>
|
|
131 |
<td class="paramkey"></td>
|
|
132 |
<td></td>
|
|
133 |
<td class="paramtype">TimerCallback_t </td>
|
|
134 |
<td class="paramname"> <em>callback</em>, </td>
|
|
135 |
</tr>
|
|
136 |
<tr>
|
|
137 |
<td class="paramkey"></td>
|
|
138 |
<td></td>
|
|
139 |
<td class="paramtype">TIMEVAL </td>
|
|
140 |
<td class="paramname"> <em>value</em>, </td>
|
|
141 |
</tr>
|
|
142 |
<tr>
|
|
143 |
<td class="paramkey"></td>
|
|
144 |
<td></td>
|
|
145 |
<td class="paramtype">TIMEVAL </td>
|
|
146 |
<td class="paramname"> <em>period</em></td><td> </td>
|
|
147 |
</tr>
|
|
148 |
<tr>
|
|
149 |
<td></td>
|
|
150 |
<td>)</td>
|
|
151 |
<td></td><td></td><td width="100%"></td>
|
|
152 |
</tr>
|
|
153 |
</table>
|
|
154 |
</div>
|
|
155 |
<div class="memdoc">
|
|
156 |
|
|
157 |
<p>
|
210
|
158 |
------- Use this to declare a new alarm ------<p>
|
|
159 |
<dl compact><dt><b>Parameters:</b></dt><dd>
|
|
160 |
<table border="0" cellspacing="2" cellpadding="0">
|
|
161 |
<tr><td valign="top"></td><td valign="top"><em>d</em> </td><td></td></tr>
|
|
162 |
<tr><td valign="top"></td><td valign="top"><em>id</em> </td><td></td></tr>
|
|
163 |
<tr><td valign="top"></td><td valign="top"><em>callback</em> </td><td></td></tr>
|
|
164 |
<tr><td valign="top"></td><td valign="top"><em>value</em> </td><td></td></tr>
|
|
165 |
<tr><td valign="top"></td><td valign="top"><em>period</em> </td><td></td></tr>
|
|
166 |
</table>
|
|
167 |
</dl>
|
|
168 |
<dl class="return" compact><dt><b>Returns:</b></dt><dd></dd></dl>
|
|
169 |
|
|
170 |
<p>
|
|
171 |
in order to decide new timer setting we have to run over all timer rows<p>
|
|
172 |
if something to store<p>
|
|
173 |
and empty row<p>
|
|
174 |
just store<p>
|
|
175 |
if successfull<p>
|
|
176 |
set next wakeup alarm if new entry is sooner than others, or if it is alone<p>
|
|
177 |
printf("elapsed_time=%d real_timer_value=%d total_sleep_time=%d\n", elapsed_time, real_timer_value, total_sleep_time);<p>
|
|
178 |
printf("SetAlarm() return %d\n", row_number);
|
|
179 |
<p>
|
|
180 |
Definition at line <a class="el" href="timer_8c-source.html#l00057">57</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
181 |
<p>
|
|
182 |
References <a class="el" href="timer_8c-source.html#l00042">last_timer_raw</a>, and <a class="el" href="timer_8c-source.html#l00039">timers</a>.
|
|
183 |
<p>
|
|
184 |
Referenced by <a class="el" href="lifegrd_8c-source.html#l00206">heartbeatInit()</a>, <a class="el" href="lifegrd_8c-source.html#l00081">proceedNODE_GUARD()</a>, and <a class="el" href="sync_8c-source.html#l00080">startSYNC()</a>.
|
207
|
185 |
</div>
|
|
186 |
</div><p>
|
|
187 |
<a class="anchor" name="fa75192a3238525618f8cb83004930cc"></a><!-- doxytag: member="timer.c::TimeDispatch" ref="fa75192a3238525618f8cb83004930cc" args="()" -->
|
|
188 |
<div class="memitem">
|
|
189 |
<div class="memproto">
|
|
190 |
<table class="memname">
|
|
191 |
<tr>
|
|
192 |
<td class="memname">void TimeDispatch </td>
|
|
193 |
<td>(</td>
|
|
194 |
<td class="paramname"> </td>
|
|
195 |
<td> ) </td>
|
|
196 |
<td width="100%"></td>
|
|
197 |
</tr>
|
|
198 |
</table>
|
|
199 |
</div>
|
|
200 |
<div class="memdoc">
|
|
201 |
|
|
202 |
<p>
|
210
|
203 |
------ TimeDispatch is called on each timer expiration ----
|
|
204 |
<p>
|
|
205 |
used to compute when should normaly occur next wakeup<p>
|
|
206 |
First run : change timer state depending on time<p>
|
|
207 |
Get time since timer signal<p>
|
|
208 |
if row is active<p>
|
|
209 |
to be trigged<p>
|
|
210 |
if simply outdated<p>
|
|
211 |
ask for trig<p>
|
|
212 |
or period have expired<p>
|
|
213 |
set val as interval, with overrun correction<p>
|
|
214 |
Check if this new timer value is the soonest<p>
|
|
215 |
Each armed timer value in decremented.<p>
|
|
216 |
Check if this new timer value is the soonest<p>
|
|
217 |
Remember how much time we should sleep.<p>
|
|
218 |
Set timer to soonest occurence<p>
|
|
219 |
Then trig them or not.<p>
|
|
220 |
reset trig state (will be free if not periodic)<p>
|
|
221 |
trig !
|
|
222 |
<p>
|
|
223 |
Definition at line <a class="el" href="timer_8c-source.html#l00131">131</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
224 |
<p>
|
|
225 |
References <a class="el" href="timer_8c-source.html#l00042">last_timer_raw</a>, <a class="el" href="timer_8c-source.html#l00044">min_val</a>, <a class="el" href="timer_8c-source.html#l00039">timers</a>, and <a class="el" href="timer_8c-source.html#l00041">total_sleep_time</a>.
|
207
|
226 |
</div>
|
|
227 |
</div><p>
|
|
228 |
<hr><h2>Variable Documentation</h2>
|
|
229 |
<a class="anchor" name="1dab7b9a29bdee8b1931f8ea90685c6f"></a><!-- doxytag: member="timer.c::last_timer_raw" ref="1dab7b9a29bdee8b1931f8ea90685c6f" args="" -->
|
|
230 |
<div class="memitem">
|
|
231 |
<div class="memproto">
|
|
232 |
<table class="memname">
|
|
233 |
<tr>
|
|
234 |
<td class="memname">TIMER_HANDLE <a class="el" href="timer_8c.html#1dab7b9a29bdee8b1931f8ea90685c6f">last_timer_raw</a> = -1 </td>
|
|
235 |
</tr>
|
|
236 |
</table>
|
|
237 |
</div>
|
|
238 |
<div class="memdoc">
|
|
239 |
|
|
240 |
<p>
|
|
241 |
|
|
242 |
<p>
|
210
|
243 |
Definition at line <a class="el" href="timer_8c-source.html#l00042">42</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
244 |
<p>
|
|
245 |
Referenced by <a class="el" href="timer_8c-source.html#l00112">DelAlarm()</a>, <a class="el" href="timer_8c-source.html#l00057">SetAlarm()</a>, and <a class="el" href="timer_8c-source.html#l00131">TimeDispatch()</a>.
|
207
|
246 |
</div>
|
|
247 |
</div><p>
|
|
248 |
<a class="anchor" name="a74e2cf2504bfd18b12f112c7aaad845"></a><!-- doxytag: member="timer.c::timers" ref="a74e2cf2504bfd18b12f112c7aaad845" args="[MAX_NB_TIMER]" -->
|
|
249 |
<div class="memitem">
|
|
250 |
<div class="memproto">
|
|
251 |
<table class="memname">
|
|
252 |
<tr>
|
|
253 |
<td class="memname">s_timer_entry <a class="el" href="timer_8c.html#a74e2cf2504bfd18b12f112c7aaad845">timers</a>[MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},} </td>
|
|
254 |
</tr>
|
|
255 |
</table>
|
|
256 |
</div>
|
|
257 |
<div class="memdoc">
|
|
258 |
|
|
259 |
<p>
|
|
260 |
|
|
261 |
<p>
|
210
|
262 |
Definition at line <a class="el" href="timer_8c-source.html#l00039">39</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
263 |
<p>
|
|
264 |
Referenced by <a class="el" href="timer_8c-source.html#l00112">DelAlarm()</a>, <a class="el" href="timer_8c-source.html#l00057">SetAlarm()</a>, and <a class="el" href="timer_8c-source.html#l00131">TimeDispatch()</a>.
|
207
|
265 |
</div>
|
|
266 |
</div><p>
|
|
267 |
<a class="anchor" name="5e9651eed13d70bcce9bdf3489a72a3d"></a><!-- doxytag: member="timer.c::total_sleep_time" ref="5e9651eed13d70bcce9bdf3489a72a3d" args="" -->
|
|
268 |
<div class="memitem">
|
|
269 |
<div class="memproto">
|
|
270 |
<table class="memname">
|
|
271 |
<tr>
|
|
272 |
<td class="memname">TIMEVAL <a class="el" href="timer_8c.html#5e9651eed13d70bcce9bdf3489a72a3d">total_sleep_time</a> = TIMEVAL_MAX </td>
|
|
273 |
</tr>
|
|
274 |
</table>
|
|
275 |
</div>
|
|
276 |
<div class="memdoc">
|
|
277 |
|
|
278 |
<p>
|
|
279 |
|
|
280 |
<p>
|
210
|
281 |
Definition at line <a class="el" href="timer_8c-source.html#l00041">41</a> of file <a class="el" href="timer_8c-source.html">timer.c</a>.
|
|
282 |
<p>
|
|
283 |
Referenced by <a class="el" href="timer_8c-source.html#l00131">TimeDispatch()</a>.
|
|
284 |
</div>
|
|
285 |
</div><p>
|
|
286 |
<hr size="1"><address style="align: right;"><small>Generated on Tue Jun 5 18:32:11 2007 for CanFestival by
|
207
|
287 |
<a href="http://www.doxygen.org/index.html">
|
|
288 |
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
|
|
289 |
</body>
|
|
290 |
</html>
|