00001
00021 #ifndef _AVR32_USART_H_
00022 #define _AVR32_USART_H_
00023
00024 #include <avr32/io.h>
00025 #include "settings.h"
00026
00028 #define USART_OK 0
00029
00031 #define USART_FAILURE -1
00032
00033 #define USART_ERROR_ARGUMENT 1
00034
00035 #define USART_TX_BUSY 2
00036
00037 #define USART_RX_EMPTY 3
00038
00039 #define USART_RX_ERROR 4
00040
00042 #define USART_MODE_FAULT 5
00043
00045 #define USART_ADDR_RECEIVED 1
00046
00048 #define USART_DEFAULT_TIMEOUT 10000
00049
00051 #define USART_EVEN_PARITY 0
00052
00053 #define USART_ODD_PARITY 1
00054
00055 #define USART_SPACE_PARITY 2
00056
00057 #define USART_MARK_PARITY 3
00058
00059 #define USART_NO_PARITY 4
00060
00061 #define USART_MULTIDROP_PARITY 6
00062
00064 #define USART_MODE_NORMAL 0x00
00065
00066 #define USART_MODE_RS485 0x01
00067
00068 #define USART_MODE_HW_HSH 0x02
00069
00070 #define USART_MODE_MODEM 0x03
00071
00072 #define USART_MODE_ISO7816_T0 0x04
00073
00074 #define USART_MODE_ISO7816_T1 0x06
00075
00076 #define USART_MODE_IRDA 0x08
00077
00078 #define USART_MODE_SW_HSH 0x0C
00079
00081 #define USART_NORMAL_CHMODE 0
00082
00083 #define USART_AUTO_ECHO 1
00084
00085 #define USART_LOCAL_LOOPBACK 2
00086
00087 #define USART_REMOTE_LOOPBACK 3
00088
00090 #define USART_1_STOPBIT 0
00091
00092 #define USART_1_5_STOPBITS 1
00093
00094 #define USART_2_STOPBITS 2
00095
00097 struct usart_options_t
00098 {
00102 unsigned long baudrate;
00103
00107 unsigned char charlength;
00108
00114 unsigned char paritytype;
00115
00122 unsigned short stopbits;
00123
00129 unsigned char channelmode;
00130 };
00131
00132 void usart_reset( volatile avr32_usart_t * usart );
00133
00134 int usart_init2( volatile avr32_usart_t * usart,
00135 struct usart_options_t * opt,
00136 long cpuHz );
00137
00138 int usart_puthcar( volatile avr32_usart_t * usart, int character );
00139
00140 int usart_writeLine( volatile avr32_usart_t * usart, char * string );
00141
00142 #endif
00143