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