doc/doxygen/html/timers__xeno_8c-source.html
author lbessard
Tue, 28 Aug 2007 14:32:05 +0200
changeset 259 fefaeb965850
parent 240 34654679f262
permissions -rw-r--r--
Bugs fixed on objdictedit dialogs
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     3
<title>CanFestival: drivers/timers_xeno/timers_xeno.c Source File</title>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     4
<link href="doxygen.css" rel="stylesheet" type="text/css">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     5
<link href="tabs.css" rel="stylesheet" type="text/css">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     6
</head><body>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     7
<!-- Generated by Doxygen 1.5.1 -->
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     8
<div class="tabs">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
     9
  <ul>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    10
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    11
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    12
    <li id="current"><a href="files.html"><span>Files</span></a></li>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    13
    <li><a href="dirs.html"><span>Directories</span></a></li>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    14
  </ul></div>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    15
<div class="tabs">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    16
  <ul>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    17
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    18
    <li><a href="globals.html"><span>Globals</span></a></li>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    19
  </ul></div>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    20
<div class="nav">
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    21
<a class="el" href="dir_65dd258ff9b9ef4cd7bd0d22f5e58dba.html">drivers</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_fbe54e12a3ca31aa857852b30ece23ba.html">timers_xeno</a></div>
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    22
<h1>timers_xeno.c</h1><a href="timers__xeno_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    23
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    24
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;sys/mman.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    25
<a name="l00004"></a>00004 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    26
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;native/task.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    27
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;native/timer.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    28
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;native/mutex.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    29
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;native/alarm.h&gt;</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    30
<a name="l00009"></a>00009 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    31
<a name="l00010"></a>00010 <span class="preprocessor">#include "<a class="code" href="win32_2applicfg_8h.html">applicfg.h</a>"</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    32
<a name="l00011"></a>00011 <span class="preprocessor">#include "<a class="code" href="can__driver_8h.html">can_driver.h</a>"</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    33
<a name="l00012"></a>00012 <span class="preprocessor">#include "<a class="code" href="timer_8h.html">timer.h</a>"</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    34
<a name="l00013"></a>00013 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    35
<a name="l00014"></a><a class="code" href="timers__xeno_8c.html#2bf49bd85708887357bb07c133e18040">00014</a> <span class="preprocessor">#define TIMERLOOP_TASK_CREATED        1</span>
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    36
<a name="l00015"></a>00015 <span class="preprocessor"></span>
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    37
<a name="l00016"></a><a class="code" href="timers__xeno_8c.html#7b04510000ccc2625dfec31ce1af3d95">00016</a> RT_MUTEX <a class="code" href="timers__unix_8c.html#16cebc4fb81e0421b9d57fcb5d7b2515">CanFestival_mutex</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    38
<a name="l00017"></a><a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">00017</a> RT_TASK <a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">timerloop_task</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    39
<a name="l00018"></a><a class="code" href="timers__xeno_8c.html#f2434742606eea8e1cb738e3f168235b">00018</a> RTIME <a class="code" href="timers__xeno_8c.html#f2434742606eea8e1cb738e3f168235b">last_time_read</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    40
<a name="l00019"></a><a class="code" href="timers__xeno_8c.html#f0e3fd522984f6999b06ea83f3716afb">00019</a> RTIME <a class="code" href="timers__xeno_8c.html#f0e3fd522984f6999b06ea83f3716afb">last_occured_alarm</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    41
<a name="l00020"></a><a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">00020</a> RTIME <a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">last_alarm_set</a>;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    42
<a name="l00021"></a>00021 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    43
<a name="l00022"></a><a class="code" href="timers__xeno_8c.html#4c575a566e5f899b64ad7e45000607ed">00022</a> <span class="keywordtype">char</span> <a class="code" href="timers__xeno_8c.html#4c575a566e5f899b64ad7e45000607ed">stop_timer</a>=0;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    44
<a name="l00023"></a>00023 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    45
<a name="l00024"></a><a class="code" href="timers__xeno_8c.html#7daa4eba1dc16bcf9d867b79c61a7b58">00024</a> <span class="keywordtype">void</span> <a class="code" href="timers__xeno_8c.html#7daa4eba1dc16bcf9d867b79c61a7b58">cleanup_all</a>(<span class="keywordtype">void</span>)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    46
<a name="l00025"></a>00025 {
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    47
<a name="l00026"></a>00026         rt_task_delete(&amp;<a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">timerloop_task</a>);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    48
<a name="l00027"></a>00027 }
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    49
<a name="l00028"></a><a class="code" href="timers__xeno_8c.html#8d52f2db8b505e53ace5dd1c2a789d94">00028</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#8d52f2db8b505e53ace5dd1c2a789d94">StopTimerLoop</a>(<span class="keywordtype">void</span>)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    50
<a name="l00029"></a>00029 {
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    51
<a name="l00030"></a>00030         <a class="code" href="timers__xeno_8c.html#4c575a566e5f899b64ad7e45000607ed">stop_timer</a> = 1;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    52
<a name="l00031"></a>00031         rt_task_unblock(&amp;<a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">timerloop_task</a>);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    53
<a name="l00032"></a>00032 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    54
<a name="l00033"></a>00033 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    55
<a name="l00034"></a>00034 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    56
<a name="l00035"></a><a class="code" href="timers__xeno_8c.html#aa3c568288a54a9398524255602bbce8">00035</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#aa3c568288a54a9398524255602bbce8">EnterMutex</a>(<span class="keywordtype">void</span>)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    57
<a name="l00036"></a>00036 {
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    58
<a name="l00037"></a>00037         rt_mutex_lock(&amp;<a class="code" href="timers__unix_8c.html#16cebc4fb81e0421b9d57fcb5d7b2515">CanFestival_mutex</a>, TM_INFINITE); 
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    59
<a name="l00038"></a>00038 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    60
<a name="l00039"></a>00039 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    61
<a name="l00040"></a><a class="code" href="timers__xeno_8c.html#887d197b991c23bc11f626ae688abec7">00040</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#887d197b991c23bc11f626ae688abec7">LeaveMutex</a>(<span class="keywordtype">void</span>)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    62
<a name="l00041"></a>00041 {
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    63
<a name="l00042"></a>00042         rt_mutex_unlock(&amp;<a class="code" href="timers__unix_8c.html#16cebc4fb81e0421b9d57fcb5d7b2515">CanFestival_mutex</a>);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    64
<a name="l00043"></a>00043 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    65
<a name="l00044"></a>00044 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    66
<a name="l00045"></a><a class="code" href="timers__xeno_8c.html#cfb2e8d3c5662059b0a5d3028a538b7c">00045</a> <span class="keywordtype">void</span> <a class="code" href="timers__xeno_8c.html#cfb2e8d3c5662059b0a5d3028a538b7c">timerloop_task_proc</a>(<span class="keywordtype">void</span> *arg)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    67
<a name="l00046"></a>00046 {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    68
<a name="l00047"></a>00047         <span class="keywordtype">int</span> ret;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    69
<a name="l00048"></a>00048         <span class="keywordflow">do</span>{
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    70
<a name="l00049"></a>00049                 <span class="keywordflow">do</span>{
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    71
<a name="l00050"></a>00050                         <a class="code" href="timers__xeno_8c.html#f0e3fd522984f6999b06ea83f3716afb">last_occured_alarm</a> = <a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">last_alarm_set</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    72
<a name="l00051"></a>00051                         <a class="code" href="timers__unix_8c.html#aa3c568288a54a9398524255602bbce8">EnterMutex</a>();
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    73
<a name="l00052"></a>00052                         <a class="code" href="timer_8c.html#7a5a515821c2e4fb2f66bac72389da00">TimeDispatch</a>();
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    74
<a name="l00053"></a>00053                         <a class="code" href="timers__unix_8c.html#887d197b991c23bc11f626ae688abec7">LeaveMutex</a>();
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    75
<a name="l00054"></a>00054                         <span class="keywordflow">while</span> ((ret = rt_task_sleep_until(<a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">last_alarm_set</a>)) == -EINTR);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    76
<a name="l00055"></a>00055                 }<span class="keywordflow">while</span> (ret == 0);
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    77
<a name="l00056"></a>00056         }<span class="keywordflow">while</span> (!<a class="code" href="timers__xeno_8c.html#4c575a566e5f899b64ad7e45000607ed">stop_timer</a>);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    78
<a name="l00057"></a>00057         printf(<span class="stringliteral">"End of TimerLoop, code %d\n"</span>,ret);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    79
<a name="l00058"></a>00058 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    80
<a name="l00059"></a>00059 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    81
<a name="l00060"></a><a class="code" href="timers__xeno_8c.html#dd08f21a7c3fcbcd53a2c41b00879fdd">00060</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#dd08f21a7c3fcbcd53a2c41b00879fdd">StartTimerLoop</a>(<a class="code" href="timer_8h.html#c8436e7543fa1329b00e570246071313">TimerCallback_t</a> init_callback)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    82
<a name="l00061"></a>00061 {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    83
<a name="l00062"></a>00062         <span class="keywordtype">int</span> ret;
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    84
<a name="l00063"></a>00063         <a class="code" href="timers__xeno_8c.html#4c575a566e5f899b64ad7e45000607ed">stop_timer</a> = 0;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    85
<a name="l00064"></a>00064         <span class="keywordtype">char</span> taskname[32];
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    86
<a name="l00065"></a>00065         snprintf(taskname, <span class="keyword">sizeof</span>(taskname), <span class="stringliteral">"timerloop-%d"</span>, getpid());
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    87
<a name="l00066"></a>00066 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    88
<a name="l00067"></a>00067         mlockall(MCL_CURRENT | MCL_FUTURE);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    89
<a name="l00068"></a>00068 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    90
<a name="l00069"></a>00069         <span class="comment">//create timerloop_task</span>
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    91
<a name="l00070"></a>00070         ret = rt_task_create(&amp;<a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">timerloop_task</a>, taskname, 0, 50, 0);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    92
<a name="l00071"></a>00071         <span class="keywordflow">if</span> (ret) {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    93
<a name="l00072"></a>00072                 printf(<span class="stringliteral">"Failed to create timerloop_task, code %d\n"</span>,errno);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    94
<a name="l00073"></a>00073                 <span class="keywordflow">return</span>;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    95
<a name="l00074"></a>00074         }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
    96
<a name="l00075"></a>00075         
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    97
<a name="l00076"></a>00076         <a class="code" href="canOpenDriver_8c.html#38b23a8ee3748bca3415967b90df1e15">getElapsedTime</a>();
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    98
<a name="l00077"></a>00077         <a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">last_alarm_set</a> = <a class="code" href="timers__xeno_8c.html#f2434742606eea8e1cb738e3f168235b">last_time_read</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
    99
<a name="l00078"></a>00078         <a class="code" href="timers__xeno_8c.html#f0e3fd522984f6999b06ea83f3716afb">last_occured_alarm</a> = <a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">last_alarm_set</a>;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   100
<a name="l00079"></a>00079         <a class="code" href="timer_8c.html#956b22f24089db4c367f40199f838a20">SetAlarm</a>(NULL, 0, init_callback, 0, 0);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   101
<a name="l00080"></a>00080         <span class="comment">// start timerloop_task</span>
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   102
<a name="l00081"></a>00081         ret = rt_task_start(&amp;<a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">timerloop_task</a>,&amp;<a class="code" href="timers__xeno_8c.html#cfb2e8d3c5662059b0a5d3028a538b7c">timerloop_task_proc</a>,NULL);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   103
<a name="l00082"></a>00082         <span class="keywordflow">if</span> (ret) {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   104
<a name="l00083"></a>00083                 printf(<span class="stringliteral">"Failed to start timerloop_task, code %d\n"</span>,errno);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   105
<a name="l00084"></a>00084                 <span class="keywordflow">goto</span> error;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   106
<a name="l00085"></a>00085         }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   107
<a name="l00086"></a>00086         
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   108
<a name="l00087"></a>00087         <span class="keywordflow">return</span>;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   109
<a name="l00088"></a>00088         
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   110
<a name="l00089"></a>00089 error:
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   111
<a name="l00090"></a>00090         <a class="code" href="timers__xeno_8c.html#7daa4eba1dc16bcf9d867b79c61a7b58">cleanup_all</a>();
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   112
<a name="l00091"></a>00091 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   113
<a name="l00092"></a>00092 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   114
<a name="l00093"></a><a class="code" href="timers__xeno_8c.html#2fd14b68f735eb13d95b60da047f26c6">00093</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#09c921f9537f26895843a3c21620855b">CreateReceiveTask</a>(<a class="code" href="unix_2applicfg_8h.html#c5a917a8cacf5edd42ba6486c0c8a243">CAN_PORT</a> fd0, <a class="code" href="timers__unix_2timerscfg_8h.html#69c1aff70ae463b42314dc6689cb7400">TASK_HANDLE</a> *ReceiveLoop_task, <span class="keywordtype">void</span>* ReceiveLoop_task_proc)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   115
<a name="l00094"></a>00094 {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   116
<a name="l00095"></a>00095         <span class="keywordtype">int</span> ret;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   117
<a name="l00096"></a>00096         <span class="keyword">static</span> <span class="keywordtype">int</span> <span class="keywordtype">id</span> = 0;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   118
<a name="l00097"></a>00097         <span class="keywordtype">char</span> taskname[32];
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   119
<a name="l00098"></a>00098         snprintf(taskname, <span class="keyword">sizeof</span>(taskname), <span class="stringliteral">"canloop%d-%d"</span>, <span class="keywordtype">id</span>, getpid());
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   120
<a name="l00099"></a>00099         <span class="keywordtype">id</span>++;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   121
<a name="l00100"></a>00100 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   122
<a name="l00101"></a>00101         mlockall(MCL_CURRENT | MCL_FUTURE);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   123
<a name="l00102"></a>00102 
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   124
<a name="l00103"></a>00103         <span class="comment">//create timerloop_task</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   125
<a name="l00104"></a>00104         ret = rt_task_create(ReceiveLoop_task,taskname,0,50,0);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   126
<a name="l00105"></a>00105         <span class="keywordflow">if</span> (ret) {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   127
<a name="l00106"></a>00106                 printf(<span class="stringliteral">"Failed to create ReceiveLoop_task number %d, code %d\n"</span>, <span class="keywordtype">id</span>, errno);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   128
<a name="l00107"></a>00107                 <span class="keywordflow">return</span>;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   129
<a name="l00108"></a>00108         }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   130
<a name="l00109"></a>00109         <span class="comment">// start timerloop_task</span>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   131
<a name="l00110"></a>00110         ret = rt_task_start(ReceiveLoop_task,ReceiveLoop_task_proc,(<span class="keywordtype">void</span>*)fd0);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   132
<a name="l00111"></a>00111         <span class="keywordflow">if</span> (ret) {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   133
<a name="l00112"></a>00112                 printf(<span class="stringliteral">"Failed to start ReceiveLoop_task number %d, code %d\n"</span>, <span class="keywordtype">id</span>, errno);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   134
<a name="l00113"></a>00113                 <span class="keywordflow">return</span>;
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   135
<a name="l00114"></a>00114         }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   136
<a name="l00115"></a>00115 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   137
<a name="l00116"></a>00116 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   138
<a name="l00117"></a><a class="code" href="timers__xeno_8c.html#b712d2cb572b9cd5f7ce99fff8922ddc">00117</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#b21b041545f4dfc5660514fbc3c2f89c">WaitReceiveTaskEnd</a>(<a class="code" href="timers__unix_2timerscfg_8h.html#69c1aff70ae463b42314dc6689cb7400">TASK_HANDLE</a> *Thread)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   139
<a name="l00118"></a>00118 {
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   140
<a name="l00119"></a>00119         rt_task_delete(Thread);
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   141
<a name="l00120"></a>00120 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   142
<a name="l00121"></a>00121 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   143
<a name="l00122"></a><a class="code" href="timers__xeno_8c.html#7996006c628d2df030b9684d7a86acd1">00122</a> <span class="keywordtype">void</span> <a class="code" href="timers__unix_8c.html#7996006c628d2df030b9684d7a86acd1">setTimer</a>(<a class="code" href="hcs12_2applicfg_8h.html#dea5fb459bddd6fd539cdf665dd657e6">TIMEVAL</a> value)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   144
<a name="l00123"></a>00123 {
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   145
<a name="l00124"></a>00124         <a class="code" href="timers__xeno_8c.html#f567c1ed1dc6f3d12732e18e05167a86">last_alarm_set</a> = (value == <a class="code" href="hcs12_2applicfg_8h.html#9b8b68779cc690a9f699155420328d0f">TIMEVAL_MAX</a>) ? <a class="code" href="hcs12_2applicfg_8h.html#9b8b68779cc690a9f699155420328d0f">TIMEVAL_MAX</a> : <a class="code" href="timers__xeno_8c.html#f2434742606eea8e1cb738e3f168235b">last_time_read</a> + value;
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   146
<a name="l00125"></a>00125         rt_task_unblock(&amp;<a class="code" href="timers__xeno_8c.html#b5326f600737761d3c937b523f3b43ff">timerloop_task</a>);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   147
<a name="l00126"></a>00126 }
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   148
<a name="l00127"></a>00127 
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   149
<a name="l00128"></a><a class="code" href="timers__xeno_8c.html#75efe30105165658d05d871255f8c0a2">00128</a> <a class="code" href="hcs12_2applicfg_8h.html#dea5fb459bddd6fd539cdf665dd657e6">TIMEVAL</a> <a class="code" href="canOpenDriver_8c.html#38b23a8ee3748bca3415967b90df1e15">getElapsedTime</a>(<span class="keywordtype">void</span>)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   150
<a name="l00129"></a>00129 {
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   151
<a name="l00130"></a>00130         <a class="code" href="timers__xeno_8c.html#f2434742606eea8e1cb738e3f168235b">last_time_read</a> = rt_timer_ticks2ns(rt_timer_read());
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   152
<a name="l00131"></a>00131         <span class="keywordflow">return</span> <a class="code" href="timers__xeno_8c.html#f2434742606eea8e1cb738e3f168235b">last_time_read</a> - <a class="code" href="timers__xeno_8c.html#f0e3fd522984f6999b06ea83f3716afb">last_occured_alarm</a>;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   153
<a name="l00132"></a>00132 }
240
34654679f262 Udpated doxygen
etisserant
parents: 215
diff changeset
   154
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Jul 2 19:10:16 2007 for CanFestival by&nbsp;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   155
<a href="http://www.doxygen.org/index.html">
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   156
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   157
</body>
f49e5a6b7804 Manual and Documentation finish
nico
parents:
diff changeset
   158
</html>