00001
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _USART_H_
00058 #define _USART_H_
00059
00060 #include <avr32/io.h>
00061 #include "errno.h"
00062
00066 struct usart_options_t
00067 {
00071 unsigned long baudrate;
00072
00076 unsigned char charlength;
00077
00083 unsigned char paritytype;
00084
00091 unsigned short stopbits;
00092
00098 unsigned char channelmode;
00099 };
00100
00101
00102 struct iso7816_options_t
00103 {
00104
00105
00106
00107 unsigned long iso7816_hz;
00108
00109
00110
00111
00112
00113 unsigned short fidi_ratio;
00114
00115
00116
00117
00118
00119
00120
00121
00122 int inhibit_nack;
00123
00124
00125
00126
00127
00128
00129
00130 int dis_suc_nack;
00131
00132
00133
00134
00135 unsigned char max_iterations;
00136
00137
00138
00139
00140
00141
00142 int bit_order;
00143 };
00144
00145
00146
00147
00148
00149
00150
00156 void usart_reset( volatile struct avr32_usart_t * usart );
00157
00158
00167 int usart_init_rs232( volatile struct avr32_usart_t * usart, struct usart_options_t * opt, long cpu_hz );
00168
00169
00170
00171
00172
00173
00174
00175
00186 int usart_send_addr(volatile struct avr32_usart_t * usart, int addr);
00187
00188
00196 int usart_write_char(volatile struct avr32_usart_t * usart, int c);
00197
00198
00205 inline void usart_bw_write_char(volatile struct avr32_usart_t * usart, int c);
00206
00214 int usart_putchar(volatile struct avr32_usart_t * usart, int c);
00215
00227 int usart_read_char(volatile struct avr32_usart_t * usart, int * c);
00228
00234 int usart_getchar(volatile struct avr32_usart_t * usart);
00235
00244 void usart_reset_status(volatile struct avr32_usart_t * usart);
00245
00247 #define USART_DEFAULT_TIMEOUT 10000
00248
00250 #define USART_EVEN_PARITY 0
00251
00252 #define USART_ODD_PARITY 1
00253
00254 #define USART_SPACE_PARITY 2
00255
00256 #define USART_MARK_PARITY 3
00257
00258 #define USART_NO_PARITY 4
00259
00260 #define USART_MULTIDROP_PARITY 6
00261
00263 #define USART_MODE_NORMAL 0x00
00264
00265 #define USART_MODE_RS485 0x01
00266
00267 #define USART_MODE_HW_HSH 0x02
00268
00269 #define USART_MODE_MODEM 0x03
00270
00271 #define USART_MODE_ISO7816_T0 0x04
00272
00273 #define USART_MODE_ISO7816_T1 0x06
00274
00275 #define USART_MODE_IRDA 0x08
00276
00277 #define USART_MODE_SW_HSH 0x0C
00278
00280 #define USART_NORMAL_CHMODE 0
00281
00282 #define USART_AUTO_ECHO 1
00283
00284 #define USART_LOCAL_LOOPBACK 2
00285
00286 #define USART_REMOTE_LOOPBACK 3
00287
00289 #define USART_1_STOPBIT 0
00290
00291 #define USART_1_5_STOPBITS 1
00292
00293 #define USART_2_STOPBITS 2
00294
00295
00296
00297
00298
00299 #define INT_RXRDY 0
00300 #define INT_TXRDY 1
00301 #define INT_RXBRK 2
00302 #define INT_ENDRX 3
00303 #define INT_ENDTX 4
00304 #define INT_OVRE 5
00305 #define INT_FRAM 6
00306 #define INT_PARE 7
00307 #define INT_TIMEOUT 8
00308 #define INT_TXEMPTY 9
00309 #define INT_ITERATION 10
00310 #define INT_TXBUFE 11
00311 #define INT_RXBUFF 12
00312 #define INT_NACK 13
00313 #define INT_RIIC 16
00314 #define INT_DSRIC 17
00315 #define INT_DCDIC 18
00316 #define INT_CTSIC 19
00317 #define INT_MANE 20
00318
00319 #endif //#ifndef _AVR32_USART_H_