fix some carriage return
[protos/xbee-avr.git] / uart_defs.h
1 /*  \r
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)\r
3  * \r
4  *  This program is free software; you can redistribute it and/or modify\r
5  *  it under the terms of the GNU General Public License as published by\r
6  *  the Free Software Foundation; either version 2 of the License, or\r
7  *  (at your option) any later version.\r
8  *\r
9  *  This program is distributed in the hope that it will be useful,\r
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  *  GNU General Public License for more details.\r
13  *\r
14  *  You should have received a copy of the GNU General Public License\r
15  *  along with this program; if not, write to the Free Software\r
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
17  *\r
18  *  Revision : $Id: uart_defs.h,v 1.2.4.13 2009-06-29 20:28:27 zer0 Exp $\r
19  *\r
20  */\r
21 \r
22 /* Olivier MATZ, Droids-corp 2004 - 2006\r
23  * Uart specific definitions\r
24  */\r
25 \r
26 #ifndef _UART_DEFS_H_\r
27 #define _UART_DEFS_H_\r
28 \r
29 #define UART_PARTITY_NONE 0\r
30 #define UART_PARTITY_ODD 1\r
31 #define UART_PARTITY_EVEN 2\r
32 \r
33 #define UART_STOP_BITS_1 0\r
34 #define UART_STOP_BITS_2 1\r
35 \r
36 #if (defined UDR3)\r
37 #define UART_HW_NUM 4\r
38 #elif (defined UDR2)\r
39 #define UART_HW_NUM 3\r
40 #elif (defined UDR1)\r
41 #define UART_HW_NUM 2\r
42 #else /* assume 1 uart */\r
43 #define UART_HW_NUM 1\r
44 #endif\r
45 \r
46 \r
47 /* For arch with only one UART, we consider that UART0 = UART */\r
48 #if !defined(SIG_UART0_DATA) && !defined(SIG_USART0_DATA)\r
49 #if defined SIG_UART_DATA\r
50 #define SIG_UART0_DATA SIG_UART_DATA\r
51 #elif defined SIG_USART_DATA\r
52 #define SIG_UART0_DATA SIG_USART_DATA\r
53 #endif\r
54 #endif\r
55 \r
56 #if !defined(SIG_UART0_RECV) && !defined(SIG_USART0_RECV)\r
57 #if defined SIG_UART_RECV\r
58 #define SIG_UART0_RECV  SIG_UART_RECV\r
59 #elif defined SIG_USART_RECV\r
60 #define SIG_UART0_RECV  SIG_USART_RECV\r
61 #endif\r
62 #endif\r
63 \r
64 #if !defined(UDR0) && defined(UDR)\r
65 #define UDR0 UDR\r
66 #endif\r
67 #ifndef UCSR0A\r
68 #define UCSR0A UCSRA\r
69 #endif\r
70 #ifndef UCSR0B\r
71 #define UCSR0B UCSRB\r
72 #endif\r
73 #ifndef UCSR0C\r
74 #define UCSR0C UCSRC\r
75 #endif\r
76 #ifndef UBRR0L\r
77 #define UBRR0L UBRRL\r
78 #endif\r
79 #ifndef UBRR0H\r
80 #define UBRR0H UBRRH\r
81 #endif\r
82 #if !defined(U2X) && defined(U2X0)\r
83 #define U2X U2X0\r
84 #endif\r
85 #if !defined(UCSZ0) && defined(UCSZ00)\r
86 #define UCSZ0 UCSZ00\r
87 #endif\r
88 #if !defined(UCSZ1) && defined(UCSZ01)\r
89 #define UCSZ1 UCSZ01\r
90 #endif\r
91 #if !defined(UCSZ2) && defined(UCSZ02)\r
92 #define UCSZ2 UCSZ02\r
93 #endif\r
94 #if !defined(UPM0) && defined(UPM00)\r
95 #define UPM0 UPM00\r
96 #endif\r
97 #if !defined(UPM1) && defined(UPM01)\r
98 #define UPM1 UPM01\r
99 #endif\r
100 #if !defined(USBS) && defined(USBS0)\r
101 #define USBS USBS0\r
102 #endif\r
103 #if !defined(TXEN) && defined(TXEN0)\r
104 #define TXEN TXEN0\r
105 #endif\r
106 #if !defined(TXCIE) && defined(TXCIE0)\r
107 #define TXCIE TXCIE0\r
108 #endif\r
109 #if !defined(RXEN) && defined(RXEN0)\r
110 #define RXEN RXEN0\r
111 #endif\r
112 #if !defined(RXCIE) && defined(RXCIE0)\r
113 #define RXCIE RXCIE0\r
114 #endif\r
115 #if !defined(TXC) && defined(TXC0)\r
116 #define TXC TXC0\r
117 #endif\r
118 #if !defined(RXC) && defined(RXC0)\r
119 #define RXC RXC0\r
120 #endif\r
121 #if !defined(RXB8) && defined(RXB80)\r
122 #define RXB8 RXB80\r
123 #endif\r
124 #if !defined(UDRIE) && defined(UDRIE0)\r
125 #define UDRIE UDRIE0\r
126 #endif\r
127 #if !defined(UDRE) && defined(UDRE0)\r
128 #define UDRE UDRE0\r
129 #endif\r
130 #if !defined(U2X) && defined(U2X1)\r
131 #define U2X U2X1\r
132 #endif\r
133 #if !defined(UCSZ1) && defined(UCSZ10)\r
134 #define UCSZ0 UCSZ10\r
135 #endif\r
136 #if !defined(UCSZ1) && defined(UCSZ11)\r
137 #define UCSZ1 UCSZ11\r
138 #endif\r
139 #if !defined(UCSZ2) && defined(UCSZ12)\r
140 #define UCSZ2 UCSZ12\r
141 #endif\r
142 #if !defined(UPM1) && defined(UPM10)\r
143 #define UPM0 UPM10\r
144 #endif\r
145 #if !defined(UPM1) && defined(UPM11)\r
146 #define UPM1 UPM11\r
147 #endif\r
148 #if !defined(USBS) && defined(USBS1)\r
149 #define USBS USBS1\r
150 #endif\r
151 #if !defined(TXEN) && defined(TXEN1)\r
152 #define TXEN TXEN1\r
153 #endif\r
154 #if !defined(TXCIE) && defined(TXCIE1)\r
155 #define TXCIE TXCIE1\r
156 #endif\r
157 #if !defined(RXEN) && defined(RXEN1)\r
158 #define RXEN RXEN1\r
159 #endif\r
160 #if !defined(RXCIE) && defined(RXCIE1)\r
161 #define RXCIE RXCIE1\r
162 #endif\r
163 #if !defined(TXC) && defined(TXC1)\r
164 #define TXC TXC1\r
165 #endif\r
166 #if !defined(RXC) && defined(RXC1)\r
167 #define RXC RXC1\r
168 #endif\r
169 #if !defined(RXB8) && defined(RXB81)\r
170 #define RXB8 RXB81\r
171 #endif\r
172 #if !defined(UDRIE) && defined(UDRIE1)\r
173 #define UDRIE UDRIE1\r
174 #endif\r
175 #if !defined(UDRIE) && defined(UDRIE1)\r
176 #define UDRIE UDRIE1\r
177 #endif\r
178 #if !defined(UDRE) && defined(UDRE1)\r
179 #define UDRE UDRE1\r
180 #endif\r
181 \r
182 /* makes functions more generic, we associate USR and UCR with UCSRA\r
183  * and UCSRB, respectively */\r
184 #if ( ! defined UCSRA ) && ( defined USR )\r
185 #define UCSRA USR\r
186 #endif\r
187 \r
188 #if ( ! defined UCSRB ) && ( defined UCR )\r
189 #define UCSRB UCR\r
190 #endif\r
191 \r
192 /* UBRR is UBRRL */\r
193 #ifndef UBRRL\r
194 #define UBRRL UBRR\r
195 #endif\r
196 \r
197 \r
198 /* workaround for libc incomplete headers when using CAN AVR\r
199  * (avr/iocanxx.h): USART is valid.\r
200  * see http://savannah.nongnu.org/bugs/?18964\r
201  */\r
202 #if defined (__AVR_AT90CAN128__) || defined (__AVR_AT90CAN64__) || defined (__AVR_AT90CAN32__)\r
203 \r
204 #ifndef SIG_USART0_RECV\r
205 #define SIG_USART0_RECV SIG_UART0_RECV\r
206 #define SIG_USART1_RECV SIG_UART1_RECV\r
207 #define SIG_USART0_DATA SIG_UART0_DATA\r
208 #define SIG_USART1_DATA SIG_UART1_DATA\r
209 #define SIG_USART0_TRANS SIG_UART0_TRANS\r
210 #define SIG_USART1_TRANS SIG_UART1_TRANS\r
211 #endif\r
212 \r
213 #endif\r
214 \r
215 \r
216 /* if the signal USART is defined, the uC has a USART. */\r
217 #if ( defined SIG_USART0_RECV ) || ( defined SIG_USART_RECV )\r
218 #define UART_IS_USART 1\r
219 #elif (defined USART_UDRE_vect) || (defined USART_TXC_vect) || (defined USART_RXC_vect)\r
220 #define UART_IS_USART 1\r
221 #elif (defined USART1_UDRE_vect) || (defined USART1_TXC_vect) || (defined USART1_RXC_vect)\r
222 #define UART_IS_USART 1\r
223 #else\r
224 #define UART_IS_USART 0\r
225 #endif\r
226 \r
227 /* if the U2X macro is defined, the uC has the U2X option. */\r
228 #ifdef U2X\r
229 #define UART_HAS_U2X 1\r
230 #else\r
231 #define UART_HAS_U2X 0\r
232 #endif\r
233 \r
234 #endif //_UART_DEFS_H_\r