Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

uart.h

00001 /*! \file uart.h \brief UART driver for ARM LPC2000 16550. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'uart.h'
00005 // Title        : UART driver for ARM LPC2000 16550
00006 // Author       : Pascal Stang - Copyright (C) 2004
00007 // Created      : 4/2/2004
00008 // Revised      : 4/2/2004
00009 // Version      : 0.1
00010 // Target MCU   : Philips ARM LPC2000 Series
00011 // Editor Tabs  : 4
00012 //
00013 // This code is distributed under the GNU Public License
00014 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00015 //
00016 //*****************************************************************************
00017 
00018 #ifndef ARMLIB_UART_H
00019 #define ARMLIB_UART_H
00020 
00021 #include "global.h"
00022 //#include "buffer.h"
00023 #include "LPC2000.h"
00024 
00025 // defines
00026 
00027 // UART_BAUD calculates a division rate given a baud rate
00028 // for use with uart0Init() and uart1Init()
00029 // example: uart0Init(UART_BAUD(115200), UART_8N1, UART_FIFO_8);
00030 //
00031 // BEWARE: additional code will be generated if 'baud' is not a contant
00032 #define UART_BAUD(baud) (uint16_t)((PCLK+baud*8L)/(baud*16))
00033 
00034 // Definitions for UART mode settings (databits, parity, stopbits)
00035 #define UART_8N1      (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO   + ULCR_STOP_1)
00036 #define UART_7N1      (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO   + ULCR_STOP_1)
00037 #define UART_8N2      (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO   + ULCR_STOP_2)
00038 #define UART_7N2      (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO   + ULCR_STOP_2)
00039 #define UART_8E1      (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)
00040 #define UART_7E1      (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)
00041 #define UART_8E2      (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)
00042 #define UART_7E2      (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)
00043 #define UART_8O1      (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD  + ULCR_STOP_1)
00044 #define UART_7O1      (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD  + ULCR_STOP_1)
00045 #define UART_8O2      (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD  + ULCR_STOP_2)
00046 #define UART_7O2      (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD  + ULCR_STOP_2)
00047 
00048 // Definitions for UART fifo mode settings
00049 #define UART_FIFO_OFF (0x00)
00050 #define UART_FIFO_1   (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)
00051 #define UART_FIFO_4   (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)
00052 #define UART_FIFO_8   (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)
00053 #define UART_FIFO_14  (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)
00054 
00055 
00056 // functions
00057 
00058 //! initializes transmit and receive buffers
00059 // called from uartInit()
00060 //void uartInitBuffers(void);
00061 
00062 //! initializes uart
00063 void uart0Init(uint16_t baud, uint8_t mode, uint8_t fifomode);
00064 void uart1Init(uint16_t baud, uint8_t mode, uint8_t fifomode);
00065 
00066 //! sends a single byte over the uart
00067 int uart0SendByte(int data);
00068 int uart1SendByte(int data);
00069 
00070 //! gets a single byte from the uart receive buffer
00071 int uart0GetByte(void);
00072 int uart1GetByte(void);
00073 
00074 
00075 #endif

Generated on Mon Nov 6 23:36:58 2006 for Procyon ARMlib by  doxygen 1.4.2