Main Page   Data Structures   File List   Data Fields   Globals  

uart.h

Go to the documentation of this file.
00001 /*! \file uart.h \brief UART driver with buffer support. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'uart.h'
00005 // Title        : UART driver with buffer support
00006 // Author       : Pascal Stang - Copyright (C) 2000-2002
00007 // Created      : 11/22/2000
00008 // Revised      : 11/01/2001
00009 // Version      : 1.3
00010 // Target MCU   : ATMEL AVR 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 UART_H
00019 #define UART_H
00020 
00021 #include "global.h"
00022 #include "buffer.h"
00023 
00024 // default baud rate
00025 // can be changed by using uartSetBaudRate()
00026 #define UART_BAUD_RATE          9600
00027 
00028 // buffer memory allocation defines
00029 // buffer sizes
00030 #define UART_TX_BUFFER_SIZE     0x0040  // number of bytes for uart transmit buffer
00031 #define UART_RX_BUFFER_SIZE     0x0040  // number of bytes for uart receive buffer
00032 
00033 // define this key if you wish to use
00034 // external RAM for the UART buffers
00035 //#define UART_BUFFER_EXTERNAL_RAM
00036 #ifdef UART_BUFFER_EXTERNAL_RAM
00037     // absolute address of uart buffers
00038     #define UART_TX_BUFFER_ADDR 0x1000
00039     #define UART_RX_BUFFER_ADDR 0x1100
00040 #endif
00041 
00042 // compatibility with dual-uart processors
00043 // (if you need to use both uarts, please use the uart2 library)
00044 #ifdef UDR0
00045     #define UDR                 UDR0
00046     #define UBRR                UBRR0L
00047     #define SIG_UART_TRANS      SIG_UART0_TRANS
00048     #define SIG_UART_RECV       SIG_UART0_RECV
00049     #define SIG_UART_DATA       SIG_UART0_DATA
00050 #endif
00051 // compatibility for the mega161
00052 #ifndef RXCIE
00053     #define RXCIE   RXCIE0
00054     #define TXCIE   TXCIE0
00055     #define UDRIE   UDRIE0
00056     #define RXEN    RXEN0
00057     #define TXEN    TXEN0
00058     #define CHR9    CHR90
00059     #define RXB8    RXB80
00060     #define TXB8    TXB80
00061 #endif
00062 #ifndef UBRR0L
00063     #define UBRR0L  UBRR0
00064     #define UBRR1L  UBRR1
00065 #endif
00066 
00067 // functions
00068 
00069 //! initializes transmit and receive buffers
00070 // called from uartInit()
00071 void uartInitBuffers(void);
00072 
00073 //! initializes uart
00074 void uartInit(void);
00075 
00076 //! sets the uart baud rate
00077 void uartSetBaudRate(u32 baudrate);
00078 
00079 //! returns pointer to the receive buffer structure
00080 cBuffer* uartGetRxBuffer(void);
00081 
00082 //! returns pointer to the transmit buffer structure
00083 cBuffer* uartGetTxBuffer(void);
00084 
00085 //! sends a single byte over the uart
00086 void uartSendByte(u08 data);
00087 
00088 //! gets a single byte from the uart receive buffer
00089 // function returns TRUE if data was available, FALSE if not
00090 // actual data is returned in variable pointed to by "data"
00091 // example usage:
00092 // char myReceivedByte;
00093 // uartReceiveByte( &myReceivedByte );
00094 u08 uartReceiveByte(u08* data);
00095 
00096 //! returns TRUE/FALSE if receive buffer is empty/not-empty
00097 u08 uartReceiveBufferIsEmpty(void);
00098 
00099 //! flushes (deletes) all data from receive buffer
00100 void uartFlushReceiveBuffer(void);
00101 
00102 //! begins transmission of the transmit buffer under interrupt control
00103 void uartSendTxBuffer(void);
00104 
00105 //! sends a buffer of length nBytes via the uart using interrupt control
00106 u08  uartSendBuffer(char *buffer, u16 nBytes);
00107 
00108 #endif
00109 

Generated on Tue Feb 4 20:18:37 2003 for Procyon AVRlib by doxygen1.3-rc2