summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc214x/lpc214x_uart.h
blob: 2752d17ae9ddc197d15dec292f5dbddf6c80eb24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/************************************************************************************
 * arch/arm/src/lpc214x/uart.h
 *
 *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
 *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name NuttX nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ************************************************************************************/

#ifndef __LPC214X_UART_H
#define __LPC214X_UART_H

/************************************************************************************
 * Included Files
 ************************************************************************************/

#include <arch/board/board.h> /* For clock settings */

/************************************************************************************
 * Definitions
 ************************************************************************************/

/* PINSEL0 bit definitions for UART0/1 */

#define LPC214X_UART0_PINSEL       0x00000005  /* PINSEL0 value for UART0 */
#define LPC214X_UART0_PINMASK      0x0000000f  /* PINSEL0 mask for UART0 */

#define LPC214X_UART1_PINSEL       0x00050000  /* PINSEL0 value for UART1 */
#define LPC214X_UART1_PINMASK      0x000f0000  /* PINSEL0 mask for UART1 */

/* Derive baud divisor setting from clock settings (see board.h) */

#define UART_BAUD(baud)            ((LPC214X_FOSC * LPC214X_PLL_M) / (baud * 16))

/* Interrupt Enable Register (IER) bit definitions */

#define LPC214X_IER_ERBFI          (1 << 0)    /* Enable receive data available int */
#define LPC214X_IER_ETBEI          (1 << 1)    /* Enable THR empty Interrupt */
#define LPC214X_IER_ELSI           (1 << 2)    /* Enable receive line status int */
#define LPC214X_IER_EDSSI          (1 << 3)    /* Enable MODEM atatus interrupt (2146/6/8 UART1 Only) */
#define LPC214X_IER_ALLIE          0x0f        /* All interrupts */

/* Interrupt ID Register(IIR) bit definitions */

#define LPC214X_IIR_NO_INT         (1 << 0)    /* No interrupts pending  */
#define LPC214X_IIR_MS_INT         (0 << 1)    /* MODEM Status (UART1 only) */
#define LPC214X_IIR_THRE_INT       (1 << 1)    /* Transmit Holding Register Empty */
#define LPC214X_IIR_RDA_INT        (2 << 1)    /* Receive Data Available */
#define LPC214X_IIR_RLS_INT        (3 << 1)    /* Receive Line Status */
#define LPC214X_IIR_CTI_INT        (6 << 1)    /* Character Timeout Indicator */
#define LPC214X_IIR_MASK           0x0e

/* FIFO Control Register (FCR) bit definitions */

#define LPC214X_FCR_FIFO_ENABLE    (1 << 0)    /* FIFO enable */
#define LPC214X_FCR_RX_FIFO_RESET  (1 << 1)    /* Reset receive FIFO */
#define LPC214X_FCR_TX_FIFO_RESET  (1 << 2)    /* Reset transmit FIFO */
#define LPC214X_FCR_FIFO_TRIG1     (0 << 6)    /* Trigger @1 character in FIFO */
#define LPC214X_FCR_FIFO_TRIG4     (1 << 6)    /* Trigger @4 characters in FIFO */
#define LPC214X_FCR_FIFO_TRIG8     (2 << 6)    /* Trigger @8 characters in FIFO */
#define LPC214X_FCR_FIFO_TRIG14    (3 << 6)    /* Trigger @14 characters in FIFO */

/* Line Control Register (LCR) bit definitions */

#define LPC214X_LCR_CHAR_5         (0 << 0)    /* 5-bit character length */
#define LPC214X_LCR_CHAR_6         (1 << 0)    /* 6-bit character length */
#define LPC214X_LCR_CHAR_7         (2 << 0)    /* 7-bit character length */
#define LPC214X_LCR_CHAR_8         (3 << 0)    /* 8-bit character length */
#define LPC214X_LCR_STOP_1         (0 << 2)    /* 1 stop bit */
#define LPC214X_LCR_STOP_2         (1 << 2)    /* 2 stop bits */
#define LPC214X_LCR_PAR_NONE       (0 << 3)    /* No parity */
#define LPC214X_LCR_PAR_ODD        (1 << 3)    /* Odd parity */
#define LPC214X_LCR_PAR_EVEN       (3 << 3)    /* Even parity */
#define LPC214X_LCR_PAR_MARK       (5 << 3)    /* Mark "1" parity */
#define LPC214X_LCR_PAR_SPACE      (7 << 3)    /* Space "0" parity */
#define LPC214X_LCR_BREAK_ENABLE   (1 << 6)    /* Output BREAK */
#define LPC214X_LCR_DLAB_ENABLE    (1 << 7)    /* Enable divisor latch access */

/* Modem Control Register (MCR) bit definitions */

#define LPC214X_MCR_DTR            (1 << 0)    /* Data terminal ready */
#define LPC214X_MCR_RTS            (1 << 1)    /* Request to send */
#define LPC214X_MCR_LB             (1 << 4)    /* Loopback */

/* Line Status Register (LSR) bit definitions */

#define LPC214X_LSR_RDR            (1 << 0)    /* Receive data ready */
#define LPC214X_LSR_OE             (1 << 1)    /* Overrun error */
#define LPC214X_LSR_PE             (1 << 2)    /* Parity error */
#define LPC214X_LSR_FE             (1 << 3)    /* Framing error */
#define LPC214X_LSR_BI             (1 << 4)    /* Break interrupt */
#define LPC214X_LSR_THRE           (1 << 5)    /* THR empty */
#define LPC214X_LSR_TEMT           (1 << 6)    /* Transmitter empty */
#define LPC214X_LSR_RXFE           (1 << 7)    /* Error in receive FIFO */
#define LPC214X_LSR_ERR_MASK       0x1e

/* Modem Status Register (MSR) bit definitions */

#define LPC214X_MSR_DCTS           (1 << 0)    /* Delta clear to send */
#define LPC214X_MSR_DDSR           (1 << 1)    /* Delta data set ready */
#define LPC214X_MSR_TERI           (1 << 2)    /* Trailing edge ring indicator */
#define LPC214X_MSR_DDCD           (1 << 3)    /* Delta data carrier detect */
#define LPC214X_MSR_CTS            (1 << 4)    /* Clear to send */
#define LPC214X_MSR_DSR            (1 << 5)    /* Data set ready */
#define LPC214X_MSR_RI             (1 << 6)    /* Ring indicator */
#define LPC214X_MSR_DCD            (1 << 7)    /* Data carrier detect */

/************************************************************************************
 * Inline Functions
 ************************************************************************************/

/************************************************************************************
 * Global Function Prototypes
 ************************************************************************************/

#endif  /* __LPC214X_UART_H */