📄 uart_8h-source.html
字号:
<!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 ARMlib-LPC2100: uart.h 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 Page</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>uart.h</h1><a href="uart_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*! \file uart.h \brief UART driver for ARM LPC210x 16550. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name : 'uart.h'</span>00005 <span class="comment">// Title : UART driver for ARM LPC210x 16550</span>00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2004</span>00007 <span class="comment">// Created : 4/2/2004</span>00008 <span class="comment">// Revised : 4/2/2004</span>00009 <span class="comment">// Version : 0.1</span>00010 <span class="comment">// Target MCU : Philips ARM LPC210x 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">#ifndef UART_H</span>00019 <span class="preprocessor"></span><span class="preprocessor">#define UART_H</span>00020 <span class="preprocessor"></span>00021 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>00022 <span class="comment">//#include "buffer.h"</span>00023 <span class="preprocessor">#include "LPC210x.h"</span>00024 00025 <span class="comment">// defines</span>00026 00027 <span class="comment">// UART_BAUD calculates a division rate given a baud rate</span>00028 <span class="comment">// for use with uart0Init() and uart1Init()</span>00029 <span class="comment">// example: uart0Init(UART_BAUD(115200), UART_8N1, UART_FIFO_8);</span>00030 <span class="comment">//</span>00031 <span class="comment">// BEWARE: additional code will be generated if 'baud' is not a contant</span>00032 <span class="preprocessor">#define UART_BAUD(baud) (uint16_t)((PCLK+baud*8L)/(baud*16))</span>00033 <span class="preprocessor"></span>00034 <span class="comment">// Definitions for UART mode settings (databits, parity, stopbits)</span>00035 <span class="preprocessor">#define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1)</span>00036 <span class="preprocessor"></span><span class="preprocessor">#define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1)</span>00037 <span class="preprocessor"></span><span class="preprocessor">#define UART_8N2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2)</span>00038 <span class="preprocessor"></span><span class="preprocessor">#define UART_7N2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2)</span>00039 <span class="preprocessor"></span><span class="preprocessor">#define UART_8E1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)</span>00040 <span class="preprocessor"></span><span class="preprocessor">#define UART_7E1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)</span>00041 <span class="preprocessor"></span><span class="preprocessor">#define UART_8E2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)</span>00042 <span class="preprocessor"></span><span class="preprocessor">#define UART_7E2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)</span>00043 <span class="preprocessor"></span><span class="preprocessor">#define UART_8O1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1)</span>00044 <span class="preprocessor"></span><span class="preprocessor">#define UART_7O1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1)</span>00045 <span class="preprocessor"></span><span class="preprocessor">#define UART_8O2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2)</span>00046 <span class="preprocessor"></span><span class="preprocessor">#define UART_7O2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2)</span>00047 <span class="preprocessor"></span>00048 <span class="comment">// Definitions for typical UART fifo mode settings</span>00049 <span class="preprocessor">#define UART_FIFO_OFF (0x00)</span>00050 <span class="preprocessor"></span><span class="preprocessor">#define UART_FIFO_1 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)</span>00051 <span class="preprocessor"></span><span class="preprocessor">#define UART_FIFO_4 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)</span>00052 <span class="preprocessor"></span><span class="preprocessor">#define UART_FIFO_8 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)</span>00053 <span class="preprocessor"></span><span class="preprocessor">#define UART_FIFO_14 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)</span>00054 <span class="preprocessor"></span>00055 00056 <span class="comment">// functions</span>00057 <span class="comment"></span>00058 <span class="comment">//! initializes transmit and receive buffers</span>00059 <span class="comment"></span><span class="comment">// called from uartInit()</span>00060 <span class="comment">//void uartInitBuffers(void);</span>00061 <span class="comment"></span>00062 <span class="comment">//! initializes uart</span>00063 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="uart_8h.html#a18">uart0Init</a>(uint16_t baud, uint8_t mode, uint8_t fifomode);00064 <span class="keywordtype">void</span> uart1Init(uint16_t baud, uint8_t mode, uint8_t fifomode);00065 <span class="comment"></span>00066 <span class="comment">//! sends a single byte over the uart</span>00067 <span class="comment"></span><span class="keywordtype">int</span> <a class="code" href="uart_8h.html#a20">uart0SendByte</a>(<span class="keywordtype">int</span> data);00068 <span class="keywordtype">int</span> uart1SendByte(<span class="keywordtype">int</span> data);00069 <span class="comment"></span>00070 <span class="comment">//! gets a single byte from the uart receive buffer</span>00071 <span class="comment"></span><span class="keywordtype">int</span> <a class="code" href="uart_8c.html#a2">uart0GetByte</a>(<span class="keywordtype">void</span>);00072 <span class="keywordtype">int</span> uart1GetByte(<span class="keywordtype">void</span>);00073 00074 00075 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 13 03:38:12 2004 for Procyon ARMlib-LPC2100 by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -