1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
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"> |
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> |
3 <title>CanFestival: src/timer.c File Reference</title> |
4 <link href="doxygen.css" rel="stylesheet" type="text/css"> |
4 <link href="doxygen.css" rel="stylesheet" type="text/css"> |
5 <link href="tabs.css" rel="stylesheet" type="text/css"> |
5 <link href="tabs.css" rel="stylesheet" type="text/css"> |
6 </head><body> |
6 </head><body> |
7 <!-- Generated by Doxygen 1.5.1 --> |
7 <!-- Generated by Doxygen 1.5.1 --> |
8 <div class="tabs"> |
8 <div class="tabs"> |
9 <ul> |
9 <ul> |
10 <li><a href="main.html"><span>Main Page</span></a></li> |
10 <li><a href="main.html"><span>Main Page</span></a></li> |
|
11 <li><a href="annotated.html"><span>Data Structures</span></a></li> |
11 <li id="current"><a href="files.html"><span>Files</span></a></li> |
12 <li id="current"><a href="files.html"><span>Files</span></a></li> |
|
13 <li><a href="dirs.html"><span>Directories</span></a></li> |
12 </ul></div> |
14 </ul></div> |
13 <div class="tabs"> |
15 <div class="tabs"> |
14 <ul> |
16 <ul> |
15 <li><a href="files.html"><span>File List</span></a></li> |
17 <li><a href="files.html"><span>File List</span></a></li> |
16 <li><a href="globals.html"><span>Globals</span></a></li> |
18 <li><a href="globals.html"><span>Globals</span></a></li> |
17 </ul></div> |
19 </ul></div> |
18 <h1>/home/epimerde/documents/tc11/CanFestival-3/src/timer.c File Reference</h1><code>#include <applicfg.h></code><br> |
20 <div class="nav"> |
19 <code>#include "timer.h"</code><br> |
21 <a class="el" href="dir_c0a169d39c08973f879fd54f07b9e9f7.html">src</a></div> |
20 |
22 <h1>timer.c File Reference</h1><code>#include <<a class="el" href="win32_2applicfg_8h-source.html">applicfg.h</a>></code><br> |
21 <p> |
23 <code>#include "<a class="el" href="timer_8h-source.html">timer.h</a>"</code><br> |
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> |
24 |
|
25 <p> |
|
26 Include dependency graph for timer.c:<p><center><img src="timer_8c__incl.png" border="0" usemap="#src/timer.c_map" alt=""></center> |
|
27 <map name="src/timer.c_map"> |
|
28 <area href="win32_2applicfg_8h.html" shape="rect" coords="567,349,655,373" alt=""> |
|
29 <area href="timer_8h.html" shape="rect" coords="147,301,216,325" alt=""> |
|
30 <area href="win32_2timerscfg_8h.html" shape="rect" coords="264,56,363,80" alt=""> |
|
31 <area href="data_8h.html" shape="rect" coords="282,301,346,325" alt=""> |
|
32 <area href="def_8h.html" shape="rect" coords="583,155,639,179" alt=""> |
|
33 <area href="can_8h.html" shape="rect" coords="435,301,494,325" alt=""> |
|
34 <area href="objdictdef_8h.html" shape="rect" coords="414,445,515,469" alt=""> |
|
35 <area href="objacces_8h.html" shape="rect" coords="418,349,511,373" alt=""> |
|
36 <area href="sdo_8h.html" shape="rect" coords="435,56,494,80" alt=""> |
|
37 <area href="pdo_8h.html" shape="rect" coords="435,203,494,227" alt=""> |
|
38 <area href="states_8h.html" shape="rect" coords="427,397,502,421" alt=""> |
|
39 <area href="lifegrd_8h.html" shape="rect" coords="426,541,503,565" alt=""> |
|
40 <area href="sync_8h.html" shape="rect" coords="431,493,498,517" alt=""> |
|
41 <area href="nmtMaster_8h.html" shape="rect" coords="411,155,518,179" alt=""> |
|
42 <area href="config_8h.html" shape="rect" coords="714,155,788,179" alt=""> |
|
43 </map> |
23 |
44 |
24 <p> |
45 <p> |
25 <a href="timer_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0"> |
46 <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> |
47 <tr><td></td></tr> |
27 <tr><td colspan="2"><br><h2>Defines</h2></td></tr> |
48 <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> |
49 <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 |
50 |
30 <tr><td colspan="2"><br><h2>Functions</h2></td></tr> |
51 <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> |
52 <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> (<a class="el" href="structstruct__CO__Data.html">CO_Data</a> *d, UNS32 id, <a class="el" href="timer_8h.html#f7d102e060339d3730ceae5fea03691b">TimerCallback_t</a> callback, TIMEVAL value, TIMEVAL period)</td></tr> |
32 |
53 |
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> |
54 <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 |
55 |
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> |
56 <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 |
57 |
37 <tr><td colspan="2"><br><h2>Variables</h2></td></tr> |
58 <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> |
59 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="structstruct__s__timer__entry.html">s_timer_entry</a> </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 |
60 |
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> |
61 <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 |
62 |
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> |
63 <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 |
64 |
100 </table> |
121 </table> |
101 </dl> |
122 </dl> |
102 <dl class="return" compact><dt><b>Returns:</b></dt><dd></dd></dl> |
123 <dl class="return" compact><dt><b>Returns:</b></dt><dd></dd></dl> |
103 |
124 |
104 <p> |
125 <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>. |
126 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> |
127 <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>. |
128 References <a class="el" href="timer_8c-source.html#l00042">last_timer_raw</a>, <a class="el" href="hcs12_2applicfg_8h-source.html#l00190">MSG_WAR</a>, <a class="el" href="timer_8h-source.html#l00044">struct_s_timer_entry::state</a>, and <a class="el" href="timer_8c-source.html#l00039">timers</a>. |
110 <p> |
129 <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>. |
130 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>. |
112 </div> |
131 </div> |
113 </div><p> |
132 </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)" --> |
133 <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)" --> |
166 </table> |
185 </table> |
167 </dl> |
186 </dl> |
168 <dl class="return" compact><dt><b>Returns:</b></dt><dd></dd></dl> |
187 <dl class="return" compact><dt><b>Returns:</b></dt><dd></dd></dl> |
169 |
188 |
170 <p> |
189 <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>. |
190 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> |
191 <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>. |
192 References <a class="el" href="timer_8h-source.html#l00045">struct_s_timer_entry::d</a>, <a class="el" href="timer_8c-source.html#l00042">last_timer_raw</a>, <a class="el" href="config_8h-source.html#l00032">MAX_NB_TIMER</a>, <a class="el" href="timer_8h-source.html#l00029">TIMER_HANDLE</a>, and <a class="el" href="timer_8c-source.html#l00039">timers</a>. |
183 <p> |
193 <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>. |
194 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>, <a class="el" href="sync_8c-source.html#l00080">startSYNC()</a>, and <a class="el" href="timers__unix_8c-source.html#l00062">StartTimerLoop()</a>. |
185 </div> |
195 </div> |
186 </div><p> |
196 </div><p> |
187 <a class="anchor" name="fa75192a3238525618f8cb83004930cc"></a><!-- doxytag: member="timer.c::TimeDispatch" ref="fa75192a3238525618f8cb83004930cc" args="()" --> |
197 <a class="anchor" name="fa75192a3238525618f8cb83004930cc"></a><!-- doxytag: member="timer.c::TimeDispatch" ref="fa75192a3238525618f8cb83004930cc" args="()" --> |
188 <div class="memitem"> |
198 <div class="memitem"> |
189 <div class="memproto"> |
199 <div class="memproto"> |
190 <table class="memname"> |
200 <table class="memname"> |
191 <tr> |
201 <tr> |
192 <td class="memname">void TimeDispatch </td> |
202 <td class="memname">void TimeDispatch </td> |
193 <td>(</td> |
203 <td>(</td> |
|
204 <td class="paramtype">void </td> |
194 <td class="paramname"> </td> |
205 <td class="paramname"> </td> |
195 <td> ) </td> |
206 <td> ) </td> |
196 <td width="100%"></td> |
207 <td width="100%"></td> |
197 </tr> |
208 </tr> |
198 </table> |
209 </table> |
200 <div class="memdoc"> |
211 <div class="memdoc"> |
201 |
212 |
202 <p> |
213 <p> |
203 ------ TimeDispatch is called on each timer expiration ---- |
214 ------ TimeDispatch is called on each timer expiration ---- |
204 <p> |
215 <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>. |
216 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> |
217 <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>. |
218 References <a class="el" href="canOpenDriver_8c-source.html#l00066">getElapsedTime()</a>, <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_8h-source.html#l00029">TIMER_HANDLE</a>, <a class="el" href="timer_8c-source.html#l00039">timers</a>, <a class="el" href="hcs12_2applicfg_8h-source.html#l00150">TIMEVAL</a>, <a class="el" href="hcs12_2applicfg_8h-source.html#l00153">TIMEVAL_MAX</a>, and <a class="el" href="timer_8c-source.html#l00041">total_sleep_time</a>. |
|
219 <p> |
|
220 Referenced by <a class="el" href="timers__win32_8cpp-source.html#l00151">class_timers::timer_loop_thread_proc()</a>, <a class="el" href="timers__unix_8c-source.html#l00030">timer_notify()</a>, and <a class="el" href="timers__xeno_8c-source.html#l00045">timerloop_task_proc()</a>. |
|
221 <p> |
|
222 Here is the call graph for this function:<p><center><img src="timer_8c_fa75192a3238525618f8cb83004930cc_cgraph.png" border="0" usemap="#timer_8c_fa75192a3238525618f8cb83004930cc_cgraph_map" alt=""></center> |
|
223 <map name="timer_8c_fa75192a3238525618f8cb83004930cc_cgraph_map"> |
|
224 <area href="canOpenDriver_8c.html#24dbe63e88d184388542037d16a8208d" shape="rect" coords="171,6,302,30" alt=""> |
|
225 </map> |
|
226 |
226 </div> |
227 </div> |
227 </div><p> |
228 </div><p> |
228 <hr><h2>Variable Documentation</h2> |
229 <hr><h2>Variable Documentation</h2> |
229 <a class="anchor" name="1dab7b9a29bdee8b1931f8ea90685c6f"></a><!-- doxytag: member="timer.c::last_timer_raw" ref="1dab7b9a29bdee8b1931f8ea90685c6f" args="" --> |
230 <a class="anchor" name="1dab7b9a29bdee8b1931f8ea90685c6f"></a><!-- doxytag: member="timer.c::last_timer_raw" ref="1dab7b9a29bdee8b1931f8ea90685c6f" args="" --> |
230 <div class="memitem"> |
231 <div class="memitem"> |