Main Page   Compound List   File List   Compound Members   File Members  

uart.h

Go to the documentation of this file.
00001 
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  : 3
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 uartSetBaudRate()
00026 #define UART_BAUD_RATE         38400
00027 
00028 // address space defines
00029 // internal ram
00030 //#ifndef INT_RAM_BASE
00031 // define if needed
00032 #define INT_RAM_BASE                                    0x0060
00033 // location of uart transmit buffer
00034 #define UART_TX_BUFFER_ADDR             0x01C0
00035 #define UART_TX_BUFFER_SIZE             0x0020
00036 // location of uart receive buffer
00037 #define UART_RX_BUFFER_ADDR             0x01E0
00038 #define UART_RX_BUFFER_SIZE             0x0020
00039 
00040 #define INT_RAM_END                                     0x0260
00041 //#endif
00042 
00043 // functions
00044 
00045 // initializes transmit and receive buffers
00046 // called from uartInit()
00047 void uartInitBuffers(void);
00048 
00049 // initializes uart
00050 void uartInit(void);
00051 
00052 // set the uart baud rate
00053 void uartSetBaudRate(u16 baudrate);
00054 
00055 // returns pointer to the receive buffer structure
00056 cBuffer* uartGetRxBuffer(void);
00057 
00058 // returns pointer to the transmit buffer structure
00059 cBuffer* uartGetTxBuffer(void);
00060 
00061 // sends a single byte over the uart
00062 void uartSendByte(u08 data);
00063 
00064 // gets a single byte from the uart receive buffer
00065 // function returns TRUE if data was available, FALSE if not
00066 // actual data is returned in variable pointed to by "data"
00067 // example usage:
00068 // char myReceivedByte;
00069 // uartReceiveByte( &myReceivedByte );
00070 u08 uartReceiveByte(u08* data);
00071 
00072 // returns TRUE/FALSE if receive buffer is empty/not-empty
00073 u08 uartReceiveBufferIsEmpty(void);
00074 
00075 // flushes (deletes) all data from receive buffer
00076 void uartFlushReceiveBuffer(void);
00077 
00078 // begins transmission of the transmit buffer under interrupt control
00079 void uartSendTxBuffer(void);
00080 
00081 // sends a buffer of length nBytes via the uart using interrupt control
00082 u08  uartSendBuffer(char *buffer, u16 nBytes);
00083 
00084 #endif
00085 

Generated at Fri Oct 25 15:36:38 2002 for avrlib by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001