1 /* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
\r
3 /*This file is prepared for Doxygen automatic documentation generation.*/
\r
4 /*! \file *********************************************************************
\r
6 * \brief NEWLIB_ADDONS USART include file for AVR32.
\r
8 * - Compiler: GNU GCC for AVR32
\r
9 * - Supported devices: All AVR32 devices can be used.
\r
12 * \author Atmel Corporation: http://www.atmel.com \n
\r
13 * Support and FAQ: http://support.atmel.no/
\r
15 ******************************************************************************/
\r
17 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
\r
19 * Redistribution and use in source and binary forms, with or without
\r
20 * modification, are permitted provided that the following conditions are met:
\r
22 * 1. Redistributions of source code must retain the above copyright notice, this
\r
23 * list of conditions and the following disclaimer.
\r
25 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
26 * this list of conditions and the following disclaimer in the documentation
\r
27 * and/or other materials provided with the distribution.
\r
29 * 3. The name of Atmel may not be used to endorse or promote products derived
\r
30 * from this software without specific prior written permission.
\r
32 * 4. This software may only be redistributed and used in connection with an Atmel
\r
35 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
\r
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
37 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
38 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
\r
39 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
41 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
\r
42 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
\r
48 #ifndef __AVR32_NEWLIB_ADDONS_USART_H__
\r
49 #define __AVR32_NEWLIB_ADDONS_USART_H__
\r
53 #include "nlao_io.h"
\r
60 volatile u32 us_ier;
\r
61 volatile u32 us_idr;
\r
62 volatile u32 us_imr;
\r
63 volatile u32 us_csr;
\r
64 volatile u32 us_rhr;
\r
65 volatile u32 us_thr;
\r
66 volatile u32 us_brgr;
\r
67 volatile u32 us_rtor;
\r
68 volatile u32 us_ttgr;
\r
69 volatile u32 us_reserved[5];
\r
70 volatile u32 us_fidi;
\r
71 volatile u32 us_ner;
\r
72 volatile u32 us_xxr;
\r
76 /* Register offsets */
\r
77 #define US_CR 0x0000
\r
78 #define US_MR 0x0004
\r
79 #define US_IER 0x0008
\r
80 #define US_IDR 0x000c
\r
81 #define US_IMR 0x0010
\r
82 #define US_CSR 0x0014
\r
83 #define US_RHR 0x0018
\r
84 #define US_THR 0x001c
\r
85 #define US_BRGR 0x0020
\r
86 #define US_RTOR 0x0024
\r
87 #define US_TTGR 0x0028
\r
89 #define US_FIDI 0x0040
\r
90 #define US_NER 0x0044
\r
91 #define US_XXR 0x0048
\r
92 #define US_IF 0x004c
\r
94 #define US_RPR 0x0100
\r
95 #define US_RCR 0x0104
\r
96 #define US_TPR 0x0108
\r
97 #define US_TCR 0x010c
\r
98 #define US_RNPR 0x0110
\r
99 #define US_RNCR 0x0114
\r
100 #define US_TNPR 0x0118
\r
101 #define US_TNCR 0x011c
\r
102 #define US_PTCR 0x0120
\r
103 #define US_PTSR 0x0124
\r
108 /* USART3 Control Register */
\r
109 #define US_CR_RSTRX (1 << 2)
\r
110 #define US_CR_RSTTX (1 << 3)
\r
111 #define US_CR_RXEN (1 << 4)
\r
112 #define US_CR_RXDIS (1 << 5)
\r
113 #define US_CR_TXEN (1 << 6)
\r
114 #define US_CR_TXDIS (1 << 7)
\r
115 #define US_CR_RSTSTA (1 << 8)
\r
116 #define US_CR_STTBRK (1 << 9)
\r
117 #define US_CR_STPBRK (1 << 10)
\r
119 #define US_CR_DTREN (1 << 16)
\r
120 #define US_CR_DTRDIS (1 << 17)
\r
121 #define US_CR_RTSEN (1 << 18)
\r
122 #define US_CR_RTSDIS (1 << 19)
\r
124 /* USART3 Mode Register */
\r
125 #define US_MR_MODE (15 << 0)
\r
126 #define US_MR_MODE_NORMAL ( 0 << 0)
\r
127 #define US_MR_MODE_HWFLOW ( 2 << 0)
\r
128 #define US_MR_CLKS ( 3 << 4)
\r
129 #define US_MR_CLKS_CLOCK ( 0 << 4)
\r
130 #define US_MR_CLKS_FDIV1 ( 1 << 4)
\r
131 #define US_MR_CLKS_SLOW ( 2 << 4)
\r
132 #define US_MR_CLKS_EXT ( 3 << 4)
\r
133 #define US_MR_CHRL_5BITS ( 0 << 6)
\r
134 #define US_MR_CHRL_6BITS ( 1 << 6)
\r
135 #define US_MR_CHRL_7BITS ( 2 << 6)
\r
136 #define US_MR_CHRL_8BITS ( 3 << 6)
\r
137 #define US_MR_SYNC ( 1 << 8)
\r
138 #define US_MR_PAR_EVEN ( 0 << 9)
\r
139 #define US_MR_PAR_ODD ( 1 << 9)
\r
140 #define US_MR_PAR_SPACE ( 2 << 9)
\r
141 #define US_MR_PAR_MARK ( 3 << 9)
\r
142 #define US_MR_PAR_NONE ( 4 << 9)
\r
143 #define US_MR_PAR_MDROP ( 6 << 9)
\r
144 #define US_MR_NBSTOP_1BIT ( 0 << 12)
\r
145 #define US_MR_NBSTOP_1_5BIT ( 1 << 12)
\r
146 #define US_MR_NBSTOP_2BITS ( 2 << 12)
\r
147 #define US_MR_OVER ( 1 << 19)
\r
148 #define US_MR_OVER_X16 ( 0 << 19)
\r
149 #define US_MR_OVER_X8 ( 1 << 19)
\r
151 /* USART3 Channel Status Register */
\r
152 #define US_CSR_RXRDY (1 << 0)
\r
153 #define US_CSR_TXRDY (1 << 1)
\r
154 #define US_CSR_RXBRK (1 << 2)
\r
155 #define US_CSR_ENDRX (1 << 3)
\r
156 #define US_CSR_ENDTX (1 << 4)
\r
159 #define US_CSR_OVRE (1 << 5)
\r
160 #define US_CSR_FRAME (1 << 6)
\r
161 #define US_CSR_PARE (1 << 7)
\r
163 #define US_CSR_TXEMPTY (1 << 9)
\r
165 #define US_CSR_TXBUFE (1 << 11)
\r
166 #define US_CSR_RXBUFF (1 << 12)
\r
167 #define US_CSR_RIIC (1 << 16)
\r
168 #define US_CSR_DSRIC (1 << 17)
\r
169 #define US_CSR_DCDIC (1 << 18)
\r
170 #define US_CSR_CTSIC (1 << 19)
\r
171 #define US_CSR_RI (1 << 20)
\r
172 #define US_CSR_DSR (1 << 21)
\r
173 #define US_CSR_DCD (1 << 22)
\r
174 #define US_CSR_CTS (1 << 23)
\r
176 /* USART3 Baud Rate Generator Register */
\r
177 #define US_BRGR_CD_OFFSET 0
\r
178 #define US_BRGR_FP_OFFSET 16
\r
180 #define US_BRGR_CD_SIZE 16
\r
181 #define US_BRGR_FP_SIZE 3
\r
183 #define US_BRGR_CD (0xFFFF << 0)
\r
184 #define US_BRGR_FP ( 7 << 16)
\r
186 /*USART3 PDC Transfer Control Register */
\r
187 #define US_PTCR_RXTEN (1 << 0)
\r
188 #define US_PTCR_RXTDIS (1 << 1)
\r
189 #define US_PTCR_TXTEN (1 << 8)
\r
190 #define US_PTCR_TXTDIS (1 << 9)
\r
192 /*USART3 PDC Transfer Status Register */
\r
193 #define US_PTSR_RXTEN (1 << 0)
\r
194 #define US_PTSR_TXTEN (1 << 8)
\r
197 int usart_init(int baudrate);
\r
198 void usart_putc(char c);
\r
199 void usart_puts(const char *s);
\r
200 int usart_getc(void);
\r
201 int usart_tstc(void);
\r
202 void usart_setbrg(int baudrate, int cpu_clock);
\r
203 void set_usart_base(void *usart_base);
\r
208 #endif /* MERLIN_USART3_H */
\r