Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | /*! \file uartsw.h \brief Software Interrupt-driven UART Driver. */ |
2 | //***************************************************************************** |
||
3 | // |
||
4 | // File Name : 'uartsw.h' |
||
5 | // Title : Software Interrupt-driven UART Driver |
||
6 | // Author : Pascal Stang - Copyright (C) 2002-2004 |
||
7 | // Created : 7/20/2002 |
||
8 | // Revised : 4/27/2004 |
||
9 | // Version : 0.1 |
||
10 | // Target MCU : Atmel AVR Series (intended for the ATmega16 and ATmega32) |
||
11 | // Editor Tabs : 4 |
||
12 | // |
||
13 | /// \ingroup driver_sw |
||
14 | /// \defgroup uartsw Software Interrupt-driven UART Driver (uartsw.c) |
||
15 | /// \code #include "uartsw.h" \endcode |
||
16 | /// \par Overview |
||
17 | /// This uart library emulates the operation of a UART (serial port) using |
||
18 | /// the AVR's hardware timers, I/O pins, and some software. |
||
19 | /// |
||
20 | /// Specifically, this code uses: |
||
21 | /// -Timer 1 Output Compare A for transmit timing |
||
22 | /// -Timer 1 Output Compare B for receive timing |
||
23 | /// -Timer 1 Input Capture for receive triggering |
||
24 | /// |
||
25 | /// The above resources cannot be used for other purposes while this software |
||
26 | /// UART is enabled. The overflow interrupt from Timer1 can still be used for |
||
27 | /// other timing, but the prescaler for Timer1 must not be changed. |
||
28 | /// |
||
29 | /// Serial output from this UART can be routed to any I/O pin. Serial input |
||
30 | /// for this UART must come from the Timer1 Input Capture (IC1) I/O pin. |
||
31 | /// These options should be configured by editing your local copy of |
||
32 | /// "uartswconf.h". |
||
33 | // |
||
34 | // This code is distributed under the GNU Public License |
||
35 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
36 | // |
||
37 | //***************************************************************************** |
||
38 | |||
39 | #ifndef UARTSW_H |
||
40 | #define UARTSW_H |
||
41 | |||
42 | #include "global.h" |
||
43 | #include "buffer.h" |
||
44 | |||
45 | // include configuration |
||
46 | #include "uartswconf.h" |
||
47 | |||
48 | // constants/macros/typdefs |
||
49 | |||
50 | // functions |
||
51 | |||
52 | //! enable and initialize the software uart |
||
53 | void uartswInit(void); |
||
54 | //! create and initialize the uart buffers |
||
55 | void uartswInitBuffers(void); |
||
56 | //! turns off software UART |
||
57 | void uartswOff(void); |
||
58 | //! returns the receive buffer structure |
||
59 | cBuffer* uartswGetRxBuffer(void); |
||
60 | //! sets the uart baud rate |
||
61 | void uartswSetBaudRate(u32 baudrate); |
||
62 | //! sends a single byte over the uart |
||
63 | void uartswSendByte(u08 data); |
||
64 | |||
65 | //! gets a single byte from the uart receive buffer |
||
66 | // Function returns TRUE if data was available, FALSE if not. |
||
67 | // Actual data is returned in variable pointed to by "data". |
||
68 | // example usage: |
||
69 | // char myReceivedByte; |
||
70 | // uartswReceiveByte( &myReceivedByte ); |
||
71 | u08 uartswReceiveByte(u08* rxData); |
||
72 | |||
73 | //! internal transmit bit handler |
||
74 | void uartswTxBitService(void); |
||
75 | //! internal receive bit handler |
||
76 | void uartswRxBitService(void); |
||
77 | |||
78 | #endif |
Powered by WebSVN v2.8.3