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

📄 uart_8h.html

📁 使用AVR单片机控制步进电机的软件代码
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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>AVR446 - Linear speed control of stepper motor: uart.h File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div><h1>uart.h File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>Header file for <a class="el" href="uart_8c.html">uart.c</a>. <p><ul><li>File: <a class="el" href="uart_8h.html">uart.h</a></li><li>Compiler: IAR EWAAVR 4.11A</li><li>Supported devices: All devices with a 16 bit timer can be used. The example is written for ATmega48</li><li>AppNote: AVR446 - Linear speed control of stepper motor</li></ul><p><dl compact><dt><b>Author:</b></dt><dd>Atmel Corporation: <a href="http://www.atmel.com">http://www.atmel.com</a> <br> Support email: <a href="mailto:avr@atmel.com">avr@atmel.com</a></dd></dl><dl compact><dt><b>Name</b></dt><dd>RELEASE_1_0 </dd></dl><dl compact><dt><b>Revision</b></dt><dd>1.2 </dd></dl><dl compact><dt><b>RCSfile</b></dt><dd><a class="el" href="uart_8h.html">uart.h</a>,v </dd></dl><dl compact><dt><b>Date</b></dt><dd>2006/05/08 12:25:58 </dd></dl><p>Definition in file <a class="el" href="uart_8h-source.html">uart.h</a>.<p><p>This graph shows which files directly or indirectly include this file:<p><center><img src="uart_8h__dep__incl.png" border="0" usemap="#uart.hdep_map" alt="Included by dependency graph"></center><map name="uart.hdep_map"><area href="main_8c.html" shape="rect" coords="7,7,68,34" alt=""><area href="speed__cntr_8c.html" shape="rect" coords="92,7,188,34" alt=""><area href="uart_8c.html" shape="rect" coords="212,7,268,34" alt=""></map><p><a href="uart_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Defines</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a5">CLR_UDRIE</a>&nbsp;&nbsp;&nbsp;(UCSR0B &amp;= ~(1&lt;&lt;UDRIE0))</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a4">SET_UDRIE</a>&nbsp;&nbsp;&nbsp;(UCSR0B |=  (1&lt;&lt;UDRIE0))</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a1">UART_RX_BUFFER_MASK</a>&nbsp;&nbsp;&nbsp;( UART_RX_BUFFER_SIZE - 1 )</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a0">UART_RX_BUFFER_SIZE</a>&nbsp;&nbsp;&nbsp;32</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a3">UART_TX_BUFFER_MASK</a>&nbsp;&nbsp;&nbsp;( UART_TX_BUFFER_SIZE - 1 )</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a2">UART_TX_BUFFER_SIZE</a>&nbsp;&nbsp;&nbsp;64</td></tr><tr><td colspan=2><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a7">InitUART</a> (void)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Init of uart.  <a href="#a7"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a11">uart_FlushRxBuffer</a> (void)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Empties the uart RX buffer.  <a href="#a11"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>__interrupt void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a12">UART_RX_interrupt</a> (void)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">RX interrupt handler.  <a href="#a12"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a8">uart_SendByte</a> (unsigned char data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">send a byte.  <a href="#a8"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a10">uart_SendInt</a> (int Tall)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sends a integer.  <a href="#a10"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a9">uart_SendString</a> (unsigned char Tab[])</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sends a string.  <a href="#a9"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>__interrupt void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a13">UART_TX_interrupt</a> (void)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">TX interrupt handler.  <a href="#a13"></a><br><br></td></tr><tr><td colspan=2><br><h2>Variables</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="uart_8h.html#a6">UART_RxBuffer</a> [UART_RX_BUFFER_SIZE]</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Buffer with received string from uart.  <a href="#a6"></a><br><br></td></tr></table><hr><h2>Define Documentation</h2><a class="anchor" name="a5" doxytag="uart.h::CLR_UDRIE" ></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"> #define CLR_UDRIE&nbsp;&nbsp;&nbsp;(UCSR0B &amp;= ~(1&lt;&lt;UDRIE0))          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="uart_8h-source.html#l00037">37</a> of file <a class="el" href="uart_8h-source.html">uart.h</a>.<p>Referenced by <a class="el" href="uart_8c-source.html#l00200">UART_TX_interrupt()</a>.    </td>  </tr></table><a class="anchor" name="a4" doxytag="uart.h::SET_UDRIE" ></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"> #define SET_UDRIE&nbsp;&nbsp;&nbsp;(UCSR0B |=  (1&lt;&lt;UDRIE0))          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="uart_8h-source.html#l00036">36</a> of file <a class="el" href="uart_8h-source.html">uart.h</a>.<p>Referenced by <a class="el" href="uart_8c-source.html#l00073">uart_SendByte()</a>.    </td>  </tr></table><a class="anchor" name="a1" doxytag="uart.h::UART_RX_BUFFER_MASK" ></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"> #define UART_RX_BUFFER_MASK&nbsp;&nbsp;&nbsp;( UART_RX_BUFFER_SIZE - 1 )          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="uart_8h-source.html#l00025">25</a> of file <a class="el" href="uart_8h-source.html">uart.h</a>.    </td>  </tr></table><a class="anchor" name="a0" doxytag="uart.h::UART_RX_BUFFER_SIZE" ></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"> #define UART_RX_BUFFER_SIZE&nbsp;&nbsp;&nbsp;32          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="uart_8h-source.html#l00024">24</a> of file <a class="el" href="uart_8h-source.html">uart.h</a>.<p>Referenced by <a class="el" href="uart_8c-source.html#l00146">UART_RX_interrupt()</a>.    </td>  </tr></table><a class="anchor" name="a3" doxytag="uart.h::UART_TX_BUFFER_MASK" ></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"> #define UART_TX_BUFFER_MASK&nbsp;&nbsp;&nbsp;( UART_TX_BUFFER_SIZE - 1 )          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="uart_8h-source.html#l00031">31</a> of file <a class="el" href="uart_8h-source.html">uart.h</a>.<p>Referenced by <a class="el" href="uart_8c-source.html#l00073">uart_SendByte()</a>, and <a class="el" href="uart_8c-source.html#l00200">UART_TX_interrupt()</a>.    </td>  </tr></table><a class="anchor" name="a2" doxytag="uart.h::UART_TX_BUFFER_SIZE" ></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"> #define UART_TX_BUFFER_SIZE&nbsp;&nbsp;&nbsp;64          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="uart_8h-source.html#l00030">30</a> of file <a class="el" href="uart_8h-source.html">uart.h</a>.    </td>  </tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="a7" doxytag="uart.h::InitUART" ></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 InitUART           </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>Init of uart. <p>Setup uart. The <a class="el" href="uart_8c.html#a0">BAUD</a> value must be modified according to clock frqequency. Refer to datasheet for details. <p>Definition at line <a class="el" href="uart_8c-source.html#l00045">45</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>References <a class="el" href="uart_8c.html#a0">BAUD</a>, and <a class="el" href="uart_8c-source.html#l00029">UART_RxPtr</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00042">Init()</a>.<p><pre class="fragment"><div>00046 {00047   <span class="comment">// Set baud rate. 19.2 kbps trasfer speed running at 8 MHz.</span>00048 <span class="comment">//#define BAUD 25</span>00049   <span class="comment">// Set baud rate. 19.2 kbps trasfer speed running at 3.6864 MHz.</span>00050 <span class="preprocessor">#define BAUD 11</span>00051 <span class="preprocessor"></span>00052   UBRR0H = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>)(<a class="code" href="uart_8c.html#a0">BAUD</a>&gt;&gt;8);00053   UBRR0L = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>)<a class="code" href="uart_8c.html#a0">BAUD</a>;00054   <span class="comment">/* Enable receiver and transmitter, rx and tx int */</span>00055   UCSR0B = (1&lt;&lt;RXEN0)|(1&lt;&lt;TXEN0)|(1&lt;&lt;RXCIE0)|(1&lt;&lt;TXCIE0);00056   <span class="comment">/* Set frame format: 8data, 1stop bit */</span>00057   UCSR0C = (3&lt;&lt;UCSZ00);00058 00059   <span class="comment">// Flush Buffers</span>00060   <a class="code" href="uart_8c.html#a2">UART_RxPtr</a> = 0;00061   UART_TxTail = 0;00062   UART_TxHead = 0;00063 }</div></pre>    </td>  </tr></table><a class="anchor" name="a11" doxytag="uart.h::uart_FlushRxBuffer" ></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_FlushRxBuffer           </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>Empties the uart RX buffer. <p>Empties the uart RX buffer.<p><dl compact><dt><b>Returns:</b></dt><dd>x Integer to be sent. </dd></dl><p>Definition at line <a class="el" href="uart_8c-source.html#l00135">135</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.<p>References <a class="el" href="uart_8c-source.html#l00027">UART_RxBuffer</a>, and <a class="el" href="uart_8c-source.html#l00029">UART_RxPtr</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00062">main()</a>.<p><pre class="fragment"><div>00135                              {00136   <a class="code" href="uart_8c.html#a2">UART_RxPtr</a> = 0;00137   <a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[<a class="code" href="uart_8c.html#a2">UART_RxPtr</a>] = 0;00138 }</div></pre>    </td>  </tr></table><a class="anchor" name="a12" doxytag="uart.h::UART_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 UART_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>

⌨️ 快捷键说明

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