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