LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 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;
59  __IO uint32_t BRG;
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)
71 
75 typedef enum IP_UART_002_FITO_LEVEL {
81 
85 typedef enum IP_UART_002_STOPLEN {
86  UART_STOPLEN_1 = (0 << 6),
87  UART_STOPLEN_2 = (1 << 6)
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)
98 
102 typedef enum IP_UART_002_CLKPOL {
103  UART_CLKPOL_FALLING = (0 << 12),
104  UART_CLKPOL_RISING = (1 << 12)
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 
144 {
145  pUART->CFG |= UART_002_ENABLE;
146 }
147 
155 {
156  pUART->BRG = baudrate;
157 }
158 
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 
186 {
187  return (uint8_t) (pUART->RXDATA & 0xFF);
188 }
189 
196 {
197  return pUART->INTSTAT;
198 }
199 
206 {
207  return pUART->STAT;
208 }
209 
217 {
218  pUART->STAT |= StatusFlag;
219 }
220 
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_ */