亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uart_8c-source.html

?? ATMEL的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>Procyon AVRlib: uart.c Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</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></div><h1>uart.c</h1><a href="uart_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*! \file uart.c \brief UART driver with buffer support. */</span>00002 <span class="comment">// *****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name    : 'uart.c'</span>00005 <span class="comment">// Title        : UART driver with buffer support</span>00006 <span class="comment">// Author       : Pascal Stang - Copyright (C) 2000-2002</span>00007 <span class="comment">// Created      : 11/22/2000</span>00008 <span class="comment">// Revised      : 06/09/2003</span>00009 <span class="comment">// Version      : 1.3</span>00010 <span class="comment">// Target MCU   : ATMEL AVR Series</span>00011 <span class="comment">// Editor Tabs  : 4</span>00012 <span class="comment">//</span>00013 <span class="comment">// This code is distributed under the GNU Public License</span>00014 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>00015 <span class="comment">//</span>00016 <span class="comment">// *****************************************************************************</span>00017 00018 <span class="preprocessor">#include &lt;avr/io.h&gt;</span>00019 <span class="preprocessor">#include &lt;avr/interrupt.h&gt;</span>00020 <span class="preprocessor">#include &lt;avr/signal.h&gt;</span>00021 00022 <span class="preprocessor">#include "<a class="code" href="buffer_8h.html">buffer.h</a>"</span>00023 <span class="preprocessor">#include "<a class="code" href="uart_8h.html">uart.h</a>"</span>00024 00025 <span class="comment">// UART global variables</span>00026 <span class="comment">// flag variables</span><a name="l00027"></a><a class="code" href="uart_8c.html#a0">00027</a> <span class="keyword">volatile</span> u08   <a class="code" href="uart_8c.html#a0">uartReadyTx</a>;         <span class="comment">///&lt; uartReadyTx flag</span><a name="l00028"></a><a class="code" href="uart_8c.html#a1">00028</a> <span class="comment"></span><span class="keyword">volatile</span> u08   <a class="code" href="uart_8c.html#a1">uartBufferedTx</a>;      <span class="comment">///&lt; uartBufferedTx flag</span>00029 <span class="comment"></span><span class="comment">// receive and transmit buffers</span><a name="l00030"></a><a class="code" href="uart_8c.html#a2">00030</a> cBuffer <a class="code" href="uart_8c.html#a2">uartRxBuffer</a>;               <span class="comment">///&lt; uart receive buffer</span><a name="l00031"></a><a class="code" href="uart_8c.html#a3">00031</a> <span class="comment"></span>cBuffer <a class="code" href="uart_8c.html#a3">uartTxBuffer</a>;               <span class="comment">///&lt; uart transmit buffer</span><a name="l00032"></a><a class="code" href="uart_8c.html#a4">00032</a> <span class="comment"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="uart_8c.html#a4">uartRxOverflow</a>;      <span class="comment">///&lt; receive overflow counter</span>00033 <span class="comment"></span>00034 <span class="preprocessor">#ifndef UART_BUFFERS_EXTERNAL_RAM</span>00035 <span class="preprocessor"></span>    <span class="comment">// using internal ram,</span>00036     <span class="comment">// automatically allocate space in ram for each buffer</span>00037     <span class="keyword">static</span> <span class="keywordtype">char</span> uartRxData[<a class="code" href="uart_8h.html#a2">UART_RX_BUFFER_SIZE</a>];00038     <span class="keyword">static</span> <span class="keywordtype">char</span> uartTxData[<a class="code" href="uart_8h.html#a1">UART_TX_BUFFER_SIZE</a>];00039 <span class="preprocessor">#endif</span>00040 <span class="preprocessor"></span>00041 <span class="keyword">typedef</span> void (*voidFuncPtru08)(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>);00042 <span class="keyword">volatile</span> <span class="keyword">static</span> voidFuncPtru08 UartRxFunc;00043 <span class="comment"></span>00044 <span class="comment">//! enable and initialize the uart</span><a name="l00045"></a><a class="code" href="uart2_8h.html#a17">00045</a> <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="uart_8c.html#a9">uartInit</a>(<span class="keywordtype">void</span>)00046 {00047     <span class="comment">// initialize the buffers</span>00048     <a class="code" href="uart_8c.html#a10">uartInitBuffers</a>();00049     <span class="comment">// initialize user receive handler</span>00050     UartRxFunc = 0;00051 00052     <span class="comment">// enable RxD/TxD and interrupts</span>00053     outb(UCR, BV(RXCIE)|BV(TXCIE)|BV(RXEN)|BV(TXEN));00054 00055     <span class="comment">// set default baud rate</span>00056     <a class="code" href="uart2_8h.html#a23">uartSetBaudRate</a>(<a class="code" href="uart_8h.html#a0">UART_DEFAULT_BAUD_RATE</a>);  00057     <span class="comment">// initialize states</span>00058     <a class="code" href="uart_8c.html#a0">uartReadyTx</a> = TRUE;00059     <a class="code" href="uart_8c.html#a1">uartBufferedTx</a> = FALSE;00060     <span class="comment">// clear overflow count</span>00061     <a class="code" href="uart_8c.html#a4">uartRxOverflow</a> = 0;00062     <span class="comment">// enable interrupts</span>00063     sei();00064 }00065 <span class="comment"></span>00066 <span class="comment">//! create and initialize the uart transmit and receive buffers</span><a name="l00067"></a><a class="code" href="uart_8h.html#a4">00067</a> <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="uart_8c.html#a10">uartInitBuffers</a>(<span class="keywordtype">void</span>)00068 {00069 <span class="preprocessor">    #ifndef UART_BUFFERS_EXTERNAL_RAM</span>00070 <span class="preprocessor"></span>        <span class="comment">// initialize the UART receive buffer</span>00071         <a class="code" href="buffer_8h.html#a1">bufferInit</a>(&amp;<a class="code" href="uart_8c.html#a2">uartRxBuffer</a>, uartRxData, <a class="code" href="uart_8h.html#a2">UART_RX_BUFFER_SIZE</a>);00072         <span class="comment">// initialize the UART transmit buffer</span>00073         <a class="code" href="buffer_8h.html#a1">bufferInit</a>(&amp;<a class="code" href="uart_8c.html#a3">uartTxBuffer</a>, uartTxData, <a class="code" href="uart_8h.html#a1">UART_TX_BUFFER_SIZE</a>);00074 <span class="preprocessor">    #else</span>00075 <span class="preprocessor"></span>        <span class="comment">// initialize the UART receive buffer</span>00076         <a class="code" href="buffer_8h.html#a1">bufferInit</a>(&amp;<a class="code" href="uart_8c.html#a2">uartRxBuffer</a>, (u08*) UART_RX_BUFFER_ADDR, <a class="code" href="uart_8h.html#a2">UART_RX_BUFFER_SIZE</a>);00077         <span class="comment">// initialize the UART transmit buffer</span>00078         <a class="code" href="buffer_8h.html#a1">bufferInit</a>(&amp;<a class="code" href="uart_8c.html#a3">uartTxBuffer</a>, (u08*) UART_TX_BUFFER_ADDR, <a class="code" href="uart_8h.html#a1">UART_TX_BUFFER_SIZE</a>);00079 <span class="preprocessor">    #endif</span>00080 <span class="preprocessor"></span>}00081 <span class="comment"></span>00082 <span class="comment">//! redirects received data to a user function</span><a name="l00083"></a><a class="code" href="uart_8h.html#a6">00083</a> <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="uart2_8h.html#a22">uartSetRxHandler</a>(<span class="keywordtype">void</span> (*rx_func)(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c))00084 {00085     <span class="comment">// set the receive interrupt to run the supplied user function</span>00086     UartRxFunc = rx_func;00087 }00088 <span class="comment"></span>00089 <span class="comment">//! set the uart baud rate</span><a name="l00090"></a><a class="code" href="uart_8h.html#a7">00090</a> <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="uart2_8h.html#a23">uartSetBaudRate</a>(u32 baudrate)00091 {00092     <span class="comment">// calculate division factor for requested baud rate, and set it</span>00093     u16 bauddiv = ((F_CPU+(baudrate*8L))/(baudrate*16L)-1);00094     outb(UBRRL, bauddiv);00095 <span class="preprocessor">    #ifdef UBRRH</span>00096 <span class="preprocessor"></span>    outb(UBRRH, bauddiv&gt;&gt;8);00097 <span class="preprocessor">    #endif</span>00098 <span class="preprocessor"></span>}00099 <span class="comment"></span>00100 <span class="comment">//! returns the receive buffer structure </span><a name="l00101"></a><a class="code" href="uart_8h.html#a8">00101</a> <span class="comment"></span>cBuffer* <a class="code" href="uart_8c.html#a13">uartGetRxBuffer</a>(<span class="keywordtype">void</span>)00102 {00103     <span class="comment">// return rx buffer pointer</span>00104     <span class="keywordflow">return</span> &amp;<a class="code" href="uart_8c.html#a2">uartRxBuffer</a>;00105 }00106 <span class="comment"></span>00107 <span class="comment">//! returns the transmit buffer structure </span><a name="l00108"></a><a class="code" href="uart_8h.html#a9">00108</a> <span class="comment"></span>cBuffer* <a class="code" href="uart_8c.html#a14">uartGetTxBuffer</a>(<span class="keywordtype">void</span>)00109 {00110     <span class="comment">// return tx buffer pointer</span>00111     <span class="keywordflow">return</span> &amp;<a class="code" href="uart_8c.html#a3">uartTxBuffer</a>;00112 }00113 <span class="comment"></span>00114 <span class="comment">//! transmits a byte over the uart</span><a name="l00115"></a><a class="code" href="uart_8h.html#a10">00115</a> <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="uart2_8h.html#a26">uartSendByte</a>(u08 txData)00116 {00117     <span class="comment">// wait for the transmitter to be ready</span>00118     <span class="keywordflow">while</span>(!<a class="code" href="uart_8c.html#a0">uartReadyTx</a>);00119     <span class="comment">// send byte</span>00120     outp( txData, UDR );00121     <span class="comment">// set ready state to FALSE</span>00122     <a class="code" href="uart_8c.html#a0">uartReadyTx</a> = FALSE;00123 }00124 <span class="comment"></span>00125 <span class="comment">//! gets a single byte from the uart receive buffer (getchar-style)</span><a name="l00126"></a><a class="code" href="uart_8h.html#a11">00126</a> <span class="comment"></span><span class="keywordtype">int</span> <a class="code" href="uart_8c.html#a16">uartGetByte</a>(<span class="keywordtype">void</span>)00127 {00128     u08 c;00129     <span class="keywordflow">if</span>(<a class="code" href="uart2_8h.html#a31">uartReceiveByte</a>(&amp;c))00130         <span class="keywordflow">return</span> c;00131     <span class="keywordflow">else</span>00132         <span class="keywordflow">return</span> -1;00133 }00134 <span class="comment"></span>00135 <span class="comment">//! gets a byte (if available) from the uart receive buffer</span><a name="l00136"></a><a class="code" href="uart_8h.html#a12">00136</a> <span class="comment"></span>u08 <a class="code" href="uart2_8h.html#a31">uartReceiveByte</a>(u08* rxData)00137 {00138     <span class="comment">// make sure we have a receive buffer</span>00139     <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a2">uartRxBuffer</a>.size)00140     {00141         <span class="comment">// make sure we have data</span>00142         <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a2">uartRxBuffer</a>.datalength)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一级黄| 欧美日韩国产123区| 综合激情成人伊人| 欧美色图在线观看| 久久99精品网久久| 中文字幕av资源一区| 91福利资源站| 国产老肥熟一区二区三区| 有码一区二区三区| 欧美成va人片在线观看| 日韩一区二区三区av| 欧美日韩在线播放一区| 美女视频免费一区| 国产欧美一区二区三区在线老狼 | 国产精品欧美精品| 精品视频123区在线观看| 国产高清精品久久久久| 亚洲国产色一区| 国产婷婷色一区二区三区四区| 欧美无人高清视频在线观看| 91香蕉视频污| 激情久久久久久久久久久久久久久久| 亚洲色图欧美激情| 欧美精品一区二区蜜臀亚洲| 欧美日韩免费高清一区色橹橹| 成人午夜伦理影院| 久久国产精品一区二区| 亚洲va韩国va欧美va| 国产精品美女久久久久久久久久久 | 五月激情丁香一区二区三区| 成人欧美一区二区三区在线播放| 欧美videos大乳护士334| 在线亚洲+欧美+日本专区| 国产99一区视频免费| 麻豆专区一区二区三区四区五区| 亚洲一区二区三区四区在线免费观看| 日本一区二区三区国色天香 | 欧美亚洲国产bt| www.av精品| 国产福利精品导航| 韩日精品视频一区| 日本亚洲免费观看| 自拍偷拍国产亚洲| 国产日韩精品一区二区三区在线| 欧美一区二区成人6969| 日本高清不卡在线观看| 国产精品888| 午夜欧美在线一二页| 一区二区三区欧美在线观看| 国产精品激情偷乱一区二区∴| 久久色在线观看| 日韩女优视频免费观看| 欧美一区二区三区影视| 欧美一区二区三区免费视频 | 日韩欧美国产成人一区二区| 日本道在线观看一区二区| 97超碰欧美中文字幕| a亚洲天堂av| 国产乱淫av一区二区三区| 视频一区在线播放| 亚洲国产成人av| 亚洲欧美日韩一区二区| 亚洲婷婷国产精品电影人久久| 国产精品初高中害羞小美女文| 国产精品美女久久久久久久 | 日韩欧美国产一区二区三区 | 久久久亚洲欧洲日产国码αv| 精品成人一区二区三区| 精品国产三级电影在线观看| 精品美女一区二区| 久久精品人人做人人综合 | 中文字幕第一区综合| 国产精品久久久久久久久久久免费看| 国产精品乱子久久久久| 午夜成人在线视频| 免费的成人av| 风间由美性色一区二区三区| 成人h动漫精品| 东方欧美亚洲色图在线| 91国在线观看| 欧美一区三区四区| 日本一区二区综合亚洲| 亚洲激情图片一区| 欧美精品一区二区久久婷婷| 亚洲天堂福利av| 亚洲成人资源在线| 国产成人免费xxxxxxxx| 色综合天天综合在线视频| 欧美精品一区二区在线播放| 欧美va亚洲va香蕉在线| 国产精品你懂的在线欣赏| 国产精品无人区| 亚洲国产乱码最新视频| 麻豆免费精品视频| 99免费精品视频| 91精品国产色综合久久ai换脸| 久久综合久久99| 一区二区三区小说| 精品午夜久久福利影院| av成人免费在线观看| 91麻豆精品国产91| 国产精品色哟哟| 免费黄网站欧美| 色综合中文综合网| 国产精品2024| 欧美在线色视频| 久久蜜臀中文字幕| 亚洲高清久久久| 国产精品91一区二区| 欧美一卡2卡三卡4卡5免费| 国产精品嫩草久久久久| 欧美经典一区二区三区| 丰满白嫩尤物一区二区| 3d动漫精品啪啪| 一二三区精品视频| 国产福利不卡视频| 日韩三区在线观看| 午夜私人影院久久久久| 成人avav影音| 成人美女视频在线观看18| 欧美成人女星排行榜| 一区二区三区国产豹纹内裤在线| 成人国产精品免费网站| 欧美mv日韩mv国产网站| 亚洲国产精品久久久久婷婷884 | 国产剧情在线观看一区二区| 欧美午夜精品理论片a级按摩| 国产亚洲一区二区三区在线观看| 日韩电影在线一区| 色哟哟国产精品| 国产精品三级视频| 狠狠色2019综合网| 久久综合资源网| 美女久久久精品| 精品久久久久香蕉网| 午夜亚洲福利老司机| 欧美日本国产一区| 亚洲另类在线一区| 色久综合一二码| 亚洲女人小视频在线观看| 国产成人精品免费网站| 欧美成va人片在线观看| 另类人妖一区二区av| 日韩一区二区在线免费观看| 视频一区二区三区在线| 在线综合亚洲欧美在线视频| 一二三区精品视频| 欧美男生操女生| 丝袜a∨在线一区二区三区不卡| 99re8在线精品视频免费播放| 1024国产精品| 94-欧美-setu| 亚洲国产精品欧美一二99| 欧美午夜精品一区二区三区| 日本aⅴ亚洲精品中文乱码| 51久久夜色精品国产麻豆| 久久国产成人午夜av影院| 日韩一区二区三| 国产乱码精品1区2区3区| 久久九九久精品国产免费直播| 激情图区综合网| 国产偷国产偷精品高清尤物| 99久久久国产精品| 亚洲欧美另类图片小说| 欧美日韩精品二区第二页| 天使萌一区二区三区免费观看| 日韩三级免费观看| 国产在线播放一区| 国产精品美女视频| 日本韩国欧美三级| 久久er99精品| 中文子幕无线码一区tr| 国产一区二区三区综合| 亚洲欧美日韩一区| 7777精品伊人久久久大香线蕉的 | 成a人片国产精品| 日本一区二区不卡视频| 欧美图区在线视频| 蜜臀国产一区二区三区在线播放| 国产欧美精品一区二区色综合朱莉| 成人性视频免费网站| 亚洲成在人线免费| 久久综合网色—综合色88| 成人免费看的视频| 免费在线成人网| 国产精品乱子久久久久| 日韩午夜av电影| 成人精品一区二区三区四区| 国产精品久久综合| 日韩视频一区二区三区| 99久久99久久精品免费看蜜桃| 免费在线观看日韩欧美| 中文字幕欧美一| 精品久久久久久久久久久久久久久 | 中文字幕免费一区| 91精品国产全国免费观看| 国产成人精品三级麻豆| 美女国产一区二区三区| 亚洲天堂精品在线观看| 久久精品水蜜桃av综合天堂|