Tiva Driver Lib
uart.h
1 //*****************************************************************************
2 //
3 // uart.h - Defines and Macros for the UART.
4 //
5 // Copyright (c) 2005-2013 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 1.1 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __DRIVERLIB_UART_H__
41 #define __DRIVERLIB_UART_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Values that can be passed to UARTIntEnable, UARTIntDisable, and UARTIntClear
57 // as the ui32IntFlags parameter, and returned from UARTIntStatus.
58 //
59 //*****************************************************************************
60 #define UART_INT_9BIT 0x1000 // 9-bit address match interrupt
61 #define UART_INT_OE 0x400 // Overrun Error Interrupt Mask
62 #define UART_INT_BE 0x200 // Break Error Interrupt Mask
63 #define UART_INT_PE 0x100 // Parity Error Interrupt Mask
64 #define UART_INT_FE 0x080 // Framing Error Interrupt Mask
65 #define UART_INT_RT 0x040 // Receive Timeout Interrupt Mask
66 #define UART_INT_TX 0x020 // Transmit Interrupt Mask
67 #define UART_INT_RX 0x010 // Receive Interrupt Mask
68 #define UART_INT_DSR 0x008 // DSR Modem Interrupt Mask
69 #define UART_INT_DCD 0x004 // DCD Modem Interrupt Mask
70 #define UART_INT_CTS 0x002 // CTS Modem Interrupt Mask
71 #define UART_INT_RI 0x001 // RI Modem Interrupt Mask
72 
73 //*****************************************************************************
74 //
75 // Values that can be passed to UARTConfigSetExpClk as the ui32Config parameter
76 // and returned by UARTConfigGetExpClk in the pui32Config parameter.
77 // Additionally, the UART_CONFIG_PAR_* subset can be passed to
78 // UARTParityModeSet as the ui32Parity parameter, and are returned by
79 // UARTParityModeGet.
80 //
81 //*****************************************************************************
82 #define UART_CONFIG_WLEN_MASK 0x00000060 // Mask for extracting word length
83 #define UART_CONFIG_WLEN_8 0x00000060 // 8 bit data
84 #define UART_CONFIG_WLEN_7 0x00000040 // 7 bit data
85 #define UART_CONFIG_WLEN_6 0x00000020 // 6 bit data
86 #define UART_CONFIG_WLEN_5 0x00000000 // 5 bit data
87 #define UART_CONFIG_STOP_MASK 0x00000008 // Mask for extracting stop bits
88 #define UART_CONFIG_STOP_ONE 0x00000000 // One stop bit
89 #define UART_CONFIG_STOP_TWO 0x00000008 // Two stop bits
90 #define UART_CONFIG_PAR_MASK 0x00000086 // Mask for extracting parity
91 #define UART_CONFIG_PAR_NONE 0x00000000 // No parity
92 #define UART_CONFIG_PAR_EVEN 0x00000006 // Even parity
93 #define UART_CONFIG_PAR_ODD 0x00000002 // Odd parity
94 #define UART_CONFIG_PAR_ONE 0x00000082 // Parity bit is one
95 #define UART_CONFIG_PAR_ZERO 0x00000086 // Parity bit is zero
96 
97 //*****************************************************************************
98 //
99 // Values that can be passed to UARTFIFOLevelSet as the ui32TxLevel parameter
100 // and returned by UARTFIFOLevelGet in the pui32TxLevel.
101 //
102 //*****************************************************************************
103 #define UART_FIFO_TX1_8 0x00000000 // Transmit interrupt at 1/8 Full
104 #define UART_FIFO_TX2_8 0x00000001 // Transmit interrupt at 1/4 Full
105 #define UART_FIFO_TX4_8 0x00000002 // Transmit interrupt at 1/2 Full
106 #define UART_FIFO_TX6_8 0x00000003 // Transmit interrupt at 3/4 Full
107 #define UART_FIFO_TX7_8 0x00000004 // Transmit interrupt at 7/8 Full
108 
109 //*****************************************************************************
110 //
111 // Values that can be passed to UARTFIFOLevelSet as the ui32RxLevel parameter
112 // and returned by UARTFIFOLevelGet in the pui32RxLevel.
113 //
114 //*****************************************************************************
115 #define UART_FIFO_RX1_8 0x00000000 // Receive interrupt at 1/8 Full
116 #define UART_FIFO_RX2_8 0x00000008 // Receive interrupt at 1/4 Full
117 #define UART_FIFO_RX4_8 0x00000010 // Receive interrupt at 1/2 Full
118 #define UART_FIFO_RX6_8 0x00000018 // Receive interrupt at 3/4 Full
119 #define UART_FIFO_RX7_8 0x00000020 // Receive interrupt at 7/8 Full
120 
121 //*****************************************************************************
122 //
123 // Values that can be passed to UARTDMAEnable() and UARTDMADisable().
124 //
125 //*****************************************************************************
126 #define UART_DMA_ERR_RXSTOP 0x00000004 // Stop DMA receive if UART error
127 #define UART_DMA_TX 0x00000002 // Enable DMA for transmit
128 #define UART_DMA_RX 0x00000001 // Enable DMA for receive
129 
130 //*****************************************************************************
131 //
132 // Values returned from UARTRxErrorGet().
133 //
134 //*****************************************************************************
135 #define UART_RXERROR_OVERRUN 0x00000008
136 #define UART_RXERROR_BREAK 0x00000004
137 #define UART_RXERROR_PARITY 0x00000002
138 #define UART_RXERROR_FRAMING 0x00000001
139 
140 //*****************************************************************************
141 //
142 // Values that can be passed to UARTHandshakeOutputsSet() or returned from
143 // UARTHandshakeOutputGet().
144 //
145 //*****************************************************************************
146 #define UART_OUTPUT_RTS 0x00000800
147 #define UART_OUTPUT_DTR 0x00000400
148 
149 //*****************************************************************************
150 //
151 // Values that can be returned from UARTHandshakeInputsGet().
152 //
153 //*****************************************************************************
154 #define UART_INPUT_RI 0x00000100
155 #define UART_INPUT_DCD 0x00000004
156 #define UART_INPUT_DSR 0x00000002
157 #define UART_INPUT_CTS 0x00000001
158 
159 //*****************************************************************************
160 //
161 // Values that can be passed to UARTFlowControl() or returned from
162 // UARTFlowControlGet().
163 //
164 //*****************************************************************************
165 #define UART_FLOWCONTROL_TX 0x00008000
166 #define UART_FLOWCONTROL_RX 0x00004000
167 #define UART_FLOWCONTROL_NONE 0x00000000
168 
169 //*****************************************************************************
170 //
171 // Values that can be passed to UARTTxIntModeSet() or returned from
172 // UARTTxIntModeGet().
173 //
174 //*****************************************************************************
175 #define UART_TXINT_MODE_FIFO 0x00000000
176 #define UART_TXINT_MODE_EOT 0x00000010
177 
178 //*****************************************************************************
179 //
180 // Values that can be passed to UARTClockSourceSet() or returned from
181 // UARTClockSourceGet().
182 //
183 //*****************************************************************************
184 #define UART_CLOCK_SYSTEM 0x00000000
185 #define UART_CLOCK_PIOSC 0x00000005
186 
187 //*****************************************************************************
188 //
189 // API Function prototypes
190 //
191 //*****************************************************************************
192 extern void UARTParityModeSet(uint32_t ui32Base, uint32_t ui32Parity);
193 extern uint32_t UARTParityModeGet(uint32_t ui32Base);
194 extern void UARTFIFOLevelSet(uint32_t ui32Base, uint32_t ui32TxLevel,
195  uint32_t ui32RxLevel);
196 extern void UARTFIFOLevelGet(uint32_t ui32Base, uint32_t *pui32TxLevel,
197  uint32_t *pui32RxLevel);
198 extern void UARTConfigSetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk,
199  uint32_t ui32Baud, uint32_t ui32Config);
200 extern void UARTConfigGetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk,
201  uint32_t *pui32Baud, uint32_t *pui32Config);
202 extern void UARTEnable(uint32_t ui32Base);
203 extern void UARTDisable(uint32_t ui32Base);
204 extern void UARTFIFOEnable(uint32_t ui32Base);
205 extern void UARTFIFODisable(uint32_t ui32Base);
206 extern void UARTEnableSIR(uint32_t ui32Base, bool bLowPower);
207 extern void UARTDisableSIR(uint32_t ui32Base);
208 extern bool UARTCharsAvail(uint32_t ui32Base);
209 extern bool UARTSpaceAvail(uint32_t ui32Base);
210 extern int32_t UARTCharGetNonBlocking(uint32_t ui32Base);
211 extern int32_t UARTCharGet(uint32_t ui32Base);
212 extern bool UARTCharPutNonBlocking(uint32_t ui32Base, unsigned char ucData);
213 extern void UARTCharPut(uint32_t ui32Base, unsigned char ucData);
214 extern void UARTBreakCtl(uint32_t ui32Base, bool bBreakState);
215 extern bool UARTBusy(uint32_t ui32Base);
216 extern void UARTIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
217 extern void UARTIntUnregister(uint32_t ui32Base);
218 extern void UARTIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
219 extern void UARTIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
220 extern uint32_t UARTIntStatus(uint32_t ui32Base, bool bMasked);
221 extern void UARTIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
222 extern void UARTDMAEnable(uint32_t ui32Base, uint32_t ui32DMAFlags);
223 extern void UARTDMADisable(uint32_t ui32Base, uint32_t ui32DMAFlags);
224 extern uint32_t UARTRxErrorGet(uint32_t ui32Base);
225 extern void UARTRxErrorClear(uint32_t ui32Base);
226 extern void UARTSmartCardEnable(uint32_t ui32Base);
227 extern void UARTSmartCardDisable(uint32_t ui32Base);
228 extern void UARTModemControlSet(uint32_t ui32Base, uint32_t ui32Control);
229 extern void UARTModemControlClear(uint32_t ui32Base, uint32_t ui32Control);
230 extern uint32_t UARTModemControlGet(uint32_t ui32Base);
231 extern uint32_t UARTModemStatusGet(uint32_t ui32Base);
232 extern void UARTFlowControlSet(uint32_t ui32Base, uint32_t ui32Mode);
233 extern uint32_t UARTFlowControlGet(uint32_t ui32Base);
234 extern void UARTTxIntModeSet(uint32_t ui32Base, uint32_t ui32Mode);
235 extern uint32_t UARTTxIntModeGet(uint32_t ui32Base);
236 extern void UARTClockSourceSet(uint32_t ui32Base, uint32_t ui32Source);
237 extern uint32_t UARTClockSourceGet(uint32_t ui32Base);
238 extern void UART9BitEnable(uint32_t ui32Base);
239 extern void UART9BitDisable(uint32_t ui32Base);
240 extern void UART9BitAddrSet(uint32_t ui32Base, uint8_t ui8Addr,
241  uint8_t ui8Mask);
242 extern void UART9BitAddrSend(uint32_t ui32Base, uint8_t ui8Addr);
243 
244 //*****************************************************************************
245 //
246 // Mark the end of the C bindings section for C++ compilers.
247 //
248 //*****************************************************************************
249 #ifdef __cplusplus
250 }
251 #endif
252 
253 #endif // __DRIVERLIB_UART_H__
void UARTModemControlClear(uint32_t ui32Base, uint32_t ui32Control)
Definition: uart.c:822
void UARTFIFOEnable(uint32_t ui32Base)
Definition: uart.c:566
uint32_t UARTClockSourceGet(uint32_t ui32Base)
Definition: uart.c:1758
void UARTSmartCardDisable(uint32_t ui32Base)
Definition: uart.c:743
bool UARTCharsAvail(uint32_t ui32Base)
Definition: uart.c:1067
void UARTConfigSetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk, uint32_t ui32Baud, uint32_t ui32Config)
Definition: uart.c:348
void UARTParityModeSet(uint32_t ui32Base, uint32_t ui32Parity)
Definition: uart.c:176
void UARTDMAEnable(uint32_t ui32Base, uint32_t ui32DMAFlags)
Definition: uart.c:1597
void UARTFIFOLevelSet(uint32_t ui32Base, uint32_t ui32TxLevel, uint32_t ui32RxLevel)
Definition: uart.c:244
void UARTIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Definition: uart.c:1349
void UARTIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: uart.c:1483
void UARTIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: uart.c:1561
void UARTDisable(uint32_t ui32Base)
Definition: uart.c:528
void UARTBreakCtl(uint32_t ui32Base, bool bBreakState)
Definition: uart.c:1284
void UARTModemControlSet(uint32_t ui32Base, uint32_t ui32Control)
Definition: uart.c:780
bool UARTSpaceAvail(uint32_t ui32Base)
Definition: uart.c:1094
void UARTSmartCardEnable(uint32_t ui32Base)
Definition: uart.c:699
void UARTRxErrorClear(uint32_t ui32Base)
Definition: uart.c:1688
bool UARTBusy(uint32_t ui32Base)
Definition: uart.c:1316
uint32_t UARTModemStatusGet(uint32_t ui32Base)
Definition: uart.c:890
int32_t UARTCharGetNonBlocking(uint32_t ui32Base)
Definition: uart.c:1123
void UART9BitEnable(uint32_t ui32Base)
Definition: uart.c:1787
void UARTEnableSIR(uint32_t ui32Base, bool bLowPower)
Definition: uart.c:627
void UART9BitDisable(uint32_t ui32Base)
Definition: uart.c:1816
uint32_t UARTIntStatus(uint32_t ui32Base, bool bMasked)
Definition: uart.c:1513
bool UARTCharPutNonBlocking(uint32_t ui32Base, unsigned char ucData)
Definition: uart.c:1202
void UARTClockSourceSet(uint32_t ui32Base, uint32_t ui32Source)
Definition: uart.c:1725
uint32_t UARTParityModeGet(uint32_t ui32Base)
Definition: uart.c:211
void UARTDisableSIR(uint32_t ui32Base)
Definition: uart.c:668
uint32_t UARTRxErrorGet(uint32_t ui32Base)
Definition: uart.c:1660
void UARTConfigGetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk, uint32_t *pui32Baud, uint32_t *pui32Config)
Definition: uart.c:447
int32_t UARTCharGet(uint32_t ui32Base)
Definition: uart.c:1164
void UART9BitAddrSend(uint32_t ui32Base, uint8_t ui8Addr)
Definition: uart.c:1890
uint32_t UARTFlowControlGet(uint32_t ui32Base)
Definition: uart.c:963
void UART9BitAddrSet(uint32_t ui32Base, uint8_t ui8Addr, uint8_t ui8Mask)
Definition: uart.c:1851
uint32_t UARTTxIntModeGet(uint32_t ui32Base)
Definition: uart.c:1039
void UARTFIFOLevelGet(uint32_t ui32Base, uint32_t *pui32TxLevel, uint32_t *pui32RxLevel)
Definition: uart.c:287
uint32_t UARTModemControlGet(uint32_t ui32Base)
Definition: uart.c:860
void UARTEnable(uint32_t ui32Base)
Definition: uart.c:496
void UARTCharPut(uint32_t ui32Base, unsigned char ucData)
Definition: uart.c:1248
void UARTTxIntModeSet(uint32_t ui32Base, uint32_t ui32Mode)
Definition: uart.c:1000
void UARTIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: uart.c:1451
void UARTFlowControlSet(uint32_t ui32Base, uint32_t ui32Mode)
Definition: uart.c:927
void UARTIntUnregister(uint32_t ui32Base)
Definition: uart.c:1394
void UARTDMADisable(uint32_t ui32Base, uint32_t ui32DMAFlags)
Definition: uart.c:1629
void UARTFIFODisable(uint32_t ui32Base)
Definition: uart.c:591