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

📄 usart__example_8c-source.html

📁 avr32100.zip Embedded demo
💻 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>AVR321000 Communication with the AVR32 USART: usart_example.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="pages.html"><span>Related&nbsp;Pages</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><h1>usart_example.c</h1><a href="usart__example_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*This file has been prepared for Doxygen automatic documentation generation.*/</span><a name="l00023"></a>00023 <span class="comment">/* ************************************************************************</span><a name="l00024"></a>00024 <span class="comment"></span><a name="l00025"></a>00025 <span class="comment">Copyright (c) 2006, Atmel Corporation All rights reserved. </span><a name="l00026"></a>00026 <span class="comment"></span><a name="l00027"></a>00027 <span class="comment">Redistribution and use in source and binary forms, with or without</span><a name="l00028"></a>00028 <span class="comment">modification, are permitted provided that the following conditions are met:</span><a name="l00029"></a>00029 <span class="comment"></span><a name="l00030"></a>00030 <span class="comment">1. Redistributions of source code must retain the above copyright notice,</span><a name="l00031"></a>00031 <span class="comment">this list of conditions and the </span><a name="l00032"></a>00032 <span class="comment">following disclaimer. </span><a name="l00033"></a>00033 <span class="comment"></span><a name="l00034"></a>00034 <span class="comment">2. Redistributions in binary form must reproduce the above copyright notice,</span><a name="l00035"></a>00035 <span class="comment">this list of conditions and the following disclaimer in the documentation</span><a name="l00036"></a>00036 <span class="comment">and/or other materials provided with the distribution.</span><a name="l00037"></a>00037 <span class="comment"></span><a name="l00038"></a>00038 <span class="comment">3. The name of ATMEL may not be used to endorse or promote products </span><a name="l00039"></a>00039 <span class="comment">derived from this software without specific prior written permission.  </span><a name="l00040"></a>00040 <span class="comment"></span><a name="l00041"></a>00041 <span class="comment">THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS </span><a name="l00042"></a>00042 <span class="comment">OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE </span><a name="l00043"></a>00043 <span class="comment">IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A </span><a name="l00044"></a>00044 <span class="comment">PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY </span><a name="l00045"></a>00045 <span class="comment">DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,</span><a name="l00046"></a>00046 <span class="comment">INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL </span><a name="l00047"></a>00047 <span class="comment">DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF </span><a name="l00048"></a>00048 <span class="comment">SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; </span><a name="l00049"></a>00049 <span class="comment">OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY </span><a name="l00050"></a>00050 <span class="comment">THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, </span><a name="l00051"></a>00051 <span class="comment">OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY </span><a name="l00052"></a>00052 <span class="comment">WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE </span><a name="l00053"></a>00053 <span class="comment"></span><a name="l00054"></a>00054 <span class="comment">POSSIBILITY OF SUCH DAMAGE. </span><a name="l00055"></a>00055 <span class="comment"></span><a name="l00056"></a>00056 <span class="comment">************************************************************************ */</span><a name="l00057"></a>00057 <a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="preprocessor">#include "<a class="code" href="usart_8h.html">usart.h</a>"</span><a name="l00060"></a>00060 <a name="l00061"></a><a class="code" href="usart__example_8c.html#a90cac659d18e8ef6294c7ae337f6b58">00061</a> <span class="preprocessor">#define SUCCESS 0;</span><a name="l00062"></a><a class="code" href="usart__example_8c.html#6d58f9ac447476b4e084d7ca383f5183">00062</a> <span class="preprocessor"></span><span class="preprocessor">#define FAILURE -1;</span><a name="l00063"></a>00063 <span class="preprocessor"></span><a name="l00064"></a><a class="code" href="usart__example_8c.html#8a26ea9b2ab943a38ada2d6ca9282231">00064</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="usart__example_8c.html#8a26ea9b2ab943a38ada2d6ca9282231">avr32_piomap_t</a>[][2];<a name="l00065"></a>00065 <a name="l00066"></a>00066 <span class="comment">/* used for printing strings */</span><a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="usart__example_8c.html#2929a2158663c710a90f2d760007397a">print</a>(<span class="keyword">volatile</span> <span class="keyword">struct</span> avr32_usart_t * usart, <span class="keywordtype">char</span> *str);<a name="l00068"></a>00068 <a name="l00069"></a>00069 <span class="comment">/* enable output on pins */</span><a name="l00070"></a>00070 <span class="keywordtype">int</span> <a class="code" href="usart__example_8c.html#0789f45a4ff69e0f650c2d3e2fdf35bb">pio_enable_module</a>(<a class="code" href="usart__example_8c.html#8a26ea9b2ab943a38ada2d6ca9282231">avr32_piomap_t</a> piomap, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size);<a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="comment">/*</span><a name="l00073"></a>00073 <span class="comment"></span><a name="l00074"></a>00074 <span class="comment">This example will display a string at the screen. Refer to the struct opt in main for </span><a name="l00075"></a>00075 <span class="comment">configuration options for your terminal.</span><a name="l00076"></a>00076 <span class="comment"></span><a name="l00077"></a>00077 <span class="comment">Please make sure that the correct jumper(s) is/are set on your development board. Consult your hardware reference </span><a name="l00078"></a>00078 <span class="comment">guide if in doubt.</span><a name="l00079"></a>00079 <span class="comment"></span><a name="l00080"></a>00080 <span class="comment">*/</span><a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="comment">/* This is a work around for the IAR EWAVR32, version 2.10B */</span><a name="l00083"></a>00083 <span class="preprocessor">#ifdef __ICCAVR32__</span><a name="l00084"></a>00084 <span class="preprocessor"></span><span class="preprocessor">#define AVR32_USART1_RXD_0_PIN      17</span><a name="l00085"></a>00085 <span class="preprocessor"></span><span class="preprocessor">#define AVR32_USART1_RXD_0_FUNCTION 0</span><a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#define AVR32_USART1_TXD_0_PIN      18</span><a name="l00087"></a>00087 <span class="preprocessor"></span><span class="preprocessor">#define AVR32_USART1_TXD_0_FUNCTION 0</span><a name="l00088"></a>00088 <span class="preprocessor"></span><span class="preprocessor">#endif</span><a name="l00089"></a>00089 <span class="preprocessor"></span><a name="l00090"></a>00090 <a name="l00096"></a><a class="code" href="usart__example_8c.html#840291bc02cba5474a4cb46a9b9566fe">00096</a> <span class="keywordtype">int</span> <a class="code" href="usart__example_8c.html#840291bc02cba5474a4cb46a9b9566fe">main</a>( <span class="keywordtype">void</span> )<a name="l00097"></a>00097 {<a name="l00098"></a>00098   <span class="keywordtype">int</span> cpu_hz = 20000000;

⌨️ 快捷键说明

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