1 /* 2 * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the 14 * distribution. 15 * 16 * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 */ 33 //***************************************************************************** 34 // 35 // uart.h 36 // 37 // Defines and Macros for the UART. 38 // 39 //***************************************************************************** 40 41 #ifndef __UART_H__ 42 #define __UART_H__ 43 44 //***************************************************************************** 45 // 46 // If building with a C++ compiler, make all of the definitions in this header 47 // have a C binding. 48 // 49 //***************************************************************************** 50 #ifdef __cplusplus 51 extern "C" 52 { 53 #endif 54 55 //***************************************************************************** 56 // 57 // Values that can be passed to UARTIntEnable, UARTIntDisable, and UARTIntClear 58 // as the ulIntFlags parameter, and returned from UARTIntStatus. 59 // 60 //***************************************************************************** 61 #define UART_INT_DMATX 0x20000 // DMA Tx Done interrupt Mask 62 #define UART_INT_DMARX 0x10000 // DMA Rx Done interrupt Mask 63 #define UART_INT_EOT 0x800 // End of transfer interrupt Mask 64 #define UART_INT_OE 0x400 // Overrun Error Interrupt Mask 65 #define UART_INT_BE 0x200 // Break Error Interrupt Mask 66 #define UART_INT_PE 0x100 // Parity Error Interrupt Mask 67 #define UART_INT_FE 0x080 // Framing Error Interrupt Mask 68 #define UART_INT_RT 0x040 // Receive Timeout Interrupt Mask 69 #define UART_INT_TX 0x020 // Transmit Interrupt Mask 70 #define UART_INT_RX 0x010 // Receive Interrupt Mask 71 #define UART_INT_CTS 0x002 // CTS Modem Interrupt Mask 72 73 74 //***************************************************************************** 75 // 76 // Values that can be passed to UARTConfigSetExpClk as the ulConfig parameter 77 // and returned by UARTConfigGetExpClk in the pulConfig parameter. 78 // Additionally, the UART_CONFIG_PAR_* subset can be passed to 79 // UARTParityModeSet as the ulParity parameter, and are returned by 80 // UARTParityModeGet. 81 // 82 //***************************************************************************** 83 #define UART_CONFIG_WLEN_MASK 0x00000060 // Mask for extracting word length 84 #define UART_CONFIG_WLEN_8 0x00000060 // 8 bit data 85 #define UART_CONFIG_WLEN_7 0x00000040 // 7 bit data 86 #define UART_CONFIG_WLEN_6 0x00000020 // 6 bit data 87 #define UART_CONFIG_WLEN_5 0x00000000 // 5 bit data 88 #define UART_CONFIG_STOP_MASK 0x00000008 // Mask for extracting stop bits 89 #define UART_CONFIG_STOP_ONE 0x00000000 // One stop bit 90 #define UART_CONFIG_STOP_TWO 0x00000008 // Two stop bits 91 #define UART_CONFIG_PAR_MASK 0x00000086 // Mask for extracting parity 92 #define UART_CONFIG_PAR_NONE 0x00000000 // No parity 93 #define UART_CONFIG_PAR_EVEN 0x00000006 // Even parity 94 #define UART_CONFIG_PAR_ODD 0x00000002 // Odd parity 95 #define UART_CONFIG_PAR_ONE 0x00000082 // Parity bit is one 96 #define UART_CONFIG_PAR_ZERO 0x00000086 // Parity bit is zero 97 98 //***************************************************************************** 99 // 100 // Values that can be passed to UARTFIFOLevelSet as the ulTxLevel parameter and 101 // returned by UARTFIFOLevelGet in the pulTxLevel. 102 // 103 //***************************************************************************** 104 #define UART_FIFO_TX1_8 0x00000000 // Transmit interrupt at 1/8 Full 105 #define UART_FIFO_TX2_8 0x00000001 // Transmit interrupt at 1/4 Full 106 #define UART_FIFO_TX4_8 0x00000002 // Transmit interrupt at 1/2 Full 107 #define UART_FIFO_TX6_8 0x00000003 // Transmit interrupt at 3/4 Full 108 #define UART_FIFO_TX7_8 0x00000004 // Transmit interrupt at 7/8 Full 109 110 //***************************************************************************** 111 // 112 // Values that can be passed to UARTFIFOLevelSet as the ulRxLevel parameter and 113 // returned by UARTFIFOLevelGet in the pulRxLevel. 114 // 115 //***************************************************************************** 116 #define UART_FIFO_RX1_8 0x00000000 // Receive interrupt at 1/8 Full 117 #define UART_FIFO_RX2_8 0x00000008 // Receive interrupt at 1/4 Full 118 #define UART_FIFO_RX4_8 0x00000010 // Receive interrupt at 1/2 Full 119 #define UART_FIFO_RX6_8 0x00000018 // Receive interrupt at 3/4 Full 120 #define UART_FIFO_RX7_8 0x00000020 // Receive interrupt at 7/8 Full 121 122 //***************************************************************************** 123 // 124 // Values that can be passed to UARTDMAEnable() and UARTDMADisable(). 125 // 126 //***************************************************************************** 127 #define UART_DMA_ERR_RXSTOP 0x00000004 // Stop DMA receive if UART error 128 #define UART_DMA_TX 0x00000002 // Enable DMA for transmit 129 #define UART_DMA_RX 0x00000001 // Enable DMA for receive 130 131 //***************************************************************************** 132 // 133 // Values returned from UARTRxErrorGet(). 134 // 135 //***************************************************************************** 136 #define UART_RXERROR_OVERRUN 0x00000008 137 #define UART_RXERROR_BREAK 0x00000004 138 #define UART_RXERROR_PARITY 0x00000002 139 #define UART_RXERROR_FRAMING 0x00000001 140 141 //***************************************************************************** 142 // 143 // Values that can be passed to UARTModemControlSet()and UARTModemControlClear() 144 // or returned from UARTModemControlGet(). 145 // 146 //***************************************************************************** 147 #define UART_OUTPUT_RTS 0x00000800 148 149 //***************************************************************************** 150 // 151 // Values that can be returned from UARTModemStatusGet(). 152 // 153 //***************************************************************************** 154 #define UART_INPUT_CTS 0x00000001 155 156 //***************************************************************************** 157 // 158 // Values that can be passed to UARTFlowControl() or returned from 159 // UARTFlowControlGet(). 160 // 161 //***************************************************************************** 162 #define UART_FLOWCONTROL_TX 0x00008000 163 #define UART_FLOWCONTROL_RX 0x00004000 164 #define UART_FLOWCONTROL_NONE 0x00000000 165 166 //***************************************************************************** 167 // 168 // Values that can be passed to UARTTxIntModeSet() or returned from 169 // UARTTxIntModeGet(). 170 // 171 //***************************************************************************** 172 #define UART_TXINT_MODE_FIFO 0x00000000 173 #define UART_TXINT_MODE_EOT 0x00000010 174 175 176 //***************************************************************************** 177 // 178 // API Function prototypes 179 // 180 //***************************************************************************** 181 extern void UARTParityModeSet(unsigned long ulBase, unsigned long ulParity); 182 extern unsigned long UARTParityModeGet(unsigned long ulBase); 183 extern void UARTFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel, 184 unsigned long ulRxLevel); 185 extern void UARTFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel, 186 unsigned long *pulRxLevel); 187 extern void UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk, 188 unsigned long ulBaud, unsigned long ulConfig); 189 extern void UARTConfigGetExpClk(unsigned long ulBase, unsigned long ulUARTClk, 190 unsigned long *pulBaud, 191 unsigned long *pulConfig); 192 extern void UARTEnable(unsigned long ulBase); 193 extern void UARTDisable(unsigned long ulBase); 194 extern void UARTFIFOEnable(unsigned long ulBase); 195 extern void UARTFIFODisable(unsigned long ulBase); 196 extern tBoolean UARTCharsAvail(unsigned long ulBase); 197 extern tBoolean UARTSpaceAvail(unsigned long ulBase); 198 extern long UARTCharGetNonBlocking(unsigned long ulBase); 199 extern long UARTCharGet(unsigned long ulBase); 200 extern tBoolean UARTCharPutNonBlocking(unsigned long ulBase, 201 unsigned char ucData); 202 extern void UARTCharPut(unsigned long ulBase, unsigned char ucData); 203 extern void UARTBreakCtl(unsigned long ulBase, tBoolean bBreakState); 204 extern tBoolean UARTBusy(unsigned long ulBase); 205 extern void UARTIntRegister(unsigned long ulBase, void(*pfnHandler)(void)); 206 extern void UARTIntUnregister(unsigned long ulBase); 207 extern void UARTIntEnable(unsigned long ulBase, unsigned long ulIntFlags); 208 extern void UARTIntDisable(unsigned long ulBase, unsigned long ulIntFlags); 209 extern unsigned long UARTIntStatus(unsigned long ulBase, tBoolean bMasked); 210 extern void UARTIntClear(unsigned long ulBase, unsigned long ulIntFlags); 211 extern void UARTDMAEnable(unsigned long ulBase, unsigned long ulDMAFlags); 212 extern void UARTDMADisable(unsigned long ulBase, unsigned long ulDMAFlags); 213 extern unsigned long UARTRxErrorGet(unsigned long ulBase); 214 extern void UARTRxErrorClear(unsigned long ulBase); 215 extern void UARTModemControlSet(unsigned long ulBase, 216 unsigned long ulControl); 217 extern void UARTModemControlClear(unsigned long ulBase, 218 unsigned long ulControl); 219 extern unsigned long UARTModemControlGet(unsigned long ulBase); 220 extern unsigned long UARTModemStatusGet(unsigned long ulBase); 221 extern void UARTFlowControlSet(unsigned long ulBase, unsigned long ulMode); 222 extern unsigned long UARTFlowControlGet(unsigned long ulBase); 223 extern void UARTTxIntModeSet(unsigned long ulBase, unsigned long ulMode); 224 extern unsigned long UARTTxIntModeGet(unsigned long ulBase); 225 226 //***************************************************************************** 227 // 228 // Mark the end of the C bindings section for C++ compilers. 229 // 230 //***************************************************************************** 231 #ifdef __cplusplus 232 } 233 #endif 234 235 #endif // __UART_H__ 236