00001 #ifndef _AVR32_USART_H_
00002 #define _AVR32_USART_H_
00003
00004 #include <avr32/io.h>
00005
00009 struct usart_options_t
00010 {
00014 unsigned long baudrate;
00015
00019 unsigned char charlength;
00020
00026 unsigned char paritytype;
00027
00034 unsigned short stopbits;
00035
00041 unsigned char channelmode;
00042 };
00043
00044
00045 struct iso7816_options_t
00046 {
00047
00048
00049
00050 unsigned long iso7816_hz;
00051
00052
00053
00054
00055
00056 unsigned short fidi_ratio;
00057
00058
00059
00060
00061
00062
00063
00064
00065 int inhibit_nack;
00066
00067
00068
00069
00070
00071
00072
00073 int dis_suc_nack;
00074
00075
00076
00077
00078 unsigned char max_iterations;
00079
00080
00081
00082
00083
00084
00085 int bit_order;
00086 };
00087
00088
00089
00090
00091
00092
00093
00099 void usart_reset(volatile avr32_usart_t * usart);
00100
00101
00109 int usart_init_rs232(volatile avr32_usart_t * usart, struct usart_options_t * opt, long cpu_hz);
00110
00111
00112
00113
00114
00115
00116
00117
00128 int usart_send_addr(volatile avr32_usart_t * usart, int addr);
00129
00130
00138 int usart_write_char(volatile avr32_usart_t * usart, int c);
00139
00140
00147 inline void usart_bw_write_char(volatile avr32_usart_t * usart, int c);
00148
00156 int usart_putchar(volatile avr32_usart_t * usart, int c);
00157
00169 int usart_read_char(volatile avr32_usart_t * usart, int * c);
00170
00176 int usart_getchar(volatile avr32_usart_t * usart);
00177
00186 void usart_reset_status(volatile avr32_usart_t * usart);
00187
00189 #define USART_SUCCESS 0
00190
00192 #define USART_FAILURE -1
00193
00194 #define USART_INVALID_INPUT 1
00195 #define USART_INVALID_ARGUMENT -1
00196
00197 #define USART_TX_BUSY 2
00198
00199 #define USART_RX_EMPTY 3
00200
00201 #define USART_RX_ERROR 4
00202
00204 #define USART_MODE_FAULT 5
00205
00207 #define USART_ADDR_RECEIVED 1
00208
00210 #define USART_DEFAULT_TIMEOUT 10000
00211
00213 #define USART_EVEN_PARITY 0
00214
00215 #define USART_ODD_PARITY 1
00216
00217 #define USART_SPACE_PARITY 2
00218
00219 #define USART_MARK_PARITY 3
00220
00221 #define USART_NO_PARITY 4
00222
00223 #define USART_MULTIDROP_PARITY 6
00224
00226 #define USART_MODE_NORMAL 0x00
00227
00228 #define USART_MODE_RS485 0x01
00229
00230 #define USART_MODE_HW_HSH 0x02
00231
00232 #define USART_MODE_MODEM 0x03
00233
00234 #define USART_MODE_ISO7816_T0 0x04
00235
00236 #define USART_MODE_ISO7816_T1 0x06
00237
00238 #define USART_MODE_IRDA 0x08
00239
00240 #define USART_MODE_SW_HSH 0x0C
00241
00243 #define USART_NORMAL_CHMODE 0
00244
00245 #define USART_AUTO_ECHO 1
00246
00247 #define USART_LOCAL_LOOPBACK 2
00248
00249 #define USART_REMOTE_LOOPBACK 3
00250
00252 #define USART_1_STOPBIT 0
00253
00254 #define USART_1_5_STOPBITS 1
00255
00256 #define USART_2_STOPBITS 2
00257
00258
00259
00260
00261
00262 #define INT_RXRDY 0
00263 #define INT_TXRDY 1
00264 #define INT_RXBRK 2
00265 #define INT_ENDRX 3
00266 #define INT_ENDTX 4
00267 #define INT_OVRE 5
00268 #define INT_FRAM 6
00269 #define INT_PARE 7
00270 #define INT_TIMEOUT 8
00271 #define INT_TXEMPTY 9
00272 #define INT_ITERATION 10
00273 #define INT_TXBUFE 11
00274 #define INT_RXBUFF 12
00275 #define INT_NACK 13
00276 #define INT_RIIC 16
00277 #define INT_DSRIC 17
00278 #define INT_DCDIC 18
00279 #define INT_CTSIC 19
00280 #define INT_MANE 20
00281
00282 #endif //#ifndef _AVR32_USART_H_