00001
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 #ifndef _AVR32_USART_H_
00051 #define _AVR32_USART_H_
00052
00053 #include <avr32/io.h>
00054 #include <stdio.h>
00055 #include "settings.h"
00056
00058 #define USART_OK 0
00059
00062 #define USART_FAILURE -1
00063
00065 #define USART_ERROR_ARGUMENT 1
00066
00067 #define USART_TX_BUSY 2
00068
00069 #define USART_RX_EMPTY 3
00070
00071 #define USART_RX_ERROR 4
00072
00075 #define USART_MODE_FAULT 5
00076
00079 #define USART_ADDR_RECEIVED 1
00080
00082 #define USART_DEFAULT_TIMEOUT 10000
00083
00085 #define USART_EVEN_PARITY 0
00086
00087 #define USART_ODD_PARITY 1
00088
00089 #define USART_SPACE_PARITY 2
00090
00091 #define USART_MARK_PARITY 3
00092
00093 #define USART_NO_PARITY 4
00094
00095 #define USART_MULTIDROP_PARITY 6
00096
00098 #define USART_MODE_NORMAL 0x00
00099
00100 #define USART_MODE_RS485 0x01
00101
00102 #define USART_MODE_HW_HSH 0x02
00103
00104 #define USART_MODE_MODEM 0x03
00105
00106 #define USART_MODE_ISO7816_T0 0x04
00107
00108 #define USART_MODE_ISO7816_T1 0x06
00109
00110 #define USART_MODE_IRDA 0x08
00111
00112 #define USART_MODE_SW_HSH 0x0C
00113
00115 #define USART_NORMAL_CHMODE 0
00116
00117 #define USART_AUTO_ECHO 1
00118
00119 #define USART_LOCAL_LOOPBACK 2
00120
00121 #define USART_REMOTE_LOOPBACK 3
00122
00124 #define USART_1_STOPBIT 0
00125
00126 #define USART_1_5_STOPBITS 1
00127
00128 #define USART_2_STOPBITS 2
00129
00131 struct usart_options_t
00132 {
00134 unsigned long baudrate;
00135
00137 unsigned char charlength;
00138
00147 unsigned char paritytype;
00148
00156 unsigned short stopbits;
00157
00164 unsigned char channelmode;
00165 };
00166
00167 void usart_reset( volatile avr32_usart_t * usart );
00168
00169 int usart_linit( volatile avr32_usart_t * usart,
00170 const struct usart_options_t * opt,
00171 const long cpuHz );
00172
00173 int usart_putchar( volatile avr32_usart_t * usart, const short character );
00174
00175 #ifdef _write_r
00176 #undef _write_r
00177 #endif
00178 int _write_r(struct _reent *ptr, int fd, const void *buf, size_t cnt);
00179
00180 #endif
00181