Robobo
component_usart.h
1 /* ----------------------------------------------------------------------------
2  * SAM Software Package License
3  * ----------------------------------------------------------------------------
4  * Copyright (c) 2012, Atmel Corporation
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following condition is met:
10  *
11  * - Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the disclaimer below.
13  *
14  * Atmel's name may not be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * ----------------------------------------------------------------------------
28  */
29 
30 #ifndef _SAM3U_USART_COMPONENT_
31 #define _SAM3U_USART_COMPONENT_
32 
33 /* ============================================================================= */
35 /* ============================================================================= */
38 
39 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
40 
41 typedef struct {
42  WoReg US_CR;
43  RwReg US_MR;
44  WoReg US_IER;
45  WoReg US_IDR;
46  RoReg US_IMR;
47  RoReg US_CSR;
48  RoReg US_RHR;
49  WoReg US_THR;
50  RwReg US_BRGR;
51  RwReg US_RTOR;
52  RwReg US_TTGR;
53  RoReg Reserved1[5];
54  RwReg US_FIDI;
55  RoReg US_NER;
56  RoReg Reserved2[1];
57  RwReg US_IF;
58  RwReg US_MAN;
59  RoReg Reserved3[36];
60  RwReg US_WPMR;
61  RoReg US_WPSR;
62  RoReg Reserved4[5];
63  RwReg US_RPR;
64  RwReg US_RCR;
65  RwReg US_TPR;
66  RwReg US_TCR;
67  RwReg US_RNPR;
68  RwReg US_RNCR;
69  RwReg US_TNPR;
70  RwReg US_TNCR;
71  WoReg US_PTCR;
72  RoReg US_PTSR;
73 } Usart;
74 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
75 /* -------- US_CR : (USART Offset: 0x0000) Control Register -------- */
76 #define US_CR_RSTRX (0x1u << 2)
77 #define US_CR_RSTTX (0x1u << 3)
78 #define US_CR_RXEN (0x1u << 4)
79 #define US_CR_RXDIS (0x1u << 5)
80 #define US_CR_TXEN (0x1u << 6)
81 #define US_CR_TXDIS (0x1u << 7)
82 #define US_CR_RSTSTA (0x1u << 8)
83 #define US_CR_STTBRK (0x1u << 9)
84 #define US_CR_STPBRK (0x1u << 10)
85 #define US_CR_STTTO (0x1u << 11)
86 #define US_CR_SENDA (0x1u << 12)
87 #define US_CR_RSTIT (0x1u << 13)
88 #define US_CR_RSTNACK (0x1u << 14)
89 #define US_CR_RETTO (0x1u << 15)
90 #define US_CR_DTREN (0x1u << 16)
91 #define US_CR_DTRDIS (0x1u << 17)
92 #define US_CR_RTSEN (0x1u << 18)
93 #define US_CR_FCS (0x1u << 18)
94 #define US_CR_RTSDIS (0x1u << 19)
95 #define US_CR_RCS (0x1u << 19)
96 /* -------- US_MR : (USART Offset: 0x0004) Mode Register -------- */
97 #define US_MR_USART_MODE_Pos 0
98 #define US_MR_USART_MODE_Msk (0xfu << US_MR_USART_MODE_Pos)
99 #define US_MR_USART_MODE_NORMAL (0x0u << 0)
100 #define US_MR_USART_MODE_RS485 (0x1u << 0)
101 #define US_MR_USART_MODE_HW_HANDSHAKING (0x2u << 0)
102 #define US_MR_USART_MODE_MODEM (0x3u << 0)
103 #define US_MR_USART_MODE_IS07816_T_0 (0x4u << 0)
104 #define US_MR_USART_MODE_IS07816_T_1 (0x6u << 0)
105 #define US_MR_USART_MODE_IRDA (0x8u << 0)
106 #define US_MR_USART_MODE_SPI_MASTER (0xEu << 0)
107 #define US_MR_USART_MODE_SPI_SLAVE (0xFu << 0)
108 #define US_MR_USCLKS_Pos 4
109 #define US_MR_USCLKS_Msk (0x3u << US_MR_USCLKS_Pos)
110 #define US_MR_USCLKS_MCK (0x0u << 4)
111 #define US_MR_USCLKS_DIV (0x1u << 4)
112 #define US_MR_USCLKS_SCK (0x3u << 4)
113 #define US_MR_CHRL_Pos 6
114 #define US_MR_CHRL_Msk (0x3u << US_MR_CHRL_Pos)
115 #define US_MR_CHRL_5_BIT (0x0u << 6)
116 #define US_MR_CHRL_6_BIT (0x1u << 6)
117 #define US_MR_CHRL_7_BIT (0x2u << 6)
118 #define US_MR_CHRL_8_BIT (0x3u << 6)
119 #define US_MR_SYNC (0x1u << 8)
120 #define US_MR_CPHA (0x1u << 8)
121 #define US_MR_PAR_Pos 9
122 #define US_MR_PAR_Msk (0x7u << US_MR_PAR_Pos)
123 #define US_MR_PAR_EVEN (0x0u << 9)
124 #define US_MR_PAR_ODD (0x1u << 9)
125 #define US_MR_PAR_SPACE (0x2u << 9)
126 #define US_MR_PAR_MARK (0x3u << 9)
127 #define US_MR_PAR_NO (0x4u << 9)
128 #define US_MR_PAR_MULTIDROP (0x6u << 9)
129 #define US_MR_NBSTOP_Pos 12
130 #define US_MR_NBSTOP_Msk (0x3u << US_MR_NBSTOP_Pos)
131 #define US_MR_NBSTOP_1_BIT (0x0u << 12)
132 #define US_MR_NBSTOP_1_5_BIT (0x1u << 12)
133 #define US_MR_NBSTOP_2_BIT (0x2u << 12)
134 #define US_MR_CHMODE_Pos 14
135 #define US_MR_CHMODE_Msk (0x3u << US_MR_CHMODE_Pos)
136 #define US_MR_CHMODE_NORMAL (0x0u << 14)
137 #define US_MR_CHMODE_AUTOMATIC (0x1u << 14)
138 #define US_MR_CHMODE_LOCAL_LOOPBACK (0x2u << 14)
139 #define US_MR_CHMODE_REMOTE_LOOPBACK (0x3u << 14)
140 #define US_MR_MSBF (0x1u << 16)
141 #define US_MR_CPOL (0x1u << 16)
142 #define US_MR_MODE9 (0x1u << 17)
143 #define US_MR_CLKO (0x1u << 18)
144 #define US_MR_OVER (0x1u << 19)
145 #define US_MR_INACK (0x1u << 20)
146 #define US_MR_DSNACK (0x1u << 21)
147 #define US_MR_VAR_SYNC (0x1u << 22)
148 #define US_MR_INVDATA (0x1u << 23)
149 #define US_MR_MAX_ITERATION_Pos 24
150 #define US_MR_MAX_ITERATION_Msk (0x7u << US_MR_MAX_ITERATION_Pos)
151 #define US_MR_MAX_ITERATION(value) ((US_MR_MAX_ITERATION_Msk & ((value) << US_MR_MAX_ITERATION_Pos)))
152 #define US_MR_FILTER (0x1u << 28)
153 #define US_MR_MAN (0x1u << 29)
154 #define US_MR_MODSYNC (0x1u << 30)
155 #define US_MR_ONEBIT (0x1u << 31)
156 /* -------- US_IER : (USART Offset: 0x0008) Interrupt Enable Register -------- */
157 #define US_IER_RXRDY (0x1u << 0)
158 #define US_IER_TXRDY (0x1u << 1)
159 #define US_IER_RXBRK (0x1u << 2)
160 #define US_IER_ENDRX (0x1u << 3)
161 #define US_IER_ENDTX (0x1u << 4)
162 #define US_IER_OVRE (0x1u << 5)
163 #define US_IER_FRAME (0x1u << 6)
164 #define US_IER_PARE (0x1u << 7)
165 #define US_IER_TIMEOUT (0x1u << 8)
166 #define US_IER_TXEMPTY (0x1u << 9)
167 #define US_IER_ITER (0x1u << 10)
168 #define US_IER_UNRE (0x1u << 10)
169 #define US_IER_TXBUFE (0x1u << 11)
170 #define US_IER_RXBUFF (0x1u << 12)
171 #define US_IER_NACK (0x1u << 13)
172 #define US_IER_RIIC (0x1u << 16)
173 #define US_IER_DSRIC (0x1u << 17)
174 #define US_IER_DCDIC (0x1u << 18)
175 #define US_IER_CTSIC (0x1u << 19)
176 #define US_IER_MANE (0x1u << 24)
177 /* -------- US_IDR : (USART Offset: 0x000C) Interrupt Disable Register -------- */
178 #define US_IDR_RXRDY (0x1u << 0)
179 #define US_IDR_TXRDY (0x1u << 1)
180 #define US_IDR_RXBRK (0x1u << 2)
181 #define US_IDR_ENDRX (0x1u << 3)
182 #define US_IDR_ENDTX (0x1u << 4)
183 #define US_IDR_OVRE (0x1u << 5)
184 #define US_IDR_FRAME (0x1u << 6)
185 #define US_IDR_PARE (0x1u << 7)
186 #define US_IDR_TIMEOUT (0x1u << 8)
187 #define US_IDR_TXEMPTY (0x1u << 9)
188 #define US_IDR_ITER (0x1u << 10)
189 #define US_IDR_UNRE (0x1u << 10)
190 #define US_IDR_TXBUFE (0x1u << 11)
191 #define US_IDR_RXBUFF (0x1u << 12)
192 #define US_IDR_NACK (0x1u << 13)
193 #define US_IDR_RIIC (0x1u << 16)
194 #define US_IDR_DSRIC (0x1u << 17)
195 #define US_IDR_DCDIC (0x1u << 18)
196 #define US_IDR_CTSIC (0x1u << 19)
197 #define US_IDR_MANE (0x1u << 24)
198 /* -------- US_IMR : (USART Offset: 0x0010) Interrupt Mask Register -------- */
199 #define US_IMR_RXRDY (0x1u << 0)
200 #define US_IMR_TXRDY (0x1u << 1)
201 #define US_IMR_RXBRK (0x1u << 2)
202 #define US_IMR_ENDRX (0x1u << 3)
203 #define US_IMR_ENDTX (0x1u << 4)
204 #define US_IMR_OVRE (0x1u << 5)
205 #define US_IMR_FRAME (0x1u << 6)
206 #define US_IMR_PARE (0x1u << 7)
207 #define US_IMR_TIMEOUT (0x1u << 8)
208 #define US_IMR_TXEMPTY (0x1u << 9)
209 #define US_IMR_ITER (0x1u << 10)
210 #define US_IMR_UNRE (0x1u << 10)
211 #define US_IMR_TXBUFE (0x1u << 11)
212 #define US_IMR_RXBUFF (0x1u << 12)
213 #define US_IMR_NACK (0x1u << 13)
214 #define US_IMR_RIIC (0x1u << 16)
215 #define US_IMR_DSRIC (0x1u << 17)
216 #define US_IMR_DCDIC (0x1u << 18)
217 #define US_IMR_CTSIC (0x1u << 19)
218 #define US_IMR_MANE (0x1u << 24)
219 /* -------- US_CSR : (USART Offset: 0x0014) Channel Status Register -------- */
220 #define US_CSR_RXRDY (0x1u << 0)
221 #define US_CSR_TXRDY (0x1u << 1)
222 #define US_CSR_RXBRK (0x1u << 2)
223 #define US_CSR_ENDRX (0x1u << 3)
224 #define US_CSR_ENDTX (0x1u << 4)
225 #define US_CSR_OVRE (0x1u << 5)
226 #define US_CSR_FRAME (0x1u << 6)
227 #define US_CSR_PARE (0x1u << 7)
228 #define US_CSR_TIMEOUT (0x1u << 8)
229 #define US_CSR_TXEMPTY (0x1u << 9)
230 #define US_CSR_ITER (0x1u << 10)
231 #define US_CSR_UNRE (0x1u << 10)
232 #define US_CSR_TXBUFE (0x1u << 11)
233 #define US_CSR_RXBUFF (0x1u << 12)
234 #define US_CSR_NACK (0x1u << 13)
235 #define US_CSR_RIIC (0x1u << 16)
236 #define US_CSR_DSRIC (0x1u << 17)
237 #define US_CSR_DCDIC (0x1u << 18)
238 #define US_CSR_CTSIC (0x1u << 19)
239 #define US_CSR_RI (0x1u << 20)
240 #define US_CSR_DSR (0x1u << 21)
241 #define US_CSR_DCD (0x1u << 22)
242 #define US_CSR_CTS (0x1u << 23)
243 #define US_CSR_MANERR (0x1u << 24)
244 /* -------- US_RHR : (USART Offset: 0x0018) Receiver Holding Register -------- */
245 #define US_RHR_RXCHR_Pos 0
246 #define US_RHR_RXCHR_Msk (0x1ffu << US_RHR_RXCHR_Pos)
247 #define US_RHR_RXSYNH (0x1u << 15)
248 /* -------- US_THR : (USART Offset: 0x001C) Transmitter Holding Register -------- */
249 #define US_THR_TXCHR_Pos 0
250 #define US_THR_TXCHR_Msk (0x1ffu << US_THR_TXCHR_Pos)
251 #define US_THR_TXCHR(value) ((US_THR_TXCHR_Msk & ((value) << US_THR_TXCHR_Pos)))
252 #define US_THR_TXSYNH (0x1u << 15)
253 /* -------- US_BRGR : (USART Offset: 0x0020) Baud Rate Generator Register -------- */
254 #define US_BRGR_CD_Pos 0
255 #define US_BRGR_CD_Msk (0xffffu << US_BRGR_CD_Pos)
256 #define US_BRGR_CD(value) ((US_BRGR_CD_Msk & ((value) << US_BRGR_CD_Pos)))
257 #define US_BRGR_FP_Pos 16
258 #define US_BRGR_FP_Msk (0x7u << US_BRGR_FP_Pos)
259 #define US_BRGR_FP(value) ((US_BRGR_FP_Msk & ((value) << US_BRGR_FP_Pos)))
260 /* -------- US_RTOR : (USART Offset: 0x0024) Receiver Time-out Register -------- */
261 #define US_RTOR_TO_Pos 0
262 #define US_RTOR_TO_Msk (0xffffu << US_RTOR_TO_Pos)
263 #define US_RTOR_TO(value) ((US_RTOR_TO_Msk & ((value) << US_RTOR_TO_Pos)))
264 /* -------- US_TTGR : (USART Offset: 0x0028) Transmitter Timeguard Register -------- */
265 #define US_TTGR_TG_Pos 0
266 #define US_TTGR_TG_Msk (0xffu << US_TTGR_TG_Pos)
267 #define US_TTGR_TG(value) ((US_TTGR_TG_Msk & ((value) << US_TTGR_TG_Pos)))
268 /* -------- US_FIDI : (USART Offset: 0x0040) FI DI Ratio Register -------- */
269 #define US_FIDI_FI_DI_RATIO_Pos 0
270 #define US_FIDI_FI_DI_RATIO_Msk (0x7ffu << US_FIDI_FI_DI_RATIO_Pos)
271 #define US_FIDI_FI_DI_RATIO(value) ((US_FIDI_FI_DI_RATIO_Msk & ((value) << US_FIDI_FI_DI_RATIO_Pos)))
272 /* -------- US_NER : (USART Offset: 0x0044) Number of Errors Register -------- */
273 #define US_NER_NB_ERRORS_Pos 0
274 #define US_NER_NB_ERRORS_Msk (0xffu << US_NER_NB_ERRORS_Pos)
275 /* -------- US_IF : (USART Offset: 0x004C) IrDA Filter Register -------- */
276 #define US_IF_IRDA_FILTER_Pos 0
277 #define US_IF_IRDA_FILTER_Msk (0xffu << US_IF_IRDA_FILTER_Pos)
278 #define US_IF_IRDA_FILTER(value) ((US_IF_IRDA_FILTER_Msk & ((value) << US_IF_IRDA_FILTER_Pos)))
279 /* -------- US_MAN : (USART Offset: 0x0050) Manchester Encoder Decoder Register -------- */
280 #define US_MAN_TX_PL_Pos 0
281 #define US_MAN_TX_PL_Msk (0xfu << US_MAN_TX_PL_Pos)
282 #define US_MAN_TX_PL(value) ((US_MAN_TX_PL_Msk & ((value) << US_MAN_TX_PL_Pos)))
283 #define US_MAN_TX_PP_Pos 8
284 #define US_MAN_TX_PP_Msk (0x3u << US_MAN_TX_PP_Pos)
285 #define US_MAN_TX_PP_ALL_ONE (0x0u << 8)
286 #define US_MAN_TX_PP_ALL_ZERO (0x1u << 8)
287 #define US_MAN_TX_PP_ZERO_ONE (0x2u << 8)
288 #define US_MAN_TX_PP_ONE_ZERO (0x3u << 8)
289 #define US_MAN_TX_MPOL (0x1u << 12)
290 #define US_MAN_RX_PL_Pos 16
291 #define US_MAN_RX_PL_Msk (0xfu << US_MAN_RX_PL_Pos)
292 #define US_MAN_RX_PL(value) ((US_MAN_RX_PL_Msk & ((value) << US_MAN_RX_PL_Pos)))
293 #define US_MAN_RX_PP_Pos 24
294 #define US_MAN_RX_PP_Msk (0x3u << US_MAN_RX_PP_Pos)
295 #define US_MAN_RX_PP_ALL_ONE (0x0u << 24)
296 #define US_MAN_RX_PP_ALL_ZERO (0x1u << 24)
297 #define US_MAN_RX_PP_ZERO_ONE (0x2u << 24)
298 #define US_MAN_RX_PP_ONE_ZERO (0x3u << 24)
299 #define US_MAN_RX_MPOL (0x1u << 28)
300 #define US_MAN_STUCKTO1 (0x1u << 29)
301 #define US_MAN_DRIFT (0x1u << 30)
302 /* -------- US_WPMR : (USART Offset: 0xE4) Write Protect Mode Register -------- */
303 #define US_WPMR_WPEN (0x1u << 0)
304 #define US_WPMR_WPKEY_Pos 8
305 #define US_WPMR_WPKEY_Msk (0xffffffu << US_WPMR_WPKEY_Pos)
306 #define US_WPMR_WPKEY(value) ((US_WPMR_WPKEY_Msk & ((value) << US_WPMR_WPKEY_Pos)))
307 /* -------- US_WPSR : (USART Offset: 0xE8) Write Protect Status Register -------- */
308 #define US_WPSR_WPVS (0x1u << 0)
309 #define US_WPSR_WPVSRC_Pos 8
310 #define US_WPSR_WPVSRC_Msk (0xffffu << US_WPSR_WPVSRC_Pos)
311 /* -------- US_RPR : (USART Offset: 0x100) Receive Pointer Register -------- */
312 #define US_RPR_RXPTR_Pos 0
313 #define US_RPR_RXPTR_Msk (0xffffffffu << US_RPR_RXPTR_Pos)
314 #define US_RPR_RXPTR(value) ((US_RPR_RXPTR_Msk & ((value) << US_RPR_RXPTR_Pos)))
315 /* -------- US_RCR : (USART Offset: 0x104) Receive Counter Register -------- */
316 #define US_RCR_RXCTR_Pos 0
317 #define US_RCR_RXCTR_Msk (0xffffu << US_RCR_RXCTR_Pos)
318 #define US_RCR_RXCTR(value) ((US_RCR_RXCTR_Msk & ((value) << US_RCR_RXCTR_Pos)))
319 /* -------- US_TPR : (USART Offset: 0x108) Transmit Pointer Register -------- */
320 #define US_TPR_TXPTR_Pos 0
321 #define US_TPR_TXPTR_Msk (0xffffffffu << US_TPR_TXPTR_Pos)
322 #define US_TPR_TXPTR(value) ((US_TPR_TXPTR_Msk & ((value) << US_TPR_TXPTR_Pos)))
323 /* -------- US_TCR : (USART Offset: 0x10C) Transmit Counter Register -------- */
324 #define US_TCR_TXCTR_Pos 0
325 #define US_TCR_TXCTR_Msk (0xffffu << US_TCR_TXCTR_Pos)
326 #define US_TCR_TXCTR(value) ((US_TCR_TXCTR_Msk & ((value) << US_TCR_TXCTR_Pos)))
327 /* -------- US_RNPR : (USART Offset: 0x110) Receive Next Pointer Register -------- */
328 #define US_RNPR_RXNPTR_Pos 0
329 #define US_RNPR_RXNPTR_Msk (0xffffffffu << US_RNPR_RXNPTR_Pos)
330 #define US_RNPR_RXNPTR(value) ((US_RNPR_RXNPTR_Msk & ((value) << US_RNPR_RXNPTR_Pos)))
331 /* -------- US_RNCR : (USART Offset: 0x114) Receive Next Counter Register -------- */
332 #define US_RNCR_RXNCTR_Pos 0
333 #define US_RNCR_RXNCTR_Msk (0xffffu << US_RNCR_RXNCTR_Pos)
334 #define US_RNCR_RXNCTR(value) ((US_RNCR_RXNCTR_Msk & ((value) << US_RNCR_RXNCTR_Pos)))
335 /* -------- US_TNPR : (USART Offset: 0x118) Transmit Next Pointer Register -------- */
336 #define US_TNPR_TXNPTR_Pos 0
337 #define US_TNPR_TXNPTR_Msk (0xffffffffu << US_TNPR_TXNPTR_Pos)
338 #define US_TNPR_TXNPTR(value) ((US_TNPR_TXNPTR_Msk & ((value) << US_TNPR_TXNPTR_Pos)))
339 /* -------- US_TNCR : (USART Offset: 0x11C) Transmit Next Counter Register -------- */
340 #define US_TNCR_TXNCTR_Pos 0
341 #define US_TNCR_TXNCTR_Msk (0xffffu << US_TNCR_TXNCTR_Pos)
342 #define US_TNCR_TXNCTR(value) ((US_TNCR_TXNCTR_Msk & ((value) << US_TNCR_TXNCTR_Pos)))
343 /* -------- US_PTCR : (USART Offset: 0x120) Transfer Control Register -------- */
344 #define US_PTCR_RXTEN (0x1u << 0)
345 #define US_PTCR_RXTDIS (0x1u << 1)
346 #define US_PTCR_TXTEN (0x1u << 8)
347 #define US_PTCR_TXTDIS (0x1u << 9)
348 /* -------- US_PTSR : (USART Offset: 0x124) Transfer Status Register -------- */
349 #define US_PTSR_RXTEN (0x1u << 0)
350 #define US_PTSR_TXTEN (0x1u << 8)
353 
354 
355 #endif /* _SAM3U_USART_COMPONENT_ */
volatile uint32_t RwReg
Definition: sam3n00a.h:54
volatile uint32_t WoReg
Definition: sam3n00a.h:53
Usart hardware registers.
Definition: component_usart.h:41
volatile const uint32_t RoReg
Definition: sam3n00a.h:49