UART2CC26X2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-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_UART2CC26X2__include
50 #define ti_drivers_uart2_UART2CC26X2__include
51 
52 #include <stddef.h>
53 #include <stdint.h>
54 
55 #include <stdint.h>
56 #include <stdbool.h>
57 
58 #include <ti/devices/DeviceFamily.h>
59 #include DeviceFamily_constructPath(inc/hw_types.h)
60 #include DeviceFamily_constructPath(driverlib/udma.h)
61 
62 #include <ti/drivers/dpl/HwiP.h>
63 #include <ti/drivers/dpl/SemaphoreP.h>
64 #include <ti/drivers/UART2.h>
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
75 #define UART2CC26X2_FLOWCTRL_NONE 0
76 
80 #define UART2CC26X2_FLOWCTRL_HARDWARE 1
81 
83 #define UART2CC26X2_FIFO_SIZE 32
84 
93 typedef enum {
100 
101 /* UART2CC26X2 functions */
102 extern void UART2CC26X2_close(UART2_Handle handle);
103 extern void UART2CC26X2_flushRx(UART2_Handle handle);
104 extern UART2_Handle UART2CC26X2_open(uint_least8_t, UART2_Params *params);
105 extern int_fast16_t UART2CC26X2_read(UART2_Handle handle, void *buffer,
106  size_t size, size_t *bytesRead, uint32_t timeout);
107 extern void UART2CC26X2_readCancel(UART2_Handle handle);
108 extern int_fast16_t UART2CC26X2_write(UART2_Handle handle,
109  const void *buffer, size_t size, size_t *bytesWritten,
110  uint32_t timeout);
111 extern void UART2CC26X2_writeCancel(UART2_Handle handle);
112 
113 /* UART2 function table pointer */
115 
183 typedef struct {
185  uint32_t baseAddr;
187  int intNum;
189  uint8_t intPriority;
191  uint32_t flowControl;
193  uint8_t rxPin;
195  uint8_t txPin;
197  uint8_t ctsPin;
199  uint8_t rtsPin;
201  uint32_t rxChannelMask;
203  uint32_t txChannelMask;
209 
215 typedef struct {
216  /* UART2 state variable */
217  struct {
218  bool opened:1; /* Has the obj been opened */
219  UART2_Mode readMode; /* Mode for read calls */
220  UART2_Mode writeMode; /* Mode for write calls */
221  UART2_ReadReturnMode readReturnMode:1; /* RX return mode (partial/full) */
222  /* Flag to indicate ongoing transmit */
223  bool txEnabled:1;
224  } state;
225 
226  HwiP_Struct hwi; /* Hwi object for interrupts */
227  uint32_t baudRate; /* Baud rate for UART */
228  UART2_DataLen dataLength; /* Data length for UART */
229  UART2_StopBits stopBits; /* Stop bits for UART */
230  UART2_Parity parityType; /* Parity bit type for UART */
231  int32_t rxStatus; /* RX status */
232  int32_t txStatus; /* TX status */
233  void *userArg; /* User supplied arg for callbacks */
234  UDMACC26XX_Handle udmaHandle; /* For setting power dependency */
235  volatile tDMAControlTable *rxDmaEntry;
236  volatile tDMAControlTable *txDmaEntry;
237 
238  /* UART read variables */
239  unsigned char *readBuf; /* Buffer data pointer */
240  size_t readSize; /* Number of bytes to read */
241  uint32_t nReadTransfers; /* Number of DMA transfers needed */
242  size_t readCount; /* Number of bytes left to read */
243  size_t rxSize; /* # of bytes to read in DMA xfer */
244  size_t bytesRead; /* Number of bytes read */
245  SemaphoreP_Struct readSem; /* UART read semaphore */
246  UART2_Callback readCallback; /* Pointer to read callback */
247 
248  /* UART write variables */
249  const unsigned char *writeBuf; /* Buffer data pointer */
250  size_t writeSize; /* Number of bytes to write*/
251  uint32_t nWriteTransfers; /* Number of DMA transfers needed */
252  size_t writeCount; /* Number of bytes left to write */
253  size_t txSize; /* # of bytes to write with DMA */
254  size_t bytesWritten; /* Number of bytes written */
255  SemaphoreP_Struct writeSem; /* UART write semaphore*/
256  UART2_Callback writeCallback; /* Pointer to write callback */
257 
258  /* PIN driver state object and handle */
261 
262  /* For Power management */
264  unsigned int powerMgrId; /* Determined from base address */
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 
271 #endif /* ti_drivers_uart2_UART2CC26X2__include */
UART2_Mode readMode
Definition: UART2CC26X2.h:219
UART2 Global configuration.
Definition: UART2.h:516
unsigned int powerMgrId
Definition: UART2CC26X2.h:264
uint8_t intPriority
Definition: UART2CC26X2.h:189
uint8_t txPin
Definition: UART2CC26X2.h:195
UART2_ReadReturnMode
UART2 return mode settings.
Definition: UART2.h:373
UART2_Handle UART2CC26X2_open(uint_least8_t, UART2_Params *params)
UART2CC26X2 Object.
Definition: UART2CC26X2.h:215
void * userArg
Definition: UART2CC26X2.h:233
size_t bytesWritten
Definition: UART2CC26X2.h:254
UART2CC26X2_FifoThreshold txIntFifoThr
Definition: UART2CC26X2.h:205
UDMACC26XX_Handle udmaHandle
Definition: UART2CC26X2.h:234
size_t readCount
Definition: UART2CC26X2.h:242
UART2_Parity
UART2 parity type settings.
Definition: UART2.h:408
UART2_DataLen dataLength
Definition: UART2CC26X2.h:228
Definition: UART2CC26X2.h:97
const UART2_FxnTable UART2CC26X2_fxnTable
PRELIMINARY UART driver interface
Definition: UART2CC26X2.h:94
UDMACC26XX Global configuration.
Definition: UDMACC26XX.h:221
uint8_t rxPin
Definition: UART2CC26X2.h:193
volatile tDMAControlTable * txDmaEntry
Definition: UART2CC26X2.h:236
Power_NotifyObj postNotify
Definition: UART2CC26X2.h:263
uint32_t nReadTransfers
Definition: UART2CC26X2.h:241
The definition of a UART2 function table that contains the required set of functions to control a spe...
Definition: UART2.h:486
int32_t rxStatus
Definition: UART2CC26X2.h:231
UART2_StopBits stopBits
Definition: UART2CC26X2.h:229
int intNum
Definition: UART2CC26X2.h:187
Definition: UART2CC26X2.h:98
void UART2CC26X2_readCancel(UART2_Handle handle)
void UART2CC26X2_flushRx(UART2_Handle handle)
size_t writeCount
Definition: UART2CC26X2.h:252
uint32_t baudRate
Definition: UART2CC26X2.h:227
size_t bytesRead
Definition: UART2CC26X2.h:244
Device-specific pin & GPIO driver for CC26xx family [def].
uint32_t flowControl
Definition: UART2CC26X2.h:191
UART2_Mode
UART2 mode settings.
Definition: UART2.h:336
UART2CC26X2 Hardware attributes.
Definition: UART2CC26X2.h:183
SemaphoreP_Struct writeSem
Definition: UART2CC26X2.h:255
struct UART2CC26X2_Object * UART2CC26X2_Handle
Definition: UART2CC26X2.h:95
size_t readSize
Definition: UART2CC26X2.h:240
PIN_Handle hPin
Definition: UART2CC26X2.h:260
UDMACC26XX driver implementation.
size_t rxSize
Definition: UART2CC26X2.h:243
UART2 Parameters.
Definition: UART2.h:424
Power notify object structure.
Definition: Power.h:443
UART2_StopBits
UART2 stop bit settings.
Definition: UART2.h:398
UART2_Parity parityType
Definition: UART2CC26X2.h:230
unsigned char * readBuf
Definition: UART2CC26X2.h:239
uint32_t txChannelMask
Definition: UART2CC26X2.h:203
UART2_Callback writeCallback
Definition: UART2CC26X2.h:256
UART2CC26X2_FifoThreshold rxIntFifoThr
Definition: UART2CC26X2.h:207
UART2CC26X2_FifoThreshold
UART TX/RX interrupt FIFO threshold select.
Definition: UART2CC26X2.h:93
void UART2CC26X2_writeCancel(UART2_Handle handle)
underlying data structure for type PIN_State
Definition: PIN.h:708
void UART2CC26X2_close(UART2_Handle handle)
SemaphoreP_Struct readSem
Definition: UART2CC26X2.h:245
uint32_t nWriteTransfers
Definition: UART2CC26X2.h:251
uint32_t baseAddr
Definition: UART2CC26X2.h:185
UART2_Callback readCallback
Definition: UART2CC26X2.h:246
HwiP_Struct hwi
Definition: UART2CC26X2.h:226
PIN_State pinState
Definition: UART2CC26X2.h:259
size_t txSize
Definition: UART2CC26X2.h:253
size_t writeSize
Definition: UART2CC26X2.h:250
uint8_t ctsPin
Definition: UART2CC26X2.h:197
Definition: UART2CC26X2.h:96
int_fast16_t UART2CC26X2_write(UART2_Handle handle, const void *buffer, size_t size, size_t *bytesWritten, uint32_t timeout)
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
int32_t txStatus
Definition: UART2CC26X2.h:232
UART2_Mode writeMode
Definition: UART2CC26X2.h:220
UART2_DataLen
UART2 data length settings.
Definition: UART2.h:386
uint32_t rxChannelMask
Definition: UART2CC26X2.h:201
uint8_t rtsPin
Definition: UART2CC26X2.h:199
int_fast16_t UART2CC26X2_read(UART2_Handle handle, void *buffer, size_t size, size_t *bytesRead, uint32_t timeout)
volatile tDMAControlTable * rxDmaEntry
Definition: UART2CC26X2.h:235
const unsigned char * writeBuf
Definition: UART2CC26X2.h:249
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale