| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usart_002.h
Go to the documentation of this file.
1 /*
2 * @brief UART/USART2 Registers and control functions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #ifndef __USART_002_H_
33 #define __USART_002_H_
34
35 #include "sys_config.h"
36 #include "cmsis.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
50 typedef struct {
51 __IO uint32_t CFG;
52 __IO uint32_t CTRL;
53 __IO uint32_t STAT;
54 __IO uint32_t INTENSET;
55 __O uint32_t INTENCLR;
56 __I uint32_t RXDATA;
57 __I uint32_t RXDATA_STAT;
58 __IO uint32_t TXDATA;
59 __IO uint32_t BRG;
60 __IO uint32_t INTSTAT;
61 } IP_USART_002_T;
62
66 typedef enum IP_UART_002_PARITY {
67 UART_PARITY_NONE = (0x00 << 4),
68 UART_PARITY_EVEN = (0x02 << 4),
69 UART_PARITY_ODD = (0x03 << 4)
70 } IP_UART_002_PARITY_T;
71
75 typedef enum IP_UART_002_FITO_LEVEL {
76 UART_FIFO_TRGLEV0 = 0,
77 UART_FIFO_TRGLEV1,
78 UART_FIFO_TRGLEV2,
79 UART_FIFO_TRGLEV3
80 } IP_UART_002_FITO_LEVEL_T;
81
85 typedef enum IP_UART_002_STOPLEN {
86 UART_STOPLEN_1 = (0 << 6),
87 UART_STOPLEN_2 = (1 << 6)
88 } IP_UART_002_STOPLEN_T;
89
93 typedef enum IP_UART_002_DATALEN {
94 UART_DATALEN_7 = (0x00 << 2),
95 UART_DATALEN_8 = (0x01 << 2),
96 UART_DATALEN_9 = (0x02 << 2)
97 } IP_UART_002_DATALEN_T;
98
102 typedef enum IP_UART_002_CLKPOL {
103 UART_CLKPOL_FALLING = (0 << 12),
104 UART_CLKPOL_RISING = (1 << 12)
105 } IP_UART_002_CLKPOL_T;
106
107 /* UART interrupt bit definitions */
108 #define RXRDY_INT (0x01 << 0)
109 #define TXRDY_INT (0x01 << 2)
110 #define CTS_DELTA_INT (0x01 << 5)
111 #define TXINT_DIS_INT (0x01 << 6)
112 #define OVRN_ERR_INT (0x01 << 8)
113 #define DELTA_RXBRK_INT (0x01 << 11)
114 #define START_DETECT_INT (0x01 << 12)
115 #define FRM_ERR_INT (0x01 << 13)
116 #define PAR_ERR_INT (0x01 << 14)
117 #define RXNOISE_INT (0x01 << 15)
119 /* UART status bit definitions */
120 #define RXRDY (0x01 << 0)
121 #define RXIDLE (0x01 << 1)
122 #define TXRDY (0x01 << 2)
123 #define TXIDLE (0x01 << 3)
124 #define CTS (0x01 << 4)
125 #define CTS_DELTA (0x01 << 5)
126 #define TXINT_DIS (0x01 << 6)
127 #define OVRN_ERR (0x01 << 8)
128 #define RXBRK (0x01 << 10)
129 #define DELTA_RXBRK (0x01 << 11)
130 #define START_DETECT (0x01 << 12)
131 #define FRM_ERR (0x01 << 13)
132 #define PAR_ERR (0x01 << 14)
133 #define RXNOISE (0x01 << 15)
135 #define UART_002_SYNCEN(n) ((n) == ENABLE ? (1 << 11) : 0)
136 #define UART_002_ENABLE (1UL)
137
143 STATIC INLINE void IP_UART_Init(IP_USART_002_T *pUART)
144 {
145 pUART->CFG |= UART_002_ENABLE;
146 }
147
154 STATIC INLINE void IP_UART_SetBaudRate(IP_USART_002_T *pUART, uint32_t baudrate)
155 {
156 pUART->BRG = baudrate;
157 }
158
164 STATIC INLINE uint32_t IP_UART_GetBaudRate(IP_USART_002_T *pUART)
165 {
166 return pUART->BRG;
167 }
168
175 STATIC INLINE void IP_UART_Transmit(IP_USART_002_T *pUART, uint8_t data)
176 {
177 pUART->TXDATA = data;
178 }
179
185 STATIC INLINE uint8_t IP_UART_Receive(IP_USART_002_T *pUART)
186 {
187 return (uint8_t) (pUART->RXDATA & 0xFF);
188 }
189
195 STATIC INLINE uint32_t IP_UART_GetIntStatus(IP_USART_002_T *pUART)
196 {
197 return pUART->INTSTAT;
198 }
199
205 STATIC INLINE uint32_t IP_UART_GetStatus(IP_USART_002_T *pUART)
206 {
207 return pUART->STAT;
208 }
209
216 STATIC INLINE void IP_UART_ClearStatus(IP_USART_002_T *pUART, uint32_t StatusFlag)
217 {
218 pUART->STAT |= StatusFlag;
219 }
220
229 void IP_UART_Config(IP_USART_002_T *pUART, IP_UART_002_DATALEN_T Databits,
230 IP_UART_002_PARITY_T Parity, IP_UART_002_STOPLEN_T Stopbits);
231
239 void IP_UART_IntEnable(IP_USART_002_T *pUART, uint32_t UARTIntCfg, FunctionalState NewState);
240
245 #ifdef __cplusplus
246 }
247 #endif
248
249 #endif /* __USART_002_H_ */