VSF Documented
i_reg_uart.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __I_REG_UART_H__
19#define __I_REG_UART_H__
20
21/*============================ INCLUDES ======================================*/
22
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33/*============================ MACROS ========================================*/
34
35#ifndef __AIC8800_UART_USE_BIT_FIELD
36# define __AIC8800_UART_USE_BIT_FIELD ENABLED
37#endif
38
39/* Define structure member permissions : read only? */
40#ifndef __IM
41# define __IM const
42#endif
43
44/* Define structure member permissions : write only? */
45#ifndef __OM
46# define __OM
47#endif
48
49/* Define structure member permissions : read or write? */
50#ifndef __IOM
51# define __IOM
52#endif
53
54#define TXRXD_REG TXRXD.VALUE
55#define DIV0_REG DIV0.VALUE
56#define IRQCTL_REG IRQCTL.VALUE
57#define DIV1_REG DIV1.VALUE
58#define IRQTYP_REG IRQTYP.VALUE
59#define DBUFCFG_REG DBUFCFG.VALUE
60#define DFMTCFG_REG DFMTCFG.VALUE
61#define MDMCFG_REG MDMCFG.VALUE
62#define IRQSTS_REG IRQSTS.VALUE
63#define MDMSTS_REG MDMSTS.VALUE
64#define DBUFSTS_REG DBUFSTS.VALUE
65#define DBUFTH_REG DBUFTH.VALUE
66#define DIV2_REG DIV2.VALUE
67/* -------------------- TXRXD register -------------------------------------- */
68
69#define UART_RXDATA 0 /* 0x000000FF */
70#define UART_RXDATA_MSK ((reg32_t)(0xff << UART_RXDATA))
71
72#define UART_TXDATA 0 /* 0x000000FF */
73#define UART_TXDATA_MSK ((reg32_t)(0xff << UART_TXDATA))
74/* -------------------- DIV0 register --------------------------------------- */
75
76#define UART_DIV0 0 /* 0x000000FF */
77#define UART_DIV0_MSK ((reg32_t)(0xff << UART_DIV0))
78
79/* -------------------- IRQCTL register ------------------------------------- */
80
81#define UART_PTIRQEN 7 /* 0x00000080 */
82#define UART_PTIRQEN_MSK ((reg32_t)(0x1 << UART_PTIRQEN))
83
84#define UART_MSIRQEN 3 /* 0x00000008 */
85#define UART_MSIRQEN_MSK ((reg32_t)(0x1 << UART_MSIRQEN))
86
87#define UART_LSIRQEN 2 /* 0x00000004 */
88#define UART_LSIRQEN_MSK ((reg32_t)(0x1 << UART_LSIRQEN))
89
90#define UART_TXIRQEN 1 /* 0x00000002 */
91#define UART_TXIRQEN_MSK ((reg32_t)(0x1 << UART_TXIRQEN))
92
93#define UART_RXIRQEN 0 /* 0x00000001 */
94#define UART_RXIRQEN_MSK ((reg32_t)(0x1 << UART_RXIRQEN))
95
96/* -------------------- DIV1 register --------------------------------------- */
97
98#define UART_DIV1 0 /* 0x000000FF */
99#define UART_DIV1_MSK ((reg32_t)(0xff << UART_DIV1))
100
101/* -------------------- IRQTYP register ------------------------------------- */
102
103#define UART_IRQTYP 0 /* 0x0000000F */
104#define UART_IRQTYP_MSK ((reg32_t)(0xf << UART_IRQTYP))
105#define UART_IRQTYP_MODEM_INT 0x00
106#define UART_IRQTYP_NO_INT 0x01
107#define UART_IRQTYP_TX_INT 0x02
108#define UART_IRQTYP_RX_INT 0x04
109#define UART_IRQTYP_RX_ERROR_INT 0x06
110#define UART_IRQTYP_TIMEOUT_INT 0x0c
111
112/* -------------------- DBUFCFG register ------------------------------------ */
113
114#define UART_TXDRST 2 /* 0x00000004 */
115#define UART_TXDRST_MSK ((reg32_t)(0x1 << UART_TXDRST))
116
117#define UART_RXDRST 1 /* 0x00000002 */
118#define UART_RXDRST_MSK ((reg32_t)(0x1 << UART_RXDRST))
119
120#define UART_DBUFEN 0 /* 0x00000001 */
121#define UART_DBUFEN_MSK ((reg32_t)(0x1 << UART_DBUFEN))
122
123/* -------------------- DFMTCFG register ------------------------------------ */
124
125#define UART_DIVMS 8 /* 0x00000100 */
126#define UART1_DIVMS_MSK ((reg32_t)(0x1 << UART_DIVMS))
127
128#define UART_DIVAE 7 /* 0x00000080 */
129#define UART_DIVAE_MSK ((reg32_t)(0x1 << UART_DIVAE))
130
131#define UART_BRK 6 /* 0x00000040 */
132#define UART_BRK_MSK ((reg32_t)(0x1 << UART_BRK))
133
134#define UART_EPS 4 /* 0x00000010 */
135#define UART_EPS_MSK ((reg32_t)(0x1 << UART_EPS))
136
137#define UART_PEN 3 /* 0x00000008 */
138#define UART_PEN_MSK ((reg32_t)(0x1 << UART_PEN))
139
140#define UART_STOP 2 /* 0x00000004 */
141#define UART_STOP_MSK ((reg32_t)(0x1 << UART_STOP))
142
143#define UART_DLS 0 /* 0x00000003 */
144#define UART_DLS_MSK ((reg32_t)(0x3 << UART_DLS))
145
146/* -------------------- MDMCFG register ------------------------------------- */
147
148#define UART_CLK_P 8 /* 0x00000100 */
149#define UART_CLK_P_MSK ((reg32_t)(0x1 << UART_CLK_P))
150
151#define UART_AUTO_DET 7 /* 0x00000080 */
152#define UART_AUTO_DET_MSK ((reg32_t)(0x1 << UART_AUTO_DET))
153
154#define UART_SIRE 6 /* 0x00000040 */
155#define UART_SIRE_MSK ((reg32_t)(0x1 << UART_SIRE))
156
157#define UART_AFCE 5 /* 0x00000020 */
158#define UART_AFCE_MSK ((reg32_t)(0x1 << UART_AFCE))
159
160#define UART_LOOPBACK 4 /* 0x00000010 */
161#define UART_LOOPBACK_MSK ((reg32_t)(0x1 << UART_LOOPBACK))
162
163#define UART_OUT2 3 /* 0x00000008 */
164#define UART_OUT2_MSK ((reg32_t)(0x1 << UART_OUT2))
165
166#define UART_OUT1 2 /* 0x00000004 */
167#define UART_OUT1_MSK ((reg32_t)(0x1 << UART_OUT1))
168
169#define UART_RTS 1 /* 0x00000002 */
170#define UART_RTS_MSK ((reg32_t)(0x1 << UART_RTS))
171
172#define UART_DTR 0 /* 0x00000001 */
173#define UART_DTR_MSK ((reg32_t)(0x1 << UART_DTR))
174
175/* -------------------- IRQSTS register ------------------------------------- */
176
177#define UART_RTDR 8 /* 0x00000100 */
178#define UART_RTDR_MSK ((reg32_t)(0x1 << UART_RTDR))
179
180#define UART_RFE 7 /* 0x00000080 */
181#define UART_RFE_MSK ((reg32_t)(0x1 << UART_RFE))
182
183#define UART_TEMT 6 /* 0x00000040 */
184#define UART_TEMT_MSK ((reg32_t)(0x1 << UART_TEMT))
185
186#define UART_THRE 5 /* 0x00000020 */
187#define UART_THRE_MSK ((reg32_t)(0x1 << UART_THRE))
188
189#define UART_OE 1 /* 0x00000002 */
190#define UART_OE_MSK ((reg32_t)(0x1 << UART_OE))
191
192#define UART_DR 0 /* 0x00000001 */
193#define UART_DR_MSK ((reg32_t)(0x1 << UART_DR))
194
195/* -------------------- MDMSTS register ------------------------------------- */
196
197/* -------------------- DBUFSTS register ------------------------------------ */
198
199#define UART_RX_DBUF_FULL 21 /* 0x00200000 */
200#define UART_RX_DBUF_FULL_MSK ((reg32_t)(0x1 << UART_RX_DBUF_FULL))
201
202#define UART_RX_DBUF_EMPTY 20 /* 0x00100000 */
203#define UART_RX_DBUF_EMPTY_MSK ((reg32_t)(0x1 << UART_RX_DBUF_EMPTY))
204
205#define UART_TX_DBUF_FULL 19 /* 0x00080000 */
206#define UART_TX_DBUF_FULL_MSK ((reg32_t)(0x1 << UART_TX_DBUF_FULL))
207
208#define UART_TX_DBUF_EMPTY 18 /* 0x00040000 */
209#define UART_TX_DBUF_EMPTY_MSK ((reg32_t)(0x1 << UART_TX_DBUF_EMPTY))
210
211#define UART_RX_COUNT 9 /* 0x0001FE00 */
212#define UART_RX_COUNT_MSK ((reg32_t)(0xFF << UART_RX_COUNT))
213
214#define UART_TX_COUNT 0 /* 0x000000FF */
215#define UART_TX_COUNT_MSK ((reg32_t)(0xff << UART_TX_COUNT))
216
217/* -------------------- DBUFTH register ------------------------------------- */
218
219#define UART_TXTRIGTH 8 /* 0x0001FE00 */
220#define UART_TXTRIGTH_MSK ((reg32_t)(0x1fe << UART_TXTRIGTH))
221
222#define UART_RXTRIGTH 0 /* 0x000000FF */
223#define UART_RXTRIGTH_MSK ((reg32_t)(0xff << UART_RXTRIGTH))
224
225/* -------------------- DIV2 register --------------------------------------- */
226
227#define UART_DIV2 0 /* 0x000000FF */
228#define UART_DIV2_MSK ((reg32_t)(0xff << UART_DIV2))
229/*============================ MACROFIED FUNCTIONS ===========================*/
230
231#if __AIC8800_UART_USE_BIT_FIELD == ENABLED
232# define DEF_UART_REG(__NAME, __TOTAL_SIZE, ...) \
233 union { \
234 struct { \
235 __VA_ARGS__ \
236 }; \
237 reg##__TOTAL_SIZE##_t VALUE; \
238 } __NAME
239#else
240# define DEF_UART_REG(__NAME, __TOTAL_SIZE, ...) \
241 __VA_ARGS__ reg##__TOTAL_SIZE##_t __NAME
242#endif
243/*============================ TYPES =========================================*/
244
245typedef struct uart_reg_t {
246 union {
248 DEF_UART_REG(TXRXD, 32,
249 __IOM reg32_t TXRXDATA : 8;
250 reg32_t : 24;
251 );
252 DEF_UART_REG(DIV0, 32,
253 __IOM reg32_t DIV0 : 8;
254 reg32_t : 24;
255 );
256 };
257 union {
258 DEF_UART_REG(IRQCTL, 32,
259 __IOM reg32_t RXIRQEN : 1;
260 __IOM reg32_t TXIRQEN : 1;
261 __IOM reg32_t LSIRQEN : 1;
262 __IOM reg32_t MSIRQEN : 1;
263 reg32_t : 1;
264 reg32_t : 1;
265 reg32_t : 1;
266 __IOM reg32_t PTIRQEN : 1;
267 reg32_t : 24;
268 );
269 DEF_UART_REG(DIV1, 32,
270 __IOM reg32_t DIV1 : 8;
271 reg32_t : 24;
272 );
273 };
274 union {
275 DEF_UART_REG(IRQTYP, 32,
276 __IM reg32_t IRQTYP : 4;
277 reg32_t : 28;
278 );
279 DEF_UART_REG(DBUFCFG, 32,
280 __OM reg32_t DBUFEN : 1;
281 __OM reg32_t RXDRST : 1;
282 __OM reg32_t TXDRST : 1;
283 reg32_t : 29;
284 );
285 };
286 DEF_UART_REG(DFMTCFG, 32,
287 __IOM reg32_t DLS : 2;
288 __IOM reg32_t STOP : 1;
289 __IOM reg32_t PEN : 1;
290 __IOM reg32_t EPS : 1;
291 reg32_t : 1;
292 __IOM reg32_t BRK : 1;
293 __IOM reg32_t DIVAE : 1;
294 __IOM reg32_t DIVMS : 1;
295 reg32_t : 23;
296 );
297 DEF_UART_REG(MDMCFG, 32,
298 __IOM reg32_t DTR : 1;
299 __IOM reg32_t RTS : 1;
300 __IOM reg32_t OUT1 : 1;
301 __IOM reg32_t OUT2 : 1;
302 __IOM reg32_t LOOPBACK : 1;
303 __IOM reg32_t AFCE : 1;
304 __IOM reg32_t SIRE : 1;
305 __IOM reg32_t AUTO_DET : 1;
306 __IOM reg32_t CLK_P : 1;
307 reg32_t : 23;
308 );
309 DEF_UART_REG(IRQSTS, 32,
310 __IM reg32_t DR : 1;
311 __IM reg32_t OE : 1;
312 reg32_t : 1;
313 reg32_t : 1;
314 reg32_t : 1;
315 __IM reg32_t THRE : 1;
316 __IM reg32_t TEMT : 1;
317 __IM reg32_t RFE : 1;
318 __IM reg32_t RTDR : 1;
319 reg32_t : 23;
320 );
321 DEF_UART_REG(MDMSTS, 32,
322 __IM reg32_t MDMSTS : 32;
323 );
325 DEF_UART_REG(DBUFSTS, 32,
326 __IM reg32_t TX_COUNT : 8;
327 reg32_t : 1;
328 __IM reg32_t RX_COUNT : 8;
329 reg32_t : 1;
330 __IM reg32_t TX_DBUF_EMPTY : 1;
331 __IM reg32_t TX_DBUF_FULL : 1;
332 __IM reg32_t RX_DBUF_EMPTY : 1;
333 __IM reg32_t RX_DBUF_FULL : 1;
334 reg32_t : 10;
335 );
336 DEF_UART_REG(DBUFTH, 32,
337 __IOM reg32_t RXTRIGTH : 8;
338 reg32_t : 1;
339 __IOM reg32_t TXTRIGTH : 8;
340 reg32_t : 15;
341 );
342 DEF_UART_REG(DIV2, 32,
343 __IOM reg32_t DIV2 : 8;
344 reg32_t : 24;
345 );
347
348
349#ifdef __cplusplus
350}
351#endif
352
353#endif
354
355/* EOF */
volatile uint32_t reg32_t
Definition f1c100s_reg.h:1039
#define REG_RSVD_U32
Definition f1c100s_reg.h:1057
volatile uint32_t reg32_t
Definition i_io_systick.h:120
#define __OM
Definition i_reg_gpio.h:47
#define __IM
Definition i_reg_gpio.h:42
#define __IOM
Definition i_reg_gpio.h:52
#define DEF_UART_REG(__NAME, __TOTAL_SIZE,...)
Definition i_reg_uart.h:232
struct uart_reg_t uart_reg_t
Definition i_reg_uart.h:245
DEF_UART_REG(DIV2, 32, __IOM reg32_t DIV2 :8;reg32_t :24;)
DEF_UART_REG(MDMSTS, 32, __IM reg32_t MDMSTS :32;)
__IM reg32_t BASE_ADDR
Definition i_reg_uart.h:247
REG_RSVD_U32 DEF_UART_REG(DBUFSTS, 32, __IM reg32_t TX_COUNT :8;reg32_t :1;__IM reg32_t RX_COUNT :8;reg32_t :1;__IM reg32_t TX_DBUF_EMPTY :1;__IM reg32_t TX_DBUF_FULL :1;__IM reg32_t RX_DBUF_EMPTY :1;__IM reg32_t RX_DBUF_FULL :1;reg32_t :10;)
DEF_UART_REG(DFMTCFG, 32, __IOM reg32_t DLS :2;__IOM reg32_t STOP :1;__IOM reg32_t PEN :1;__IOM reg32_t EPS :1;reg32_t :1;__IOM reg32_t BRK :1;__IOM reg32_t DIVAE :1;__IOM reg32_t DIVMS :1;reg32_t :23;)
DEF_UART_REG(DBUFTH, 32, __IOM reg32_t RXTRIGTH :8;reg32_t :1;__IOM reg32_t TXTRIGTH :8;reg32_t :15;)
DEF_UART_REG(MDMCFG, 32, __IOM reg32_t DTR :1;__IOM reg32_t RTS :1;__IOM reg32_t OUT1 :1;__IOM reg32_t OUT2 :1;__IOM reg32_t LOOPBACK :1;__IOM reg32_t AFCE :1;__IOM reg32_t SIRE :1;__IOM reg32_t AUTO_DET :1;__IOM reg32_t CLK_P :1;reg32_t :23;)
DEF_UART_REG(IRQSTS, 32, __IM reg32_t DR :1;__IM reg32_t OE :1;reg32_t :1;reg32_t :1;reg32_t :1;__IM reg32_t THRE :1;__IM reg32_t TEMT :1;__IM reg32_t RFE :1;__IM reg32_t RTDR :1;reg32_t :23;)