📄 uart_8c.html
字号:
<td class="md" nowrap valign="top"> void uart_SendByte </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned char </td> <td class="mdname1" valign="top" nowrap> <em>data</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>send a byte. <p>Puts a byte in TX buffer and starts uart TX interrupt. If TX buffer is full it will hang until space.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>data</em> </td><td>Data to be sent. </td></tr> </table></dl><p>Definition at line <a class="el" href="uart_8c-source.html#l00073">73</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>References <a class="el" href="uart_8h-source.html#l00036">SET_UDRIE</a>, and <a class="el" href="uart_8h-source.html#l00031">UART_TX_BUFFER_MASK</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00173">ShowHelp()</a>, <a class="el" href="uart_8c-source.html#l00146">UART_RX_interrupt()</a>, <a class="el" href="uart_8c-source.html#l00111">uart_SendInt()</a>, and <a class="el" href="uart_8c-source.html#l00097">uart_SendString()</a>.<p><pre class="fragment"><div>00074 {00075 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> tmphead;00076 00077 <span class="comment">// Calculate buffer index</span>00078 tmphead = ( UART_TxHead + 1 ) & <a class="code" href="uart_8h.html#a3">UART_TX_BUFFER_MASK</a>;00079 <span class="comment">// Wait for free space in buffer</span>00080 <span class="keywordflow">while</span> ( tmphead == UART_TxTail )00081 ;00082 <span class="comment">// Store data in buffer</span>00083 UART_TxBuffer[tmphead] = data;00084 <span class="comment">// Store new index</span>00085 UART_TxHead = tmphead;00086 <span class="comment">// Enable UDRE interrupt</span>00087 <a class="code" href="uart_8h.html#a4">SET_UDRIE</a>;00088 }</div></pre> </td> </tr></table><a class="anchor" name="a9" doxytag="uart.c::uart_SendInt" ></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 uart_SendInt </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname1" valign="top" nowrap> <em>x</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Sends a integer. <p>Converts a integer to ASCII and sends it using uart_SendByte. If TX buffer is full it will hang until space.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>x</em> </td><td>Integer to be sent. </td></tr> </table></dl><p>Definition at line <a class="el" href="uart_8c-source.html#l00111">111</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>References <a class="el" href="uart_8c-source.html#l00073">uart_SendByte()</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00190">ShowData()</a>.<p><pre class="fragment"><div>00112 {00113 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> dec[] = <span class="stringliteral">"0123456789"</span>;00114 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> div_val = 10000;00115 00116 <span class="keywordflow">if</span> (x < 0){00117 x = - x;00118 <a class="code" href="uart_8h.html#a8">uart_SendByte</a>(<span class="charliteral">'-'</span>);00119 }00120 <span class="keywordflow">while</span> (div_val > 1 && div_val > x)00121 div_val /= 10;00122 <span class="keywordflow">do</span>{00123 <a class="code" href="uart_8h.html#a8">uart_SendByte</a> (dec[x / div_val]);00124 x %= div_val;00125 div_val /= 10;00126 }<span class="keywordflow">while</span>(div_val);00127 }</div></pre><p>Here is the call graph for this function:<p><center><img src="uart_8c_a9_cgraph.png" border="0" usemap="#uart_8c_a9_cgraph_map" alt=""></center><map name="uart_8c_a9_cgraph_map"><area href="uart_8h.html#a8" shape="rect" coords="155,7,264,33" alt=""></map> </td> </tr></table><a class="anchor" name="a8" doxytag="uart.c::uart_SendString" ></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 uart_SendString </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned char </td> <td class="mdname1" valign="top" nowrap> <em>Str</em>[] </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Sends a string. <p>Loops thru a string and send each byte with uart_SendByte. If TX buffer is full it will hang until space.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>Str</em> </td><td>String to be sent. </td></tr> </table></dl><p>Definition at line <a class="el" href="uart_8c-source.html#l00097">97</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>References <a class="el" href="uart_8c-source.html#l00073">uart_SendByte()</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00062">main()</a>, and <a class="el" href="main_8c-source.html#l00190">ShowData()</a>.<p><pre class="fragment"><div>00098 {00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> n = 0;00100 <span class="keywordflow">while</span>(Str[n])00101 <a class="code" href="uart_8h.html#a8">uart_SendByte</a>(Str[n++]);00102 }</div></pre><p>Here is the call graph for this function:<p><center><img src="uart_8c_a8_cgraph.png" border="0" usemap="#uart_8c_a8_cgraph_map" alt=""></center><map name="uart_8c_a8_cgraph_map"><area href="uart_8h.html#a8" shape="rect" coords="176,7,285,33" alt=""></map> </td> </tr></table><a class="anchor" name="a12" doxytag="uart.c::UART_TX_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 UART_TX_interrupt </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>TX interrupt handler. <p>TX interrupt handler. TX interrupt turned on by uart_SendByte, turned off when TX buffer is empty. <p>Definition at line <a class="el" href="uart_8c-source.html#l00200">200</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>References <a class="el" href="uart_8h-source.html#l00037">CLR_UDRIE</a>, and <a class="el" href="uart_8h-source.html#l00031">UART_TX_BUFFER_MASK</a>.<p><pre class="fragment"><div>00201 {00202 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> UART_TxTail_tmp;00203 UART_TxTail_tmp = UART_TxTail;00204 00205 <span class="comment">// Check if all data is transmitted</span>00206 <span class="keywordflow">if</span> ( UART_TxHead != UART_TxTail_tmp )00207 {00208 <span class="comment">// Calculate buffer index</span>00209 UART_TxTail_tmp = ( UART_TxTail + 1 ) & <a class="code" href="uart_8h.html#a3">UART_TX_BUFFER_MASK</a>;00210 <span class="comment">// Store new index</span>00211 UART_TxTail = UART_TxTail_tmp;00212 <span class="comment">// Start transmition</span>00213 UDR0= UART_TxBuffer[ UART_TxTail_tmp];00214 }00215 <span class="keywordflow">else</span>00216 <span class="comment">// Disable UDRE interrupt</span>00217 <a class="code" href="uart_8h.html#a5">CLR_UDRIE</a>;00218 }</div></pre> </td> </tr></table><hr><h2>Variable Documentation</h2><a class="anchor" name="a1" doxytag="uart.c::UART_RxBuffer" ></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"> unsigned char <a class="el" href="uart_8h.html#a6">UART_RxBuffer</a>[UART_RX_BUFFER_SIZE] </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Buffer with received string from uart. <p><p>Definition at line <a class="el" href="uart_8c-source.html#l00027">27</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00062">main()</a>, <a class="el" href="uart_8c-source.html#l00135">uart_FlushRxBuffer()</a>, and <a class="el" href="uart_8c-source.html#l00146">UART_RX_interrupt()</a>. </td> </tr></table><a class="anchor" name="a2" doxytag="uart.c::UART_RxPtr" ></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"> unsigned char <a class="el" href="uart_8c.html#a2">UART_RxPtr</a> </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>RX buffer pointer. <p><p>Definition at line <a class="el" href="uart_8c-source.html#l00029">29</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>Referenced by <a class="el" href="uart_8c-source.html#l00045">InitUART()</a>, <a class="el" href="uart_8c-source.html#l00135">uart_FlushRxBuffer()</a>, and <a class="el" href="uart_8c-source.html#l00146">UART_RX_interrupt()</a>. </td> </tr></table><hr size="1"><address style="align: right;"><small>Generated on Mon May 8 15:05:04 2006 for AVR446 - Linear speed control of stepper motor by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -