⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avrgsm__com_8c.html

📁 SMS傳送Sourcode,compiler with C,AT command
💻 HTML
📖 第 1 页 / 共 4 页
字号:
  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> void COM_rx_reset           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Reset receive interrupt. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>void</em>&nbsp;</td><td></td></tr>  </table></dl><dl compact><dt><b>Return values:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>void</em>&nbsp;</td><td></td></tr>  </table></dl><p>Definition at line <a class="el" href="AVRGSM__com_8c-source.html#l00085">85</a> of file <a class="el" href="AVRGSM__com_8c-source.html">AVRGSM_com.c</a>.<p>References <a class="el" href="AVRGSM__api_8c-source.html#l00039">rx_ack</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00037">rx_buffer</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00043">rx_i</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00034">rx_overflow</a>, and <a class="el" href="AVRGSM__com_8c-source.html#l00046">rx_wr_i</a>.<p>Referenced by <a class="el" href="AVRGSM__api_8c-source.html#l00278">API_check_acknowledge()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00125">API_deletemsg()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00073">API_modem_init()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00232">API_readmsg()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00160">API_sendmsg()</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00066">COM_init()</a>, <a class="el" href="STATE__functions_8c-source.html#l00118">ST_delete_msg()</a>, <a class="el" href="STATE__functions_8c-source.html#l00051">ST_init_phone()</a>, and <a class="el" href="STATE__functions_8c-source.html#l00158">ST_read()</a>.<p><pre class="fragment"><div>00086 {00087 00088     UCSR0B &amp;= ~(1&lt;&lt;RXCIE0);       <span class="comment">// Disable RX interrupt</span>00089     <a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a> = <a class="code" href="AVRGSM__com_8c.html#a5">rx_wr_i</a> = 0;           <span class="comment">//Init variables</span>00090     <a class="code" href="AVRGSM__com_8c.html#a0">rx_overflow</a> = <a class="code" href="AVRGSM__api_8c.html#a0">rx_ack</a> = 0;     <span class="comment">//Zero overflow flag</span>00091     <a class="code" href="AVRGSM__com_8c.html#a2">rx_buffer</a>[ <a class="code" href="AVRGSM__com_8c.html#a5">rx_wr_i</a> ] = <span class="charliteral">'\0'</span>;  <span class="comment">//Buffer init.</span>00092 }</div></pre>    </td>  </tr></table><a class="anchor" name="a16" doxytag="AVRGSM_com.c::COM_setSearchString" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> void COM_setSearchString           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">unsigned char&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>Response</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Set desired search string. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>void</em>&nbsp;</td><td></td></tr>  </table></dl><dl compact><dt><b>Return values:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>void</em>&nbsp;</td><td></td></tr>  </table></dl><p>Definition at line <a class="el" href="AVRGSM__com_8c-source.html#l00127">127</a> of file <a class="el" href="AVRGSM__com_8c-source.html">AVRGSM_com.c</a>.<p>References <a class="el" href="AVRGSM__com_8c-source.html#l00043">rx_i</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00053">searchFor</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00040">searchStr</a>, and <a class="el" href="AVRGSM__com_8c-source.html#l00054">searchStrings</a>.<p>Referenced by <a class="el" href="AVRGSM__api_8c-source.html#l00125">API_deletemsg()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00073">API_modem_init()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00232">API_readmsg()</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00160">API_sendmsg()</a>, <a class="el" href="STATE__functions_8c-source.html#l00118">ST_delete_msg()</a>, <a class="el" href="STATE__functions_8c-source.html#l00051">ST_init_phone()</a>, and <a class="el" href="STATE__functions_8c-source.html#l00158">ST_read()</a>.<p><pre class="fragment"><div>00128 {00129 00130     UCSR0B &amp;= ~( 1 &lt;&lt; RXCIE0 );           <span class="comment">// Disable RX interrupt</span>00131     <a class="code" href="AVRGSM__com_8c.html#a10">searchFor</a> = <a class="code" href="AVRGSM__com_8c.html#a11">searchStrings</a>[Response];  <span class="comment">//Set desired search dtring</span>00132     <a class="code" href="AVRGSM__com_8c.html#a3">searchStr</a> = Response;                 <span class="comment">//Used in rx_isr</span>00133     <a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a> = 0;00134 }</div></pre>    </td>  </tr></table><a class="anchor" name="a22" doxytag="AVRGSM_com.c::COM_trim" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> int COM_trim           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Remove trailing O, K,  and <br>. <p>If the receive buffer have trailing "OK\r\n" These characters will be deleted.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>void</em>&nbsp;</td><td></td></tr>  </table></dl><dl compact><dt><b>Return values:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>i</em>&nbsp;</td><td>Length of trimmed buffer</td></tr>  </table></dl><p>Local variables <p>Definition at line <a class="el" href="AVRGSM__com_8c-source.html#l00289">289</a> of file <a class="el" href="AVRGSM__com_8c-source.html">AVRGSM_com.c</a>.<p>References <a class="el" href="AVRGSM__com_8c-source.html#l00037">rx_buffer</a>, and <a class="el" href="AVRGSM__com_8c-source.html#l00046">rx_wr_i</a>.<p>Referenced by <a class="el" href="AVRGSM__tools_8c-source.html#l00080">TOOLS__decodeCMGR()</a>, and <a class="el" href="AVRGSM__tools_8c-source.html#l00039">TOOLS_decodeCMTI()</a>.<p><pre class="fragment"><div>00290 {00291 00293     <span class="keywordtype">int</span> i;00294     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> temp;00295 00296     <span class="keywordflow">for</span>( i = <a class="code" href="AVRGSM__com_8c.html#a5">rx_wr_i</a> - 1; i &gt;= 0; i--)                                                      <span class="comment">//Run through COM_in[] backwards</span>00297     {00298         temp = <a class="code" href="AVRGSM__com_8c.html#a2">rx_buffer</a>[i];                                                                <span class="comment">//rx_buff[i] into temp</span>00299         <span class="keywordflow">if</span>( ( temp != <span class="charliteral">'\r'</span> ) &amp;&amp; ( temp != <span class="charliteral">'\n'</span> ) &amp;&amp; ( temp != <span class="charliteral">'O'</span> ) &amp;&amp; ( temp != <span class="charliteral">'K'</span> ) )    <span class="comment">//If not equal to 'O', 'K', '\r' or '\n', break</span>00300         {00301             <span class="keywordflow">break</span>;                                                                          <span class="comment">//Do break</span>00302         }00303     }00304 00305     <a class="code" href="AVRGSM__com_8c.html#a2">rx_buffer</a>[ i+1 ] = <span class="charliteral">'\0'</span>;                                                                <span class="comment">//Terminate trimmed string</span>00306 00307     <span class="keywordflow">return</span> i;                                                                               <span class="comment">//Return new length</span>00308 }</div></pre>    </td>  </tr></table><a class="anchor" name="a17" doxytag="AVRGSM_com.c::USART0_RX_interrupt" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> __interrupt void USART0_RX_interrupt           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Receive interrupt routine. <p>This receive routine buffer incomming messages from the connected GSM modem But also check if the received string was a acknowledge <p>Definition at line <a class="el" href="AVRGSM__com_8c-source.html#l00143">143</a> of file <a class="el" href="AVRGSM__com_8c-source.html">AVRGSM_com.c</a>.<p>References <a class="el" href="splint_8h-source.html#l00025">__interrupt</a>, <a class="el" href="AVRGSM__com_8h-source.html#l00030">CMTI_</a>, <a class="el" href="AVRGSM__com_8h-source.html#l00032">CRLF_</a>, <a class="el" href="AVRGSM__api_8c-source.html#l00039">rx_ack</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00037">rx_buffer</a>, <a class="el" href="AVRGSM__com_8h-source.html#l00027">RX_BUFFER_MASK</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00043">rx_i</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00034">rx_overflow</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00046">rx_wr_i</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00053">searchFor</a>, <a class="el" href="AVRGSM__com_8c-source.html#l00040">searchStr</a>, and <a class="el" href="AVRGSM__com_8c-source.html#l00054">searchStrings</a>.<p><pre class="fragment"><div>00144 {00145 00146     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data;                             <span class="comment">//Local variable</span>00147 00148     data = UDR0;                                    <span class="comment">//Always read something</span>00149 00150     <a class="code" href="AVRGSM__com_8c.html#a2">rx_buffer</a>[ <a class="code" href="AVRGSM__com_8c.html#a5">rx_wr_i</a>++ ] = data;                  <span class="comment">//Store new data</span>00151 00152 00153     <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__com_8c.html#a5">rx_wr_i</a> &gt; <a class="code" href="AVRGSM__com_8h.html#a1">RX_BUFFER_MASK</a> )                  <span class="comment">//Check for overflow</span>00154     {00155         <a class="code" href="AVRGSM__com_8c.html#a5">rx_wr_i</a> = 0;                                <span class="comment">//Reset write index</span>00156         <a class="code" href="AVRGSM__com_8c.html#a0">rx_overflow</a> = 1;                            <span class="comment">//Set flag high</span>00157         UCSR0B &amp;= ~( 1 &lt;&lt; RXCIE0 );                 <span class="comment">// Disable RX interrupt</span>00158     }00159 00160     <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__com_8c.html#a10">searchFor</a>[<a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a>] == data )                   <span class="comment">//Test response match</span>00161     {00162         <a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a>++;00163 00164         <span class="keywordflow">if</span>( !<a class="code" href="AVRGSM__com_8c.html#a10">searchFor</a>[<a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a>] )                      <span class="comment">//End of new_message string...received new message!</span>00165         {00166             <a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a> = 0;00167 00168             <span class="keywordflow">if</span>( <a class="code" href="AVRGSM__com_8c.html#a3">searchStr</a> == <a class="code" href="AVRGSM__com_8h.html#a4">CMTI_</a> )                <span class="comment">//+CMTI:</span>00169             {00170                 <a class="code" href="AVRGSM__com_8c.html#a10">searchFor</a> = <a class="code" href="AVRGSM__com_8c.html#a11">searchStrings</a>[ <a class="code" href="AVRGSM__com_8h.html#a6">CRLF_</a> ]; <span class="comment">//Wait for</span>00171                 <a class="code" href="AVRGSM__com_8c.html#a3">searchStr</a> = <a class="code" href="AVRGSM__com_8h.html#a6">CRLF_</a>;00172             }00173 00174             <span class="keywordflow">else</span>                                    <span class="comment">//Normal acknowledgement</span>00175             {00176                 <a class="code" href="AVRGSM__api_8c.html#a0">rx_ack</a> = 1;                         <span class="comment">//Set new message flag</span>00177                 UCSR0B &amp;= ~( 1 &lt;&lt; RXCIE0 );         <span class="comment">// Disable RX interrupt</span>00178             }00179         }00180     }00181 00182     <span class="keywordflow">else</span>00183     {00184         <a class="code" href="AVRGSM__com_8c.html#a4">rx_i</a> = 0;                                   <span class="comment">//Not valid search pattern...start again.</span>00185     }00186 }</div></pre>    </td>  </tr></table><hr><h2>Variable Documentation</h2><a class="anchor" name="a7" doxytag="AVRGSM_com.c::CMTI" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> const unsigned char __flash <a class="el" href="AVRGSM__com_8c.html#a7">CMTI</a>[] = "+CMTI: "          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>New Message arrived. <p><p>Definition at line <a class="el" href="AVRGSM__com_8c-source.html#l00050">50</a> of file <a class="el" href="AVRGSM__com_8c-source.html">AVRGSM_com.c</a>.    </td>  </tr></table><a class="anchor" name="a9" doxytag="AVRGSM_com.c::CR_LF" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> const unsigned char __flash <a class="el" href="AVRGSM__com_8c.html#a9">CR_LF</a>[] = "\r\n"          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -