UART2CC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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  */
49 #ifndef ti_drivers_uart2_UART2CC32XX__include
50 #define ti_drivers_uart2_UART2CC32XX__include
51 
52 #include <stddef.h>
53 #include <stdint.h>
54 #include <stdbool.h>
55 
56 #include <ti/drivers/dpl/HwiP.h>
57 #include <ti/drivers/dpl/SemaphoreP.h>
59 #include <ti/drivers/UART2.h>
61 #include <ti/drivers/Power.h>
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
73 #define UART2CC32XX_PIN_UNASSIGNED 0xFFF
74 
81 #define UART2CC32XX_DMACH_UNASSIGNED 0xFF
82 
83 /*
84  * The bits in the pin mode macros are as follows:
85  * The lower 8 bits of the macro refer to the pin, offset by 1, to match
86  * driverlib pin defines. For example, UART2CC32XX_PIN_01_UART1_TX & 0xff = 0,
87  * which equals PIN_01 in driverlib pin.h. By matching the PIN_xx defines in
88  * driverlib pin.h, we can pass the pin directly to the driverlib functions.
89  * The upper 8 bits of the macro correspond to the pin mux confg mode
90  * value for the pin to operate in the UART mode. For example, pin 1 is
91  * configured with mode 7 to operate as UART1 TX.
92  */
93 #define UART2CC32XX_PIN_01_UART1_TX 0x700
94 #define UART2CC32XX_PIN_02_UART1_RX 0x701
95 #define UART2CC32XX_PIN_03_UART0_TX 0x702
96 #define UART2CC32XX_PIN_04_UART0_RX 0x703
97 #define UART2CC32XX_PIN_07_UART1_TX 0x506
98 #define UART2CC32XX_PIN_08_UART1_RX 0x507
99 #define UART2CC32XX_PIN_16_UART1_TX 0x20F
100 #define UART2CC32XX_PIN_17_UART1_RX 0x210
101 #define UART2CC32XX_PIN_45_UART0_RX 0x92C
102 #define UART2CC32XX_PIN_45_UART1_RX 0x22C
103 #define UART2CC32XX_PIN_53_UART0_TX 0x934
104 #define UART2CC32XX_PIN_55_UART0_TX 0x336
105 #define UART2CC32XX_PIN_55_UART1_TX 0x636
106 #define UART2CC32XX_PIN_57_UART0_RX 0x338
107 #define UART2CC32XX_PIN_57_UART1_RX 0x638
108 #define UART2CC32XX_PIN_58_UART1_TX 0x639
109 #define UART2CC32XX_PIN_59_UART1_RX 0x63A
110 #define UART2CC32XX_PIN_62_UART0_TX 0xB3D
112 /*
113  * Flow control pins.
114  */
115 #define UART2CC32XX_PIN_50_UART0_CTS 0xC31
116 #define UART2CC32XX_PIN_50_UART0_RTS 0x331
117 #define UART2CC32XX_PIN_50_UART1_RTS 0xA31
118 #define UART2CC32XX_PIN_52_UART0_RTS 0x633
119 #define UART2CC32XX_PIN_61_UART0_RTS 0x53C
120 #define UART2CC32XX_PIN_61_UART0_CTS 0x63C
121 #define UART2CC32XX_PIN_61_UART1_CTS 0x33C
122 #define UART2CC32XX_PIN_62_UART0_RTS 0xA3D
123 #define UART2CC32XX_PIN_62_UART1_RTS 0x33D
128 #define UART2CC32XX_FLOWCTRL_NONE 0
129 
133 #define UART2CC32XX_FLOWCTRL_HARDWARE 1
134 
143 typedef enum {
150 
151 /* UART2CC32XX functions */
152 extern void UART2CC32XX_close(UART2_Handle handle);
153 extern UART2_Handle UART2CC32XX_open(uint_least8_t, UART2_Params *params);
154 extern int_fast16_t UART2CC32XX_read(UART2_Handle handle, void *buffer,
155  size_t size, size_t *bytesRead, uint32_t timeout);
156 extern void UART2CC32XX_readCancel(UART2_Handle handle);
157 extern int_fast16_t UART2CC32XX_write(UART2_Handle handle,
158  const void *buffer, size_t size, size_t *bytesWritten,
159  uint32_t timeout);
160 extern void UART2CC32XX_writeCancel(UART2_Handle handle);
161 extern void UART2CC32XX_flushRx(UART2_Handle handle);
162 
163 /* UART2 function table pointer */
165 
233 typedef struct {
235  uint32_t baseAddr;
237  int intNum;
239  uint8_t intPriority;
241  uint32_t flowControl;
243  uint32_t rxPin;
245  uint32_t txPin;
247  uint32_t ctsPin;
249  uint32_t rtsPin;
255  uint32_t rxDmaChannel;
257  uint32_t txDmaChannel;
259 
265 typedef struct {
266  /* UART2 state variable */
267  struct {
268  bool opened:1; /* Has the obj been opened */
269  UART2_Mode readMode; /* Mode for read calls */
270  UART2_Mode writeMode; /* Mode for write calls */
271  UART2_ReadReturnMode readReturnMode:1; /* RX return mode (partial/full) */
272  bool txEnabled:1; /* Flag to show ongoing transmit */
273  } state;
274 
275  HwiP_Handle hwi; /* Hwi object for interrupts */
276  uint32_t baudRate; /* Baud rate for UART */
277  UART2_DataLen dataLength; /* Data length for UART */
278  UART2_StopBits stopBits; /* Stop bits for UART */
279  UART2_Parity parityType; /* Parity bit type for UART */
280  int32_t rxStatus; /* RX status */
281  int32_t txStatus; /* TX status */
282  void *userArg; /* User supplied arg for callbacks */
283  UDMACC32XX_Handle udmaHandle; /* For setting power dependency */
284 
285  /* UART read variables */
286  unsigned char *readBuf; /* Buffer data pointer */
287  size_t readSize; /* Number of bytes to read */
288  uint32_t nReadTransfers; /* Number of DMA transfers needed */
289  size_t readCount; /* Number of bytes left to read */
290  size_t rxSize; /* # of bytes to read in DMA xfer */
291  size_t bytesRead; /* Number of bytes read */
292  SemaphoreP_Handle readSem; /* UART read semaphore */
293  UART2_Callback readCallback; /* Pointer to read callback */
294 
295  /* UART write variables */
296  const unsigned char *writeBuf; /* Buffer data pointer */
297  size_t writeSize; /* Number of bytes to write*/
298  uint32_t nWriteTransfers; /* Number of DMA transfers needed */
299  size_t writeCount; /* Number of bytes left to write */
300  size_t txSize; /* # of bytes to write with DMA */
301  size_t bytesWritten; /* Number of bytes written */
302  SemaphoreP_Handle writeSem; /* UART write semaphore*/
303  UART2_Callback writeCallback; /* Pointer to write callback */
304 
305  /* For Power management */
307  unsigned int powerMgrId; /* Determined from base address */
308  PowerCC32XX_ParkState prevParkTX; /* Previous park state TX pin */
309  uint16_t txPin; /* TX pin ID */
310  PowerCC32XX_ParkState prevParkRTS; /* Previous park state of RTS pin */
311  uint16_t rtsPin; /* RTS pin ID */
313 
314 #ifdef __cplusplus
315 }
316 #endif
317 
318 #endif /* ti_drivers_uart2_UART2CC32XX__include */
UART2 Global configuration.
Definition: UART2.h:516
size_t txSize
Definition: UART2CC32XX.h:300
void UART2CC32XX_flushRx(UART2_Handle handle)
uint32_t nReadTransfers
Definition: UART2CC32XX.h:288
uint32_t baudRate
Definition: UART2CC32XX.h:276
UART2_ReadReturnMode
UART2 return mode settings.
Definition: UART2.h:373
Power_NotifyObj postNotify
Definition: UART2CC32XX.h:306
UART2_Mode readMode
Definition: UART2CC32XX.h:269
struct UART2CC32XX_Object * UART2CC32XX_Handle
Definition: UART2CC32XX.h:146
Definition: UART2CC32XX.h:147
void UART2CC32XX_writeCancel(UART2_Handle handle)
Definition: UART2CC32XX.h:144
uint32_t baseAddr
Definition: UART2CC32XX.h:235
uint32_t nWriteTransfers
Definition: UART2CC32XX.h:298
UART2_Parity
UART2 parity type settings.
Definition: UART2.h:408
uint8_t intPriority
Definition: UART2CC32XX.h:239
PRELIMINARY UART driver interface
uint32_t txPin
Definition: UART2CC32XX.h:245
HwiP_Handle hwi
Definition: UART2CC32XX.h:275
Power Manager.
int32_t txStatus
Definition: UART2CC32XX.h:281
Definition: UART2CC32XX.h:145
SemaphoreP_Handle readSem
Definition: UART2CC32XX.h:292
size_t bytesRead
Definition: UART2CC32XX.h:291
uint32_t ctsPin
Definition: UART2CC32XX.h:247
The definition of a UART2 function table that contains the required set of functions to control a spe...
Definition: UART2.h:486
uDMA driver implementation for CC32XX.
size_t readCount
Definition: UART2CC32XX.h:289
UART2_Parity parityType
Definition: UART2CC32XX.h:279
SemaphoreP_Handle writeSem
Definition: UART2CC32XX.h:302
UART2CC32XX_FifoThreshold
UART TX/RX interrupt FIFO threshold select.
Definition: UART2CC32XX.h:143
void UART2CC32XX_close(UART2_Handle handle)
UART2CC32XX Hardware attributes.
Definition: UART2CC32XX.h:233
int_fast16_t UART2CC32XX_write(UART2_Handle handle, const void *buffer, size_t size, size_t *bytesWritten, uint32_t timeout)
UART2_Callback writeCallback
Definition: UART2CC32XX.h:303
UDMACC32XX Global configuration.
Definition: UDMACC32XX.h:125
uint32_t rxPin
Definition: UART2CC32XX.h:243
Power manager interface for the CC32XX.
size_t bytesWritten
Definition: UART2CC32XX.h:301
const unsigned char * writeBuf
Definition: UART2CC32XX.h:296
UART2_Mode
UART2 mode settings.
Definition: UART2.h:336
uint32_t rtsPin
Definition: UART2CC32XX.h:249
size_t writeSize
Definition: UART2CC32XX.h:297
UART2CC32XX Object.
Definition: UART2CC32XX.h:265
PowerCC32XX_ParkState prevParkRTS
Definition: UART2CC32XX.h:310
uint32_t txDmaChannel
Definition: UART2CC32XX.h:257
uint16_t rtsPin
Definition: UART2CC32XX.h:311
uint32_t rxDmaChannel
Definition: UART2CC32XX.h:255
const UART2_FxnTable UART2CC32XX_fxnTable
unsigned int powerMgrId
Definition: UART2CC32XX.h:307
UART2 Parameters.
Definition: UART2.h:424
Power notify object structure.
Definition: Power.h:443
int32_t rxStatus
Definition: UART2CC32XX.h:280
UDMACC32XX_Handle udmaHandle
Definition: UART2CC32XX.h:283
UART2_StopBits
UART2 stop bit settings.
Definition: UART2.h:398
UART2_Handle UART2CC32XX_open(uint_least8_t, UART2_Params *params)
Definition: UART2CC32XX.h:148
UART2_Callback readCallback
Definition: UART2CC32XX.h:293
UART2_StopBits stopBits
Definition: UART2CC32XX.h:278
void * userArg
Definition: UART2CC32XX.h:282
UART2_Mode writeMode
Definition: UART2CC32XX.h:270
uint16_t txPin
Definition: UART2CC32XX.h:309
PowerCC32XX_ParkState prevParkTX
Definition: UART2CC32XX.h:308
size_t rxSize
Definition: UART2CC32XX.h:290
int intNum
Definition: UART2CC32XX.h:237
void UART2CC32XX_readCancel(UART2_Handle handle)
uint32_t flowControl
Definition: UART2CC32XX.h:241
size_t readSize
Definition: UART2CC32XX.h:287
unsigned char * readBuf
Definition: UART2CC32XX.h:286
UART2_DataLen dataLength
Definition: UART2CC32XX.h:277
UART2CC32XX_FifoThreshold rxIntFifoThr
Definition: UART2CC32XX.h:253
void(* UART2_Callback)(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status)
The definition of a callback function used by the UART2 driver when used in UART2_Mode_CALLBACK The c...
Definition: UART2.h:328
int_fast16_t UART2CC32XX_read(UART2_Handle handle, void *buffer, size_t size, size_t *bytesRead, uint32_t timeout)
size_t writeCount
Definition: UART2CC32XX.h:299
UART2_DataLen
UART2 data length settings.
Definition: UART2.h:386
UART2CC32XX_FifoThreshold txIntFifoThr
Definition: UART2CC32XX.h:251
PowerCC32XX_ParkState
Enumeration of states a pin can be parked in.
Definition: PowerCC32XX.h:385
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale