UARTCC32XXDMA.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
66 #ifndef ti_drivers_uart_UARTCC32XXDMA__include
67 #define ti_drivers_uart_UARTCC32XXDMA__include
68 
69 #include <stdint.h>
70 #include <stdbool.h>
71 
72 #include <ti/drivers/dpl/ClockP.h>
73 #include <ti/drivers/dpl/HwiP.h>
74 
75 #include <ti/drivers/dpl/SemaphoreP.h>
76 #include <ti/drivers/Power.h>
78 #include <ti/drivers/UART.h>
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
91 #define UARTCC32XXDMA_PIN_UNASSIGNED 0xFFF
92 /*
93  * The bits in the pin mode macros are as follows:
94  * The lower 8 bits of the macro refer to the pin, offset by 1, to match
95  * driverlib pin defines. For example, UARTCC32XXDMA_PIN_01_UART1_TX & 0xff = 0,
96  * which equals PIN_01 in driverlib pin.h. By matching the PIN_xx defines in
97  * driverlib pin.h, we can pass the pin directly to the driverlib functions.
98  * The upper 8 bits of the macro correspond to the pin mux confg mode
99  * value for the pin to operate in the UART mode. For example, pin 1 is
100  * configured with mode 7 to operate as UART1 TX.
101  */
102 #define UARTCC32XXDMA_PIN_01_UART1_TX 0x700
103 #define UARTCC32XXDMA_PIN_02_UART1_RX 0x701
104 #define UARTCC32XXDMA_PIN_03_UART0_TX 0x702
105 #define UARTCC32XXDMA_PIN_04_UART0_RX 0x703
106 #define UARTCC32XXDMA_PIN_07_UART1_TX 0x506
107 #define UARTCC32XXDMA_PIN_08_UART1_RX 0x507
108 #define UARTCC32XXDMA_PIN_16_UART1_TX 0x20F
109 #define UARTCC32XXDMA_PIN_17_UART1_RX 0x210
110 #define UARTCC32XXDMA_PIN_45_UART0_RX 0x92C
111 #define UARTCC32XXDMA_PIN_45_UART1_RX 0x22C
112 #define UARTCC32XXDMA_PIN_53_UART0_TX 0x934
113 #define UARTCC32XXDMA_PIN_55_UART0_TX 0x336
114 #define UARTCC32XXDMA_PIN_55_UART1_TX 0x636
115 #define UARTCC32XXDMA_PIN_57_UART0_RX 0x338
116 #define UARTCC32XXDMA_PIN_57_UART1_RX 0x638
117 #define UARTCC32XXDMA_PIN_58_UART1_TX 0x639
118 #define UARTCC32XXDMA_PIN_59_UART1_RX 0x63A
119 #define UARTCC32XXDMA_PIN_62_UART0_TX 0xB3D
121 /*
122  * Flow control pins.
123  */
124 #define UARTCC32XXDMA_PIN_50_UART0_CTS 0xC31
125 #define UARTCC32XXDMA_PIN_50_UART0_RTS 0x331
126 #define UARTCC32XXDMA_PIN_50_UART1_RTS 0xA31
127 #define UARTCC32XXDMA_PIN_52_UART0_RTS 0x633
128 #define UARTCC32XXDMA_PIN_61_UART0_RTS 0x53C
129 #define UARTCC32XXDMA_PIN_61_UART0_CTS 0x63C
130 #define UARTCC32XXDMA_PIN_61_UART1_CTS 0x33C
131 #define UARTCC32XXDMA_PIN_62_UART0_RTS 0xA3D
132 #define UARTCC32XXDMA_PIN_62_UART1_RTS 0x33D
137 #define UARTCC32XXDMA_FLOWCTRL_NONE 0
138 
142 #define UARTCC32XXDMA_FLOWCTRL_HARDWARE 1
143 
154 /* Add UARTCC32XXDMA_STATUS_* macros here */
155 
176 #define UARTCC32XXDMA_CMD_IS_BUSY (UART_CMD_RESERVED + 0)
177 
178 
187 #define UARTCC32XXDMA_CMD_IS_RX_DATA_AVAILABLE (UART_CMD_RESERVED + 1)
188 
189 
198 #define UARTCC32XXDMA_CMD_IS_TX_SPACE_AVAILABLE (UART_CMD_RESERVED + 2)
199 
200 
203 /* UART function table pointer */
205 
218 typedef void (*UARTCC32XXDMA_ErrorCallback) (UART_Handle handle, uint32_t error);
219 
271 typedef struct {
273  unsigned int baseAddr;
275  unsigned int intNum;
277  unsigned int intPriority;
279  uint32_t flowControl;
281  unsigned long rxChannelIndex;
283  unsigned long txChannelIndex;
285  uint16_t rxPin;
287  uint16_t txPin;
289  uint16_t ctsPin;
291  uint16_t rtsPin;
298 
304 typedef struct {
305  /* UART control variables */
306  bool opened; /* Has the obj been opened */
307  UART_Mode readMode; /* Mode for all read calls */
308  UART_Mode writeMode; /* Mode for all write calls */
309  unsigned int readTimeout; /* Timeout for read semaphore */
310  unsigned int writeTimeout; /* Timeout for write semaphore */
311  UART_Callback readCallback; /* Pointer to read callback */
312  UART_Callback writeCallback; /* Pointer to write callback */
313  UART_ReturnMode readReturnMode; /* Receive return mode */
314  UART_DataMode readDataMode; /* Type of data being read */
315  UART_DataMode writeDataMode; /* Type of data being written */
316  uint32_t baudRate; /* Baud rate for UART */
317  UART_LEN dataLength; /* Data length for UART */
318  UART_STOP stopBits; /* Stop bits for UART */
319  UART_PAR parityType; /* Parity bit type for UART */
320  UART_Echo readEcho; /* Echo received data back */
321 
322  /* UART write variables */
323  const void *writeBuf; /* Buffer data pointer */
324  size_t writeCount; /* Number of Chars sent */
325  size_t writeSize; /* Chars remaining in buffer */
326 
327  /* UART receive variables */
328  void *readBuf; /* Buffer data pointer */
329  size_t readCount; /* Number of Chars read */
330  size_t readSize; /* Chars remaining in buffer */
331 
332  /* Semaphores for blocking mode */
333  SemaphoreP_Handle writeSem; /* UART write semaphore */
334  SemaphoreP_Handle readSem; /* UART read semaphore */
335 
336  HwiP_Handle hwiHandle;
337 
338  /* For Power management */
339  ClockP_Handle txFifoEmptyClk; /* UART TX FIFO empty clock */
340  Power_NotifyObj postNotify; /* LPDS wake-up notify object */
341  unsigned int powerMgrId; /* Determined from base address */
342  PowerCC32XX_ParkState prevParkTX; /* Previous park state TX pin */
343  uint16_t txPin; /* TX pin ID */
344  PowerCC32XX_ParkState prevParkRTS; /* Previous park state of RTS pin */
345  uint16_t rtsPin; /* RTS pin ID */
346 
347  /* UDMA */
350 
351 #ifdef __cplusplus
352 }
353 #endif
354 
355 #endif /* ti_drivers_uart_UARTCC32XXDMA__include */
UARTCC32XXDMA Hardware attributes.
Definition: UARTCC32XXDMA.h:271
UART_STOP
UART stop bit settings.
Definition: UART.h:525
Power_NotifyObj postNotify
Definition: UARTCC32XXDMA.h:340
uint32_t flowControl
Definition: UARTCC32XXDMA.h:279
uint16_t rxPin
Definition: UARTCC32XXDMA.h:285
PowerCC32XX_ParkState prevParkTX
Definition: UARTCC32XXDMA.h:342
size_t readSize
Definition: UARTCC32XXDMA.h:330
UARTCC32XXDMA Object.
Definition: UARTCC32XXDMA.h:304
UART_Callback writeCallback
Definition: UARTCC32XXDMA.h:312
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:637
unsigned int writeTimeout
Definition: UARTCC32XXDMA.h:310
Power Manager.
UART_PAR
UART parity type settings.
Definition: UART.h:535
UDMACC32XX_Handle dmaHandle
Definition: UARTCC32XXDMA.h:348
unsigned int baseAddr
Definition: UARTCC32XXDMA.h:273
const void * writeBuf
Definition: UARTCC32XXDMA.h:323
UART_Mode
UART mode settings.
Definition: UART.h:430
UART_Echo readEcho
Definition: UARTCC32XXDMA.h:320
UART_DataMode
UART data mode settings.
Definition: UART.h:485
size_t readCount
Definition: UARTCC32XXDMA.h:329
UART_ReturnMode
UART return mode settings.
Definition: UART.h:463
SemaphoreP_Handle readSem
Definition: UARTCC32XXDMA.h:334
unsigned int powerMgrId
Definition: UARTCC32XXDMA.h:341
UART_Echo
UART echo settings.
Definition: UART.h:503
uDMA driver implementation for CC32XX.
unsigned int intNum
Definition: UARTCC32XXDMA.h:275
UART Global configuration.
Definition: UART.h:680
SemaphoreP_Handle writeSem
Definition: UARTCC32XXDMA.h:333
uint16_t txPin
Definition: UARTCC32XXDMA.h:287
void * readBuf
Definition: UARTCC32XXDMA.h:328
UDMACC32XX Global configuration.
Definition: UDMACC32XX.h:125
uint16_t ctsPin
Definition: UARTCC32XXDMA.h:289
Power manager interface for the CC32XX.
ClockP_Handle txFifoEmptyClk
Definition: UARTCC32XXDMA.h:339
uint32_t baudRate
Definition: UARTCC32XXDMA.h:316
Power notify object structure.
Definition: Power.h:443
UART_PAR parityType
Definition: UARTCC32XXDMA.h:319
Universal Asynchronous Receiver-Transmitter (UART) Driver.
bool opened
Definition: UARTCC32XXDMA.h:306
UART_STOP stopBits
Definition: UARTCC32XXDMA.h:318
UART_LEN dataLength
Definition: UARTCC32XXDMA.h:317
UART_DataMode readDataMode
Definition: UARTCC32XXDMA.h:314
uint16_t rtsPin
Definition: UARTCC32XXDMA.h:345
uint16_t rtsPin
Definition: UARTCC32XXDMA.h:291
unsigned int readTimeout
Definition: UARTCC32XXDMA.h:309
size_t writeCount
Definition: UARTCC32XXDMA.h:324
size_t writeSize
Definition: UARTCC32XXDMA.h:325
UARTCC32XXDMA_ErrorCallback errorFxn
Definition: UARTCC32XXDMA.h:296
HwiP_Handle hwiHandle
Definition: UARTCC32XXDMA.h:336
void(* UARTCC32XXDMA_ErrorCallback)(UART_Handle handle, uint32_t error)
The definition of an optional callback function used by the UART driver to notify the application whe...
Definition: UARTCC32XXDMA.h:218
UART_LEN
UART data length settings.
Definition: UART.h:513
unsigned long rxChannelIndex
Definition: UARTCC32XXDMA.h:281
PowerCC32XX_ParkState prevParkRTS
Definition: UARTCC32XXDMA.h:344
uint16_t txPin
Definition: UARTCC32XXDMA.h:343
UART_Mode writeMode
Definition: UARTCC32XXDMA.h:308
UART_DataMode writeDataMode
Definition: UARTCC32XXDMA.h:315
struct UARTCC32XXDMA_Object * UARTCC32XXDMA_Handle
UART_Mode readMode
Definition: UARTCC32XXDMA.h:307
unsigned long txChannelIndex
Definition: UARTCC32XXDMA.h:283
unsigned int intPriority
Definition: UARTCC32XXDMA.h:277
UART_Callback readCallback
Definition: UARTCC32XXDMA.h:311
const UART_FxnTable UARTCC32XXDMA_fxnTable
UART_ReturnMode readReturnMode
Definition: UARTCC32XXDMA.h:313
void(* UART_Callback)(UART_Handle handle, void *buf, size_t count)
The definition of a callback function used by the UART driver when used in UART_MODE_CALLBACK The cal...
Definition: UART.h:423
PowerCC32XX_ParkState
Enumeration of states a pin can be parked in.
Definition: PowerCC32XX.h:393
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale