vt100: include pgmspace.h as we use PROGMEM macro
[aversive.git] / modules / comm / uart / 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 #if !defined(UDR0) && defined(UDR)\r
48 #define UDR0 UDR\r
49 #endif\r
50 #ifndef UCSR0A\r
51 #define UCSR0A UCSRA\r
52 #endif\r
53 #ifndef UCSR0B\r
54 #define UCSR0B UCSRB\r
55 #endif\r
56 #ifndef UCSR0C\r
57 #define UCSR0C UCSRC\r
58 #endif\r
59 #ifndef UBRR0L\r
60 #define UBRR0L UBRRL\r
61 #endif\r
62 #ifndef UBRR0H\r
63 #define UBRR0H UBRRH\r
64 #endif\r
65 #if !defined(U2X) && defined(U2X0)\r
66 #define U2X U2X0\r
67 #endif\r
68 #if !defined(UCSZ0) && defined(UCSZ00)\r
69 #define UCSZ0 UCSZ00\r
70 #endif\r
71 #if !defined(UCSZ1) && defined(UCSZ01)\r
72 #define UCSZ1 UCSZ01\r
73 #endif\r
74 #if !defined(UCSZ2) && defined(UCSZ02)\r
75 #define UCSZ2 UCSZ02\r
76 #endif\r
77 #if !defined(UPM0) && defined(UPM00)\r
78 #define UPM0 UPM00\r
79 #endif\r
80 #if !defined(UPM1) && defined(UPM01)\r
81 #define UPM1 UPM01\r
82 #endif\r
83 #if !defined(USBS) && defined(USBS0)\r
84 #define USBS USBS0\r
85 #endif\r
86 #if !defined(TXEN) && defined(TXEN0)\r
87 #define TXEN TXEN0\r
88 #endif\r
89 #if !defined(TXCIE) && defined(TXCIE0)\r
90 #define TXCIE TXCIE0\r
91 #endif\r
92 #if !defined(RXEN) && defined(RXEN0)\r
93 #define RXEN RXEN0\r
94 #endif\r
95 #if !defined(RXCIE) && defined(RXCIE0)\r
96 #define RXCIE RXCIE0\r
97 #endif\r
98 #if !defined(TXC) && defined(TXC0)\r
99 #define TXC TXC0\r
100 #endif\r
101 #if !defined(RXC) && defined(RXC0)\r
102 #define RXC RXC0\r
103 #endif\r
104 #if !defined(RXB8) && defined(RXB80)\r
105 #define RXB8 RXB80\r
106 #endif\r
107 #if !defined(UDRIE) && defined(UDRIE0)\r
108 #define UDRIE UDRIE0\r
109 #endif\r
110 #if !defined(UDRE) && defined(UDRE0)\r
111 #define UDRE UDRE0\r
112 #endif\r
113 #if !defined(U2X) && defined(U2X1)\r
114 #define U2X U2X1\r
115 #endif\r
116 #if !defined(UCSZ1) && defined(UCSZ10)\r
117 #define UCSZ0 UCSZ10\r
118 #endif\r
119 #if !defined(UCSZ1) && defined(UCSZ11)\r
120 #define UCSZ1 UCSZ11\r
121 #endif\r
122 #if !defined(UCSZ2) && defined(UCSZ12)\r
123 #define UCSZ2 UCSZ12\r
124 #endif\r
125 #if !defined(UPM1) && defined(UPM10)\r
126 #define UPM0 UPM10\r
127 #endif\r
128 #if !defined(UPM1) && defined(UPM11)\r
129 #define UPM1 UPM11\r
130 #endif\r
131 #if !defined(USBS) && defined(USBS1)\r
132 #define USBS USBS1\r
133 #endif\r
134 #if !defined(TXEN) && defined(TXEN1)\r
135 #define TXEN TXEN1\r
136 #endif\r
137 #if !defined(TXCIE) && defined(TXCIE1)\r
138 #define TXCIE TXCIE1\r
139 #endif\r
140 #if !defined(RXEN) && defined(RXEN1)\r
141 #define RXEN RXEN1\r
142 #endif\r
143 #if !defined(RXCIE) && defined(RXCIE1)\r
144 #define RXCIE RXCIE1\r
145 #endif\r
146 #if !defined(TXC) && defined(TXC1)\r
147 #define TXC TXC1\r
148 #endif\r
149 #if !defined(RXC) && defined(RXC1)\r
150 #define RXC RXC1\r
151 #endif\r
152 #if !defined(RXB8) && defined(RXB81)\r
153 #define RXB8 RXB81\r
154 #endif\r
155 #if !defined(UDRIE) && defined(UDRIE1)\r
156 #define UDRIE UDRIE1\r
157 #endif\r
158 #if !defined(UDRIE) && defined(UDRIE1)\r
159 #define UDRIE UDRIE1\r
160 #endif\r
161 #if !defined(UDRE) && defined(UDRE1)\r
162 #define UDRE UDRE1\r
163 #endif\r
164 \r
165 /* makes functions more generic, we associate USR and UCR with UCSRA\r
166  * and UCSRB, respectively */\r
167 #if ( ! defined UCSRA ) && ( defined USR )\r
168 #define UCSRA USR\r
169 #endif\r
170 \r
171 #if ( ! defined UCSRB ) && ( defined UCR )\r
172 #define UCSRB UCR\r
173 #endif\r
174 \r
175 /* UBRR is UBRRL */\r
176 #ifndef UBRRL\r
177 #define UBRRL UBRR\r
178 #endif\r
179 \r
180 \r
181 /* workaround for libc incomplete headers when using CAN AVR\r
182  * (avr/iocanxx.h): USART is valid.\r
183  * see http://savannah.nongnu.org/bugs/?18964\r
184  */\r
185 #if defined (__AVR_AT90CAN128__) || defined (__AVR_AT90CAN64__) || defined (__AVR_AT90CAN32__)\r
186 \r
187 #ifndef SIG_USART0_RECV\r
188 #define SIG_USART0_RECV SIG_UART0_RECV\r
189 #define SIG_USART1_RECV SIG_UART1_RECV\r
190 #define SIG_USART0_DATA SIG_UART0_DATA\r
191 #define SIG_USART1_DATA SIG_UART1_DATA\r
192 #define SIG_USART0_TRANS SIG_UART0_TRANS\r
193 #define SIG_USART1_TRANS SIG_UART1_TRANS\r
194 #endif\r
195 \r
196 #endif\r
197 \r
198 \r
199 /* if the signal USART is defined, the uC has a USART. */\r
200 #if defined(UART_TX_vect)\r
201 #define UART_IS_USART 0\r
202 #else\r
203 #define UART_IS_USART 1\r
204 #endif\r
205 \r
206 /* if the U2X macro is defined, the uC has the U2X option. */\r
207 #ifdef U2X\r
208 #define UART_HAS_U2X 1\r
209 #else\r
210 #define UART_HAS_U2X 0\r
211 #endif\r
212 \r
213 #endif //_UART_DEFS_H_\r