00001 /*! \file uartsw.h \brief Software Interrupt-driven UART Driver. */ 00002 //***************************************************************************** 00003 // 00004 // File Name : 'uartsw.h' 00005 // Title : Software Interrupt-driven UART Driver 00006 // Author : Pascal Stang - Copyright (C) 2002-2004 00007 // Created : 7/20/2002 00008 // Revised : 4/27/2004 00009 // Version : 0.1 00010 // Target MCU : Atmel AVR Series (intended for the ATmega16 and ATmega32) 00011 // Editor Tabs : 4 00012 // 00013 /// \ingroup driver_sw 00014 /// \defgroup uartsw Software Interrupt-driven UART Driver (uartsw.c) 00015 /// \code #include "uartsw.h" \endcode 00016 /// \par Overview 00017 /// This uart library emulates the operation of a UART (serial port) using 00018 /// the AVR's hardware timers, I/O pins, and some software. 00019 /// 00020 /// Specifically, this code uses: 00021 /// -Timer 1 Output Compare A for transmit timing 00022 /// -Timer 1 Output Compare B for receive timing 00023 /// -Timer 1 Input Capture for receive triggering 00024 /// 00025 /// The above resources cannot be used for other purposes while this software 00026 /// UART is enabled. The overflow interrupt from Timer1 can still be used for 00027 /// other timing, but the prescaler for Timer1 must not be changed. 00028 /// 00029 /// Serial output from this UART can be routed to any I/O pin. Serial input 00030 /// for this UART must come from the Timer1 Input Capture (IC1) I/O pin. 00031 /// These options should be configured by editing your local copy of 00032 /// "uartswconf.h". 00033 // 00034 // This code is distributed under the GNU Public License 00035 // which can be found at http://www.gnu.org/licenses/gpl.txt 00036 // 00037 //***************************************************************************** 00038 00039 #ifndef UARTSW_H 00040 #define UARTSW_H 00041 00042 #include "global.h" 00043 #include "buffer.h" 00044 00045 // include configuration 00046 #include "uartswconf.h" 00047 00048 // constants/macros/typdefs 00049 00050 // functions 00051 00052 //! enable and initialize the software uart 00053 void uartswInit(void); 00054 //! create and initialize the uart buffers 00055 void uartswInitBuffers(void); 00056 //! turns off software UART 00057 void uartswOff(void); 00058 //! returns the receive buffer structure 00059 cBuffer* uartswGetRxBuffer(void); 00060 //! sets the uart baud rate 00061 void uartswSetBaudRate(u32 baudrate); 00062 //! sends a single byte over the uart 00063 void uartswSendByte(u08 data); 00064 00065 //! gets a single byte from the uart receive buffer 00066 // Function returns TRUE if data was available, FALSE if not. 00067 // Actual data is returned in variable pointed to by "data". 00068 // example usage: 00069 // char myReceivedByte; 00070 // uartswReceiveByte( &myReceivedByte ); 00071 u08 uartswReceiveByte(u08* rxData); 00072 00073 //! internal transmit bit handler 00074 void uartswTxBitService(void); 00075 //! internal receive bit handler 00076 void uartswRxBitService(void); 00077 00078 #endif