1 |
207 |
jeremybenn |
/* uart.h. UART constant definitions.
|
2 |
|
|
|
3 |
|
|
Copyright (C) 2004, Jacob Bower
|
4 |
|
|
Copyright (C) 2010, Embecosm Limited <info@embecosm.com>
|
5 |
|
|
|
6 |
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
7 |
|
|
|
8 |
|
|
This file is part of Newlib.
|
9 |
|
|
|
10 |
|
|
The original work by Jacob Bower is provided as-is without any kind of
|
11 |
|
|
warranty. Use it at your own risk!
|
12 |
|
|
|
13 |
|
|
All subsequent work is bound by version 3 of the GPL as follows.
|
14 |
|
|
|
15 |
|
|
This program is free software; you can redistribute it and/or modify it
|
16 |
|
|
under the terms of the GNU General Public License as published by the Free
|
17 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
18 |
|
|
any later version.
|
19 |
|
|
|
20 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
23 |
|
|
more details.
|
24 |
|
|
|
25 |
|
|
You should have received a copy of the GNU General Public License along
|
26 |
|
|
with this program. If not, see <http:#www.gnu.org/licenses/>. */
|
27 |
|
|
/* -------------------------------------------------------------------------- */
|
28 |
|
|
/* This program is commented throughout in a fashion suitable for processing
|
29 |
|
|
with Doxygen. */
|
30 |
|
|
/* -------------------------------------------------------------------------- */
|
31 |
|
|
#ifndef UART__H
|
32 |
|
|
#define UART__H
|
33 |
|
|
|
34 |
|
|
#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
|
35 |
|
|
#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
|
36 |
|
|
#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
|
37 |
|
|
#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
|
38 |
|
|
#define UART_IER 1 /* Out: Interrupt Enable Register */
|
39 |
|
|
#define UART_IIR 2 /* In: Interrupt ID Register */
|
40 |
|
|
#define UART_FCR 2 /* Out: FIFO Control Register */
|
41 |
|
|
#define UART_EFR 2 /* I/O: Extended Features Register */
|
42 |
|
|
/* (DLAB=1, 16C660 only) */
|
43 |
|
|
#define UART_LCR 3 /* Out: Line Control Register */
|
44 |
|
|
#define UART_MCR 4 /* Out: Modem Control Register */
|
45 |
|
|
#define UART_LSR 5 /* In: Line Status Register */
|
46 |
|
|
#define UART_MSR 6 /* In: Modem Status Register */
|
47 |
|
|
#define UART_SCR 7 /* I/O: Scratch Register */
|
48 |
|
|
|
49 |
|
|
/*
|
50 |
|
|
* These are the definitions for the FIFO Control Register
|
51 |
|
|
* (16650 only)
|
52 |
|
|
*/
|
53 |
|
|
#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
|
54 |
|
|
#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */
|
55 |
|
|
#define UART_FCR_CLEAR_XMIT 0x04 /* Clear the XMIT FIFO */
|
56 |
|
|
#define UART_FCR_DMA_SELECT 0x08 /* For DMA applications */
|
57 |
|
|
#define UART_FCR_TRIGGER_MASK 0xC0 /* Mask for the FIFO trigger range */
|
58 |
|
|
#define UART_FCR_TRIGGER_1 0x00 /* Mask for trigger set at 1 */
|
59 |
|
|
#define UART_FCR_TRIGGER_4 0x40 /* Mask for trigger set at 4 */
|
60 |
|
|
#define UART_FCR_TRIGGER_8 0x80 /* Mask for trigger set at 8 */
|
61 |
|
|
#define UART_FCR_TRIGGER_14 0xC0 /* Mask for trigger set at 14 */
|
62 |
|
|
/* 16650 redefinitions */
|
63 |
|
|
#define UART_FCR6_R_TRIGGER_8 0x00 /* Mask for receive trigger set at 1 */
|
64 |
|
|
#define UART_FCR6_R_TRIGGER_16 0x40 /* Mask for receive trigger set at 4 */
|
65 |
|
|
#define UART_FCR6_R_TRIGGER_24 0x80 /* Mask for receive trigger set at 8 */
|
66 |
|
|
#define UART_FCR6_R_TRIGGER_28 0xC0 /* Mask for receive trigger set at 14 */
|
67 |
|
|
#define UART_FCR6_T_TRIGGER_16 0x00 /* Mask for transmit trigger set at 16 */
|
68 |
|
|
#define UART_FCR6_T_TRIGGER_8 0x10 /* Mask for transmit trigger set at 8 */
|
69 |
|
|
#define UART_FCR6_T_TRIGGER_24 0x20 /* Mask for transmit trigger set at 24 */
|
70 |
|
|
#define UART_FCR6_T_TRIGGER_30 0x30 /* Mask for transmit trigger set at 30 */
|
71 |
|
|
|
72 |
|
|
/*
|
73 |
|
|
* These are the definitions for the Line Control Register
|
74 |
|
|
*
|
75 |
|
|
* Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting
|
76 |
|
|
* UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits.
|
77 |
|
|
*/
|
78 |
|
|
#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
|
79 |
|
|
#define UART_LCR_SBC 0x40 /* Set break control */
|
80 |
|
|
#define UART_LCR_SPAR 0x20 /* Stick parity (?) */
|
81 |
|
|
#define UART_LCR_EPAR 0x10 /* Even parity select */
|
82 |
|
|
#define UART_LCR_PARITY 0x08 /* Parity Enable */
|
83 |
|
|
#define UART_LCR_STOP 0x04 /* Stop bits: 0=1 stop bit, 1= 2 stop bits */
|
84 |
|
|
#define UART_LCR_WLEN5 0x00 /* Wordlength: 5 bits */
|
85 |
|
|
#define UART_LCR_WLEN6 0x01 /* Wordlength: 6 bits */
|
86 |
|
|
#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */
|
87 |
|
|
#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
|
88 |
|
|
|
89 |
|
|
/*
|
90 |
|
|
* These are the definitions for the Line Status Register
|
91 |
|
|
*/
|
92 |
|
|
#define UART_LSR_TEMT 0x40 /* Transmitter empty */
|
93 |
|
|
#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
|
94 |
|
|
#define UART_LSR_BI 0x10 /* Break interrupt indicator */
|
95 |
|
|
#define UART_LSR_FE 0x08 /* Frame error indicator */
|
96 |
|
|
#define UART_LSR_PE 0x04 /* Parity error indicator */
|
97 |
|
|
#define UART_LSR_OE 0x02 /* Overrun error indicator */
|
98 |
|
|
#define UART_LSR_DR 0x01 /* Receiver data ready */
|
99 |
|
|
|
100 |
|
|
/*
|
101 |
|
|
* These are the definitions for the Interrupt Identification Register
|
102 |
|
|
*/
|
103 |
|
|
#define UART_IIR_NO_INT 0x01 /* No interrupts pending */
|
104 |
|
|
#define UART_IIR_ID 0x06 /* Mask for the interrupt ID */
|
105 |
|
|
|
106 |
|
|
#define UART_IIR_MSI 0x00 /* Modem status interrupt */
|
107 |
|
|
#define UART_IIR_THRI 0x02 /* Transmitter holding register empty */
|
108 |
|
|
#define UART_IIR_TOI 0x0c /* Receive time out interrupt */
|
109 |
|
|
#define UART_IIR_RDI 0x04 /* Receiver data interrupt */
|
110 |
|
|
#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */
|
111 |
|
|
|
112 |
|
|
/*
|
113 |
|
|
* These are the definitions for the Interrupt Enable Register
|
114 |
|
|
*/
|
115 |
|
|
#define UART_IER_MSI 0x08 /* Enable Modem status interrupt */
|
116 |
|
|
#define UART_IER_RLSI 0x04 /* Enable receiver line status interrupt */
|
117 |
|
|
#define UART_IER_THRI 0x02 /* Enable Transmitter holding register int. */
|
118 |
|
|
#define UART_IER_RDI 0x01 /* Enable receiver data interrupt */
|
119 |
|
|
|
120 |
|
|
/*
|
121 |
|
|
* These are the definitions for the Modem Control Register
|
122 |
|
|
*/
|
123 |
|
|
#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
|
124 |
|
|
#define UART_MCR_OUT2 0x08 /* Out2 complement */
|
125 |
|
|
#define UART_MCR_OUT1 0x04 /* Out1 complement */
|
126 |
|
|
#define UART_MCR_RTS 0x02 /* RTS complement */
|
127 |
|
|
#define UART_MCR_DTR 0x01 /* DTR complement */
|
128 |
|
|
|
129 |
|
|
/*
|
130 |
|
|
* These are the definitions for the Modem Status Register
|
131 |
|
|
*/
|
132 |
|
|
#define UART_MSR_DCD 0x80 /* Data Carrier Detect */
|
133 |
|
|
#define UART_MSR_RI 0x40 /* Ring Indicator */
|
134 |
|
|
#define UART_MSR_DSR 0x20 /* Data Set Ready */
|
135 |
|
|
#define UART_MSR_CTS 0x10 /* Clear to Send */
|
136 |
|
|
#define UART_MSR_DDCD 0x08 /* Delta DCD */
|
137 |
|
|
#define UART_MSR_TERI 0x04 /* Trailing edge ring indicator */
|
138 |
|
|
#define UART_MSR_DDSR 0x02 /* Delta DSR */
|
139 |
|
|
#define UART_MSR_DCTS 0x01 /* Delta CTS */
|
140 |
|
|
#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */
|
141 |
|
|
|
142 |
|
|
/*
|
143 |
|
|
* These are the definitions for the Extended Features Register
|
144 |
|
|
* (StarTech 16C660 only, when DLAB=1)
|
145 |
|
|
*/
|
146 |
|
|
#define UART_EFR_CTS 0x80 /* CTS flow control */
|
147 |
|
|
#define UART_EFR_RTS 0x40 /* RTS flow control */
|
148 |
|
|
#define UART_EFR_SCD 0x20 /* Special character detect */
|
149 |
|
|
#define UART_EFR_ENI 0x10 /* Enhanced Interrupt */
|
150 |
|
|
|
151 |
|
|
/* The library functions defined here, avoiding namespace polution. */
|
152 |
399 |
jeremybenn |
extern void __uart_init ();
|
153 |
|
|
extern void __uart_putc (char c);
|
154 |
|
|
extern char __uart_getc ();
|
155 |
207 |
jeremybenn |
|
156 |
|
|
#endif /* UART__H */
|