doc/doxygen/html/sync_8c-source.html
author etisserant
Thu, 30 Aug 2007 17:01:11 +0200
changeset 260 1eafe582b6a1
parent 240 34654679f262
permissions -rw-r--r--
Better code readability
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>CanFestival: src/sync.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="dirs.html"><span>Directories</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="dir_0aa10e4f705947227e11e7ccb081fbe4.html">src</a></div>
<h1>sync.c</h1><a href="sync_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">This file is part of CanFestival, a library implementing CanOpen Stack. </span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">Copyright (C): Edouard TISSERANT and Francis DUPIN</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">See COPYING file for copyrights details.</span>
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment">modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment">License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment">version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"></span>
<a name="l00013"></a>00013 <span class="comment">This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00016"></a>00016 <span class="comment">Lesser General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"></span>
<a name="l00018"></a>00018 <span class="comment">You should have received a copy of the GNU Lesser General Public</span>
<a name="l00019"></a>00019 <span class="comment">License along with this library; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment">Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00021"></a>00021 <span class="comment">*/</span>
<a name="l00022"></a>00022 
<a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="data_8h.html">data.h</a>"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="sync_8h.html">sync.h</a>"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="win32_2canfestival_8h.html">canfestival.h</a>"</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="comment">/* Prototypes for internals functions */</span>
<a name="l00038"></a>00038 
<a name="l00045"></a>00045 <span class="keywordtype">void</span> <a class="code" href="sync_8c.html#4f6067ef03a5c85e07ddd817dd8d948f">SyncAlarm</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, <a class="code" href="hcs12_2applicfg_8h.html#a6a1b7af83d4106c1d1621bdb28d9c48">UNS32</a> <span class="keywordtype">id</span>);
<a name="l00046"></a>00046 <a class="code" href="hcs12_2applicfg_8h.html#a6a1b7af83d4106c1d1621bdb28d9c48">UNS32</a> <a class="code" href="sync_8c.html#9bcb477ec78154d3d0d0c9bb60392224">OnCOB_ID_SyncUpdate</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, <span class="keyword">const</span> <a class="code" href="structtd__indextable.html">indextable</a> * unsused_indextable, 
<a name="l00047"></a>00047         <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> unsused_bSubindex);
<a name="l00048"></a>00048 
<a name="l00055"></a><a class="code" href="sync_8c.html#4f6067ef03a5c85e07ddd817dd8d948f">00055</a> <span class="keywordtype">void</span> <a class="code" href="sync_8c.html#4f6067ef03a5c85e07ddd817dd8d948f">SyncAlarm</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, <a class="code" href="hcs12_2applicfg_8h.html#a6a1b7af83d4106c1d1621bdb28d9c48">UNS32</a> <span class="keywordtype">id</span>)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057         <a class="code" href="sync_8c.html#9d242846e77a0792d2db7a455c4b955e">sendSYNC</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, *<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#c72942f41becf1ee80b9e65b05a2ac1b">COB_ID_Sync</a> &amp; 0x1FFFFFFF) ;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00069"></a><a class="code" href="sync_8c.html#9bcb477ec78154d3d0d0c9bb60392224">00069</a> <a class="code" href="hcs12_2applicfg_8h.html#a6a1b7af83d4106c1d1621bdb28d9c48">UNS32</a> <a class="code" href="sync_8c.html#9bcb477ec78154d3d0d0c9bb60392224">OnCOB_ID_SyncUpdate</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, <span class="keyword">const</span> <a class="code" href="structtd__indextable.html">indextable</a> * unsused_indextable, <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> unsused_bSubindex)
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071         <a class="code" href="sync_8c.html#4a5d93c6c2b82b6449519b1143437ee9">startSYNC</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>);
<a name="l00072"></a>00072         <span class="keywordflow">return</span> 0;
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00080"></a><a class="code" href="sync_8h.html#4a5d93c6c2b82b6449519b1143437ee9">00080</a> <span class="keywordtype">void</span> <a class="code" href="sync_8c.html#4a5d93c6c2b82b6449519b1143437ee9">startSYNC</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>)
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082         <a class="code" href="objacces_8c.html#9a512a966532e40f35d3a4201bf54ead">RegisterSetODentryCallBack</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, 0x1005, 0, &amp;<a class="code" href="sync_8c.html#9bcb477ec78154d3d0d0c9bb60392224">OnCOB_ID_SyncUpdate</a>);
<a name="l00083"></a>00083         <a class="code" href="objacces_8c.html#9a512a966532e40f35d3a4201bf54ead">RegisterSetODentryCallBack</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, 0x1006, 0, &amp;<a class="code" href="sync_8c.html#9bcb477ec78154d3d0d0c9bb60392224">OnCOB_ID_SyncUpdate</a>);
<a name="l00084"></a>00084 
<a name="l00085"></a>00085         <span class="keywordflow">if</span>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#4e7917821f265cb833634a613da2442a">syncTimer</a> != TIMER_NONE){
<a name="l00086"></a>00086                 <a class="code" href="sync_8c.html#3b95ed533faac10bd1f2eabc649e92f4">stopSYNC</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>);
<a name="l00087"></a>00087         }
<a name="l00088"></a>00088         
<a name="l00089"></a>00089         <span class="keywordflow">if</span>(*<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#c72942f41becf1ee80b9e65b05a2ac1b">COB_ID_Sync</a> &amp; 0x40000000 &amp;&amp; *<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#bc2d265828e65a81b1e5429c9ba2a498">Sync_Cycle_Period</a>)
<a name="l00090"></a>00090         {
<a name="l00091"></a>00091                 <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#4e7917821f265cb833634a613da2442a">syncTimer</a> = <a class="code" href="timer_8c.html#956b22f24089db4c367f40199f838a20">SetAlarm</a>(
<a name="l00092"></a>00092                                 <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>,
<a name="l00093"></a>00093                                 0 <span class="comment">/*No id needed*/</span>,
<a name="l00094"></a>00094                                 &amp;<a class="code" href="sync_8c.html#4f6067ef03a5c85e07ddd817dd8d948f">SyncAlarm</a>,
<a name="l00095"></a>00095                                 <a class="code" href="hcs12_2applicfg_8h.html#5f44d2f770d3bd711510372589f5ae9c">US_TO_TIMEVAL</a>(*<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#bc2d265828e65a81b1e5429c9ba2a498">Sync_Cycle_Period</a>), 
<a name="l00096"></a>00096                                 <a class="code" href="hcs12_2applicfg_8h.html#5f44d2f770d3bd711510372589f5ae9c">US_TO_TIMEVAL</a>(*<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#bc2d265828e65a81b1e5429c9ba2a498">Sync_Cycle_Period</a>));
<a name="l00097"></a>00097         }
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00105"></a><a class="code" href="sync_8h.html#3b95ed533faac10bd1f2eabc649e92f4">00105</a> <span class="keywordtype">void</span> <a class="code" href="sync_8c.html#3b95ed533faac10bd1f2eabc649e92f4">stopSYNC</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107         <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#4e7917821f265cb833634a613da2442a">syncTimer</a> = <a class="code" href="timer_8c.html#12fe6467e1df03cc40dd6f76123c99f6">DelAlarm</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#4e7917821f265cb833634a613da2442a">syncTimer</a>);
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109 
<a name="l00118"></a><a class="code" href="sync_8h.html#9d242846e77a0792d2db7a455c4b955e">00118</a> <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> <a class="code" href="sync_8c.html#9d242846e77a0792d2db7a455c4b955e">sendSYNC</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, <a class="code" href="hcs12_2applicfg_8h.html#a6a1b7af83d4106c1d1621bdb28d9c48">UNS32</a> cob_id)
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120   <a class="code" href="structMessage.html">Message</a> m;
<a name="l00121"></a>00121   <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> resultat ;
<a name="l00122"></a>00122   
<a name="l00123"></a>00123   <a class="code" href="hcs12_2applicfg_8h.html#d5dffc889e623fbc4f635e69276cdf20">MSG_WAR</a>(0x3001, <span class="stringliteral">"sendSYNC "</span>, 0);
<a name="l00124"></a>00124   
<a name="l00125"></a>00125   m.<a class="code" href="structMessage.html#21cda7edcf0800d296151c83e7f9948e">cob_id</a>.<a class="code" href="structSHORT__CAN.html#e77854035fa72dc0769724a2d056bc9d">w</a> = cob_id ;
<a name="l00126"></a>00126   m.<a class="code" href="structMessage.html#4fea58e2ceec365228be253ba3d8bdba">rtr</a> = <a class="code" href="def_8h.html#b6a4c86a352c3ac564dae3767c7524f3">NOT_A_REQUEST</a>;
<a name="l00127"></a>00127   m.<a class="code" href="structMessage.html#a8c32de83f67079897508203c8e2198c">len</a> = 0;
<a name="l00128"></a>00128   resultat = <a class="code" href="canOpenDriver_8c.html#fab789b9b2ee0ab6c6f27e67d6c03661">canSend</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#05c8d7a0518b95971818a9c612f8b9c0">canHandle</a>,&amp;m) ;
<a name="l00129"></a>00129   <a class="code" href="sync_8c.html#89ae8cfbfc53c26248d5d91f689c7197">proceedSYNC</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, &amp;m) ; 
<a name="l00130"></a>00130   <span class="keywordflow">return</span> resultat ;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 
<a name="l00141"></a><a class="code" href="sync_8h.html#89ae8cfbfc53c26248d5d91f689c7197">00141</a> <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> <a class="code" href="sync_8c.html#89ae8cfbfc53c26248d5d91f689c7197">proceedSYNC</a>(<a class="code" href="structstruct__CO__Data.html">CO_Data</a>* <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, <a class="code" href="structMessage.html">Message</a> *m)
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143 
<a name="l00144"></a>00144   <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> res;
<a name="l00145"></a>00145   
<a name="l00146"></a>00146   <a class="code" href="hcs12_2applicfg_8h.html#d5dffc889e623fbc4f635e69276cdf20">MSG_WAR</a>(0x3002, <span class="stringliteral">"SYNC received. Proceed. "</span>, 0);
<a name="l00147"></a>00147   
<a name="l00148"></a>00148   (*<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#f51d3f1c7af9ab07bed3a8c28e3e2162">post_sync</a>)();
<a name="l00149"></a>00149 
<a name="l00150"></a>00150   <span class="comment">/* only operational state allows PDO transmission */</span>
<a name="l00151"></a>00151   <span class="keywordflow">if</span>(! <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#ac7e1610f30cb4035d51532db75738e6">CurrentCommunicationState</a>.<a class="code" href="structs__state__communication.html#9e525c64ecaa9ffd9f2f9e6dea031fed">csPDO</a>) 
<a name="l00152"></a>00152     <span class="keywordflow">return</span> 0;
<a name="l00153"></a>00153 
<a name="l00154"></a>00154   res = <a class="code" href="pdo_8c.html#fbf33713253ccf33f9277e31c78a6cb5">_sendPDOevent</a>(<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>, 1 <span class="comment">/*isSyncEvent*/</span> );
<a name="l00155"></a>00155   
<a name="l00156"></a>00156   <span class="comment">/*Call user app callback*/</span>
<a name="l00157"></a>00157   (*<a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>-&gt;<a class="code" href="structstruct__CO__Data.html#ebb8649e117348c6cc94cd6f86684747">post_TPDO</a>)();
<a name="l00158"></a>00158   
<a name="l00159"></a>00159   <span class="keywordflow">return</span> res;
<a name="l00160"></a>00160   
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 
<a name="l00164"></a><a class="code" href="sync_8h.html#2e43afff70fd6c17e53b1fc9a7c39b88">00164</a> <span class="keywordtype">void</span> <a class="code" href="sync_8c.html#4361c24679b77c8c1466f0357fabaa6d">_post_sync</a>(){}
<a name="l00165"></a><a class="code" href="sync_8h.html#af70e681622716f01f0b459eaa7e4d16">00165</a> <span class="keywordtype">void</span> <a class="code" href="sync_8c.html#8098c6d131b8c2b779a8e06070c818da">_post_TPDO</a>(){}
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Jul 2 19:10:16 2007 for CanFestival by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
</body>
</html>