4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
33 * \version $Id: at91_aic.h 18260 2007-10-11 14:08:10Z batt $
35 * \author Daniele Basile <asterix@develer.com>
37 * AT91 UART User interface.
38 * This file is based on NUT/OS implementation. See license below.
41 * Copyright (C) 2005-2006 by egnite Software GmbH. All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. Neither the name of the copyright holders nor the names of
53 * contributors may be used to endorse or promote products derived
54 * from this software without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
57 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
59 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
60 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
61 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
62 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
63 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
64 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
65 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
66 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * For additional information see http://www.ethernut.de/
76 * USART Control Register
79 #define US_CR_OFF 0x00000000 ///< USART control register offset.
80 #define US0_CR (*((volatile uint32_t *)(USART0_BASE + US_CR_OFF) ///< Channel 0 control register address.
81 #define US1_CR (*((volatile uint32_t *)(USART1_BASE + US_CR_OFF) ///< Channel 1 control register address.
82 #define US_RSTRX 2 ///< Reset receiver. */
83 #define US_RSTTX 3 ///< Reset transmitter.
84 #define US_RXEN 4 ///< Receiver enable.
85 #define US_RXDIS 5 ///< Receiver disable.
86 #define US_TXEN 6 ///< Transmitter enable.
87 #define US_TXDIS 7 ///< Transmitter disable.
88 #define US_RSTSTA 8 ///< Reset status bits.
89 #define US_STTBRK 9 ///< Start break.
90 #define US_STPBRK 10 ///< Stop break.
91 #define US_STTTO 11 ///< Start timeout.
92 #define US_SENDA 12 ///< Send next byte with address bit set.
93 #define US_RSTIT 13 ///< Reset interations.
94 #define US_RTSNAK 14 ///< Reset non acknowledge.
95 #define US_RETTO 15 ///< Rearm time out.
96 #define US_DTREN 16 ///< Data terminal ready enable.
97 #define US_DTRDIS 17 ///< Data terminal ready disable.
98 #define US_RTSEN 18 ///< Request to send enable.
99 #define US_RTSDIS 19 ///< Request to send disable.
106 #define US_MR_OFF 0x00000004 ///< USART mode register offset.
107 #define US0_MR (*((volatile uint32_t *)(USART0_BASE + US_MR_OFF) ///< Channel 0 mode register address.
108 #define US1_MR (*((volatile uint32_t *)(USART1_BASE + US_MR_OFF) ///< Channel 1 mode register address.
110 #define US_USART_MODE_MASK 0x0000000F ///< USART mode mask.
111 #define US_USART_MODE_NORMA 0x00000000 ///< Normal.
112 #define US_USART_MODE_RS485 0x00000001 ///< RS485.
113 #define US_USART_MODE_HW_HDSH 0x00000002 ///< Hardware handshaking.
114 #define US_USART_MODE_MODEM 0x00000003 ///< Modem.
115 #define US_USART_MODE_ISO7816T0 0x00000004 ///< ISO7816 protocol: T=0.
116 #define US_USART_MODE_ISO7816T1 0x00000006 ///< ISO7816 protocol: T=1.
117 #define US_USART_MODE_RS485 0x00000008 ///< IrDA.
119 #define US_CLKS_MASK 0x00000030 ///< Clock selection mask.
120 #define US_CLKS_MCK 0x00000000 ///< Master clock.
121 #define US_CLKS_MCK8 0x00000010 ///< Master clock divided by 8.
122 #define US_CLKS_SCK 0x00000020 ///< External clock.
123 #define US_CLKS_SLCK 0x00000030 ///< Slow clock.
125 #define US_CHRL_MASK 0x000000C0 ///< Masks data length.
126 #define US_CHRL_5 0x00000000 ///< 5 data bits.
127 #define US_CHRL_6 0x00000040 ///< 6 data bits.
128 #define US_CHRL_7 0x00000080 ///< 7 data bits.
129 #define US_CHRL_8 0x000000C0 ///< 8 data bits.
131 #define US_SYNC 8 ///< Synchronous mode enable.
133 #define US_PAR_MASK 0x00000E00 ///< Parity mode mask.
134 #define US_PAR_EVEN 0x00000000 ///< Even parity.
135 #define US_PAR_ODD 0x00000200 ///< Odd parity.
136 #define US_PAR_SPACE 0x00000400 ///< Space parity.
137 #define US_PAR_MARK 0x00000600 ///< Marked parity.
138 #define US_PAR_NO 0x00000800 ///< No parity.
139 #define US_PAR_MULTIDROP 0x00000C00 ///< Multi-drop mode.
141 #define US_NBSTOP_MASK 0x00003000 ///< Masks stop bit length.
142 #define US_NBSTOP_1 0x00000000 ///< 1 stop bit.
143 #define US_NBSTOP_1_5 0x00001000 ///< 1.5 stop bits.
144 #define US_NBSTOP_2 0x00002000 ///< 2 stop bits.
146 #define US_CHMODE_MASK 0x0000C000 ///< Channel mode mask.
147 #define US_CHMODE_NORMAL 0x00000000 ///< Normal mode.
148 #define US_CHMODE_AUTOMATIC_ECHO 0x00004000 ///< Automatic echo.
149 #define US_CHMODE_LOCAL_LOOPBACK 0x00008000 ///< Local loopback.
150 #define US_CHMODE_REMOTE_LOOPBACK 0x0000C000 ///< Remote loopback.
152 #define US_MSBF 16 ///< Bit order.
153 #define US_MODE9 17 ///< 9 bit mode.
154 #define US_CLKO 18 ///< Clock output select.
155 #define US_OVER 19 ///< Oversampling mode.
156 #define US_INACK 20 ///< Inhibit non acknowledge.
157 #define US_DSNACK 21 ///< Disable successive nack.
159 #define US_MAX_INTERATION_MASK 0x07000000 ///< Max numer of interation in mode ISO7816 T=0.
161 #define US_FILTER 28 ///< Infrared receive line filter.
166 * Status and Interrupt Register
169 #define US_IER_OFF 0x00000008 ///< USART interrupt enable register offset.
170 #define US0_IER (*((volatile uint32_t *)(USART0_BASE + US_IER_OFF) ///< Channel 0 interrupt enable register address.
171 #define US1_IER (*((volatile uint32_t *)(USART1_BASE + US_IER_OFF) ///< Channel 1 interrupt enable register address.
173 #define US_IDR_OFF 0x0000000C ///< USART interrupt disable register offset.
174 #define US0_IDR (*((volatile uint32_t *)(USART0_BASE + US_IDR_OFF) ///< Channel 0 interrupt disable register address.
175 #define US1_IDR (*((volatile uint32_t *)(USART1_BASE + US_IDR_OFF) ///< Channel 1 interrupt disable register address.
177 #define US_IMR_OFF 0x00000010 ///< USART interrupt mask register offset.
178 #define US0_IMR (*((volatile uint32_t *)(USART0_BASE + US_IMR_OFF) ///< Channel 0 interrupt mask register address.
179 #define US1_IMR (*((volatile uint32_t *)(USART1_BASE + US_IMR_OFF) ///< Channel 1 interrupt mask register address.
181 #define US_CSR_OFF 0x00000014 ///< USART status register offset.
182 #define US0_CSR (*((volatile uint32_t *)(USART0_BASE + US_CSR_OFF) ///< Channel 0 status register address.
183 #define US1_CSR (*((volatile uint32_t *)(USART1_BASE + US_CSR_OFF) ///< Channel 1 status register address.
184 #define US_CSR_RI 20 ///< Image of RI input.
185 #define US_CSR_DSR 21 ///< Image of DSR input.
186 #define US_CSR_DCD 22 ///< Image of DCD input.
187 #define US_CSR_CTS 23 ///< Image of CTS input.
189 #define US_RXRDY 0 ///< Receiver ready.
190 #define US_TXRDY 1 ///< Transmitter ready.
191 #define US_RXBRK 2 ///< Receiver break.
192 #define US_ENDRX 3 ///< End of receiver PDC transfer.
193 #define US_ENDTX 4 ///< End of transmitter PDC transfer.
194 #define US_OVRE 5 ///< Overrun error.
195 #define US_FRAME 6 ///< Framing error.
196 #define US_PARE 7 ///< Parity error.
197 #define US_TIMEOUT 8 ///< Receiver timeout.
198 #define US_TXEMPTY 9 ///< Transmitter empty.
199 #define US_ITERATION 10 ///< Iteration interrupt enable.
200 #define US_TXBUFE 11 ///< Buffer empty interrupt enable.
201 #define US_RXBUFF 12 ///< Buffer full interrupt enable.
202 #define US_NACK 13 ///< Non acknowledge interrupt enable.
203 #define US_RIIC 16 ///< Ring indicator input change enable.
204 #define US_DSRIC 17 ///< Data set ready input change enable.
205 #define US_DCDIC 18 ///< Data carrier detect input change interrupt enable.
206 #define US_CTSIC 19 ///< Clear to send input change interrupt enable.
209 * Receiver Holding Register
212 #define US_RHR_OFF 0x00000018 ///< USART receiver holding register offset.
213 #define US0_RHR (*((volatile uint32_t *)(USART0_BASE + US_RHR_OFF) ///< Channel 0 receiver holding register address.
214 #define US1_RHR (*((volatile uint32_t *)(USART1_BASE + US_RHR_OFF) ///< Channel 1 receiver holding register address.
215 #define US_RHR_RXCHR_MASK 0x000001FF ///< Last char received if US_RXRDY is set.
216 #define US_RHR_RXSYNH 15 ///< Received sync.
220 * Transmitter Holding Register
223 #define US_THR_OFF 0x0000001C ///< USART transmitter holding register offset.
224 #define US0_THR (*((volatile uint32_t *)(USART0_BASE + US_THR_OFF) ///< Channel 0 transmitter holding register address.
225 #define US1_THR (*((volatile uint32_t *)(USART1_BASE + US_THR_OFF) ///< Channel 1 transmitter holding register address.
226 #define US_THR_TXCHR_MASK 0x000001FF ///< Next char to be trasmitted.
227 #define US_THR_TXSYNH 15 ///< Sync field to be trasmitted.
231 * Baud Rate Generator Register
234 #define US_BRGR_OFF 0x00000020 ///< USART baud rate register offset.
235 #define US0_BRGR (*((volatile uint32_t *)(USART0_BASE + US_BRGR_OFF) ///< Channel 0 baud rate register address.
236 #define US1_BRGR (*((volatile uint32_t *)(USART1_BASE + US_BRGR_OFF) ///< Channel 1 baud rate register address.
237 #define US_BRGR_MASK 0x0000FFFF ///< Clock divider.
238 #define US_BRGR_FP_MASK 0x001F0000 ///< Fractional part.
242 * Receiver Timeout Register
245 #define US_RTOR_OFF 0x00000024 ///< USART receiver timeout register offset.
246 #define US0_RTOR (*((volatile uint32_t *)(USART0_BASE + US_RTOR_OFF) ///< Channel 0 receiver timeout register address.
247 #define US1_RTOR (*((volatile uint32_t *)(USART1_BASE + US_RTOR_OFF) ///< Channel 1 receiver timeout register address.
251 * Transmitter Time Guard Register
254 #define US_TTGR_OFF 0x00000028 ///< USART transmitter time guard register offset.
255 #define US0_TTGR (*((volatile uint32_t *)(USART0_BASE + US_TTGR_OFF) ///< Channel 0 transmitter time guard register address.
256 #define US1_TTGR (*((volatile uint32_t *)(USART1_BASE + US_TTGR_OFF) ///< Channel 1 transmitter time guard register address.
260 * FI DI Ratio Register
263 #define US_FIDI_OFF 0x00000040 ///< USART FI DI ratio register offset.
264 #define US0_FIDI (*((volatile uint32_t *)(USART0_BASE + US_FIDI_OFF) ///< Channel 0 FI DI ratio register address.
265 #define US1_FIDI (*((volatile uint32_t *)(USART1_BASE + US_FIDI_OFF) ///< Channel 1 FI DI ratio register address.
269 * Error Counter Register
272 #define US_NER_OFF 0x00000044 ///< USART error counter register offset.
273 #define US0_NER (*((volatile uint32_t *)(USART0_BASE + US_NER_OFF) ///< Channel 0 error counter register address.
274 #define US1_NER (*((volatile uint32_t *)(USART1_BASE + US_NER_OFF) ///< Channel 1 error counter register address.
278 * IrDA Filter Register
281 #define US_IF_OFF 0x0000004C ///< USART IrDA filter register offset.
282 #define US0_IF (*((volatile uint32_t *)(USART0_BASE + US_IF_OFF) ///< Channel 0 IrDA filter register address.
283 #define US1_IF (*((volatile uint32_t *)(USART1_BASE + US_IF_OFF) ///< Channel 1 IrDA filter register address.
286 #if defined(*((volatile uint32_t *)(USART_HAS_PDC)
289 * Receive Pointer Register
292 #define US0_RPR (*((volatile uint32_t *)(USART0_BASE + PERIPH_RPR_OFF) ///< Channel 0 receive pointer register address.
293 #define US1_RPR (*((volatile uint32_t *)(USART1_BASE + PERIPH_RPR_OFF) ///< Channel 1 receive pointer register address.
297 * Receive Counter Register
300 #define US0_RCR (*((volatile uint32_t *)(USART0_BASE + PERIPH_RCR_OFF) ///< Channel 0 receive counter register address.
301 #define US1_RCR (*((volatile uint32_t *)(USART1_BASE + PERIPH_RCR_OFF) ///< Channel 1 receive counter register address.
305 * Transmit Pointer Register
308 #define US0_TPR (*((volatile uint32_t *)(USART0_BASE + PERIPH_TPR_OFF) ///< Channel 0 transmit pointer register address.
309 #define US1_TPR (*((volatile uint32_t *)(USART1_BASE + PERIPH_TPR_OFF) ///< Channel 1 transmit pointer register address.
313 * Name Transmit Counter Register
316 #define US0_TCR (*((volatile uint32_t *)(USART0_BASE + PERIPH_TCR_OFF) ///< Channel 0 transmit counter register address.
317 #define US1_TCR (*((volatile uint32_t *)(USART1_BASE + PERIPH_TCR_OFF) ///< Channel 1 transmit counter register address.
320 #if defined(PERIPH_RNPR_OFF) && defined(PERIPH_RNCR_OFF)
321 #define US0_RNPR (*((volatile uint32_t *)(USART0_BASE + PERIPH_RNPR_OFF) ///< PDC channel 0 receive next pointer register.
322 #define US1_RNPR (*((volatile uint32_t *)(USART1_BASE + PERIPH_RNPR_OFF) ///< PDC channel 1 receive next pointer register.
323 #define US0_RNCR (*((volatile uint32_t *)(USART0_BASE + PERIPH_RNCR_OFF) ///< PDC channel 0 receive next counter register.
324 #define US1_RNCR (*((volatile uint32_t *)(USART1_BASE + PERIPH_RNCR_OFF) ///< PDC channel 1 receive next counter register.
327 #if defined(PERIPH_TNPR_OFF) && defined(PERIPH_TNCR_OFF)
328 #define US0_TNPR (*((volatile uint32_t *)(USART0_BASE + PERIPH_TNPR_OFF) ///< PDC channel 0 transmit next pointer register.
329 #define US1_TNPR (*((volatile uint32_t *)(USART1_BASE + PERIPH_TNPR_OFF) ///< PDC channel 1 transmit next pointer register.
330 #define US0_TNCR (*((volatile uint32_t *)(USART0_BASE + PERIPH_TNCR_OFF) ///< PDC channel 0 transmit next counter register.
331 #define US1_TNCR (*((volatile uint32_t *)(USART1_BASE + PERIPH_TNCR_OFF) ///< PDC channel 1 transmit next counter register.
334 #if defined(PERIPH_PTCR_OFF)
335 #define US0_PTCR (*((volatile uint32_t *)(USART0_BASE + PERIPH_PTCR_OFF) ///< PDC channel 0 transfer control register.
336 #define US1_PTCR (*((volatile uint32_t *)(USART1_BASE + PERIPH_PTCR_OFF) ///< PDC channel 1 transfer control register.
339 #if defined(PERIPH_PTSR_OFF)
340 #define US0_PTSR (*((volatile uint32_t *)(USART0_BASE + PERIPH_PTSR_OFF) ///< PDC channel 0 transfer status register.
341 #define US1_PTSR (*((volatile uint32_t *)(USART1_BASE + PERIPH_PTSR_OFF) ///< PDC channel 1 transfer status register.
344 #endif /* USART_HAS_PDC */
347 #endif /* _AT91_US_H_ */