doc/doxygen/html/sync_8c-source.html
changeset 388 1c1e3599d66a
parent 387 6efc85c5493e
child 389 8a46c8432c82
equal deleted inserted replaced
387:6efc85c5493e 388:1c1e3599d66a
     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: src/sync.c Source File</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&nbsp;Page</span></a></li>
       
    11     <li><a href="annotated.html"><span>Data&nbsp;Structures</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>
       
    14   </ul></div>
       
    15 <div class="tabs">
       
    16   <ul>
       
    17     <li><a href="files.html"><span>File&nbsp;List</span></a></li>
       
    18     <li><a href="globals.html"><span>Globals</span></a></li>
       
    19   </ul></div>
       
    20 <div class="nav">
       
    21 <a class="el" href="dir_0aa10e4f705947227e11e7ccb081fbe4.html">src</a></div>
       
    22 <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>
       
    23 <a name="l00002"></a>00002 <span class="comment">This file is part of CanFestival, a library implementing CanOpen Stack. </span>
       
    24 <a name="l00003"></a>00003 <span class="comment"></span>
       
    25 <a name="l00004"></a>00004 <span class="comment">Copyright (C): Edouard TISSERANT and Francis DUPIN</span>
       
    26 <a name="l00005"></a>00005 <span class="comment"></span>
       
    27 <a name="l00006"></a>00006 <span class="comment">See COPYING file for copyrights details.</span>
       
    28 <a name="l00007"></a>00007 <span class="comment"></span>
       
    29 <a name="l00008"></a>00008 <span class="comment">This library is free software; you can redistribute it and/or</span>
       
    30 <a name="l00009"></a>00009 <span class="comment">modify it under the terms of the GNU Lesser General Public</span>
       
    31 <a name="l00010"></a>00010 <span class="comment">License as published by the Free Software Foundation; either</span>
       
    32 <a name="l00011"></a>00011 <span class="comment">version 2.1 of the License, or (at your option) any later version.</span>
       
    33 <a name="l00012"></a>00012 <span class="comment"></span>
       
    34 <a name="l00013"></a>00013 <span class="comment">This library is distributed in the hope that it will be useful,</span>
       
    35 <a name="l00014"></a>00014 <span class="comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
       
    36 <a name="l00015"></a>00015 <span class="comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
       
    37 <a name="l00016"></a>00016 <span class="comment">Lesser General Public License for more details.</span>
       
    38 <a name="l00017"></a>00017 <span class="comment"></span>
       
    39 <a name="l00018"></a>00018 <span class="comment">You should have received a copy of the GNU Lesser General Public</span>
       
    40 <a name="l00019"></a>00019 <span class="comment">License along with this library; if not, write to the Free Software</span>
       
    41 <a name="l00020"></a>00020 <span class="comment">Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
       
    42 <a name="l00021"></a>00021 <span class="comment">*/</span>
       
    43 <a name="l00022"></a>00022 
       
    44 <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="data_8h.html">data.h</a>"</span>
       
    45 <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="sync_8h.html">sync.h</a>"</span>
       
    46 <a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="win32_2canfestival_8h.html">canfestival.h</a>"</span>
       
    47 <a name="l00036"></a>00036 
       
    48 <a name="l00037"></a>00037 <span class="comment">/* Prototypes for internals functions */</span>
       
    49 <a name="l00038"></a>00038 
       
    50 <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>);
       
    51 <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, 
       
    52 <a name="l00047"></a>00047         <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> unsused_bSubindex);
       
    53 <a name="l00048"></a>00048 
       
    54 <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>)
       
    55 <a name="l00056"></a>00056 {
       
    56 <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) ;
       
    57 <a name="l00058"></a>00058 }
       
    58 <a name="l00059"></a>00059 
       
    59 <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)
       
    60 <a name="l00070"></a>00070 {
       
    61 <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>);
       
    62 <a name="l00072"></a>00072         <span class="keywordflow">return</span> 0;
       
    63 <a name="l00073"></a>00073 }
       
    64 <a name="l00074"></a>00074 
       
    65 <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>)
       
    66 <a name="l00081"></a>00081 {
       
    67 <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>);
       
    68 <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>);
       
    69 <a name="l00084"></a>00084 
       
    70 <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){
       
    71 <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>);
       
    72 <a name="l00087"></a>00087         }
       
    73 <a name="l00088"></a>00088         
       
    74 <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>)
       
    75 <a name="l00090"></a>00090         {
       
    76 <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>(
       
    77 <a name="l00092"></a>00092                                 <a class="code" href="structstruct__s__timer__entry.html#1f47508e63fb89e692b98e178a78268f">d</a>,
       
    78 <a name="l00093"></a>00093                                 0 <span class="comment">/*No id needed*/</span>,
       
    79 <a name="l00094"></a>00094                                 &amp;<a class="code" href="sync_8c.html#4f6067ef03a5c85e07ddd817dd8d948f">SyncAlarm</a>,
       
    80 <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>), 
       
    81 <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>));
       
    82 <a name="l00097"></a>00097         }
       
    83 <a name="l00098"></a>00098 }
       
    84 <a name="l00099"></a>00099 
       
    85 <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>)
       
    86 <a name="l00106"></a>00106 {
       
    87 <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>);
       
    88 <a name="l00108"></a>00108 }
       
    89 <a name="l00109"></a>00109 
       
    90 <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)
       
    91 <a name="l00119"></a>00119 {
       
    92 <a name="l00120"></a>00120   <a class="code" href="structMessage.html">Message</a> m;
       
    93 <a name="l00121"></a>00121   <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> resultat ;
       
    94 <a name="l00122"></a>00122   
       
    95 <a name="l00123"></a>00123   <a class="code" href="hcs12_2applicfg_8h.html#d5dffc889e623fbc4f635e69276cdf20">MSG_WAR</a>(0x3001, <span class="stringliteral">"sendSYNC "</span>, 0);
       
    96 <a name="l00124"></a>00124   
       
    97 <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 ;
       
    98 <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>;
       
    99 <a name="l00127"></a>00127   m.<a class="code" href="structMessage.html#a8c32de83f67079897508203c8e2198c">len</a> = 0;
       
   100 <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) ;
       
   101 <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) ; 
       
   102 <a name="l00130"></a>00130   <span class="keywordflow">return</span> resultat ;
       
   103 <a name="l00131"></a>00131 }
       
   104 <a name="l00132"></a>00132 
       
   105 <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)
       
   106 <a name="l00142"></a>00142 {
       
   107 <a name="l00143"></a>00143 
       
   108 <a name="l00144"></a>00144   <a class="code" href="hcs12_2applicfg_8h.html#c2e754635928189b98cf3f5b7e6dbffb">UNS8</a> res;
       
   109 <a name="l00145"></a>00145   
       
   110 <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);
       
   111 <a name="l00147"></a>00147   
       
   112 <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>)();
       
   113 <a name="l00149"></a>00149 
       
   114 <a name="l00150"></a>00150   <span class="comment">/* only operational state allows PDO transmission */</span>
       
   115 <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>) 
       
   116 <a name="l00152"></a>00152     <span class="keywordflow">return</span> 0;
       
   117 <a name="l00153"></a>00153 
       
   118 <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> );
       
   119 <a name="l00155"></a>00155   
       
   120 <a name="l00156"></a>00156   <span class="comment">/*Call user app callback*/</span>
       
   121 <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>)();
       
   122 <a name="l00158"></a>00158   
       
   123 <a name="l00159"></a>00159   <span class="keywordflow">return</span> res;
       
   124 <a name="l00160"></a>00160   
       
   125 <a name="l00161"></a>00161 }
       
   126 <a name="l00162"></a>00162 
       
   127 <a name="l00163"></a>00163 
       
   128 <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>(){}
       
   129 <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>(){}
       
   130 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Jul 2 19:10:16 2007 for CanFestival by&nbsp;
       
   131 <a href="http://www.doxygen.org/index.html">
       
   132 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
       
   133 </body>
       
   134 </html>