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