UART2CC26X2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, 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 
100 
101 /* UART2CC26X2 functions */
102 extern void UART2CC26X2_close(UART2_Handle handle);
103 extern void UART2CC26X2_disableRx(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, size_t size,
106  size_t *bytesRead);
107 extern void UART2CC26X2_readCancel(UART2_Handle handle);
108 extern int_fast16_t UART2CC26X2_write(UART2_Handle handle, const void *buffer,
109  size_t size, size_t *bytesWritten);
110 extern void UART2CC26X2_writeCancel(UART2_Handle handle);
111 extern void UART2CC26X2_flushRx(UART2_Handle handle);
112 extern void UART2CC26X2_getParams(UART2_Handle handle, UART2_Params *params);
113 extern void UART2CC26X2_setParams(UART2_Handle handle, UART2_Params *params);
114 
115 /* UART2 function table pointer */
117 
182 typedef struct UART2CC26X2_HWAttrs {
184  uint32_t baseAddr;
186  int intNum;
188  uint8_t intPriority;
190  uint32_t flowControl;
192  uint8_t rxPin;
194  uint8_t txPin;
196  uint8_t ctsPin;
198  uint8_t rtsPin;
200  uint32_t rxChannelMask;
202  uint32_t txChannelMask;
208 
214 typedef struct UART2CC26X2_Object {
215  /* UART2 state variable */
216  struct {
217  bool opened:1; /* Has the obj been opened */
218  UART2_Mode readMode; /* Mode for read calls */
219  UART2_Mode writeMode; /* Mode for write calls */
220  UART2_ReadReturnMode readReturnMode:1; /* RX return mode (partial/full) */
221  /* Flag to indicate ongoing transmit */
222  bool txEnabled:1;
223  } state;
224 
225  HwiP_Struct hwi; /* Hwi object for interrupts */
226  uint32_t baudRate; /* Baud rate for UART */
227  UART2_DataLen dataLength; /* Data length for UART */
228  UART2_StopBits stopBits; /* Stop bits for UART */
229  UART2_Parity parityType; /* Parity bit type for UART */
230  int32_t rxStatus; /* RX status */
231  int32_t txStatus; /* TX status */
232  void *userArg; /* User supplied arg for callbacks */
233  UDMACC26XX_Handle udmaHandle; /* For setting power dependency */
234  volatile tDMAControlTable *rxDmaEntry;
235  volatile tDMAControlTable *txDmaEntry;
236 
237  /* UART read variables */
238  unsigned char *readBuf; /* Buffer data pointer */
239  size_t readSize; /* Number of bytes to read */
240  uint32_t nReadTransfers; /* Number of DMA transfers needed */
241  size_t readCount; /* Number of bytes left to read */
242  size_t rxSize; /* # of bytes to read in DMA xfer */
243  size_t bytesRead; /* Number of bytes read */
244  SemaphoreP_Struct readSem; /* UART read semaphore */
245  unsigned int readTimeout; /* Timeout for 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  unsigned int writeTimeout; /* Timeout for write semaphore */
257  UART2_Callback writeCallback; /* Pointer to write callback */
258 
259  /* PIN driver state object and handle */
262 
263  /* For Power management */
265  unsigned int powerMgrId; /* Determined from base address */
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif /* ti_drivers_uart2_UART2CC26X2__include */
UART2_Mode readMode
Definition: UART2CC26X2.h:218
unsigned int powerMgrId
Definition: UART2CC26X2.h:265
uint8_t intPriority
Definition: UART2CC26X2.h:188
uint8_t txPin
Definition: UART2CC26X2.h:194
UART2_ReadReturnMode
UART2 return mode settings.
Definition: UART2.h:371
UART2_Handle UART2CC26X2_open(uint_least8_t, UART2_Params *params)
struct UART2CC26X2_HWAttrs UART2CC26X2_HWAttrs
UART2CC26X2 Hardware attributes.
UART2CC26X2 Object.
Definition: UART2CC26X2.h:214
void * userArg
Definition: UART2CC26X2.h:232
size_t bytesWritten
Definition: UART2CC26X2.h:254
UART2CC26X2_FifoThreshold txIntFifoThr
Definition: UART2CC26X2.h:204
UDMACC26XX_Handle udmaHandle
Definition: UART2CC26X2.h:233
size_t readCount
Definition: UART2CC26X2.h:241
UART2_Parity
UART2 parity type settings.
Definition: UART2.h:406
UART2_DataLen dataLength
Definition: UART2CC26X2.h:227
Definition: UART2CC26X2.h:97
const UART2_FxnTable UART2CC26X2_fxnTable
PRELIMINARY UART driver interface
Definition: UART2CC26X2.h:94
void UART2CC26X2_disableRx(UART2_Handle handle)
UDMACC26XX Global configuration.
Definition: UDMACC26XX.h:222
uint8_t rxPin
Definition: UART2CC26X2.h:192
volatile tDMAControlTable * txDmaEntry
Definition: UART2CC26X2.h:235
Power_NotifyObj postNotify
Definition: UART2CC26X2.h:264
struct UART2CC26X2_Object UART2CC26X2_Object
UART2CC26X2 Object.
int_fast16_t UART2CC26X2_read(UART2_Handle handle, void *buffer, size_t size, size_t *bytesRead)
uint32_t nReadTransfers
Definition: UART2CC26X2.h:240
The definition of a UART2 function table that contains the required set of functions to control a spe...
Definition: UART2.h:485
int32_t rxStatus
Definition: UART2CC26X2.h:230
UART2_StopBits stopBits
Definition: UART2CC26X2.h:228
int intNum
Definition: UART2CC26X2.h:186
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:226
size_t bytesRead
Definition: UART2CC26X2.h:243
UART2 Global configuration.
Definition: UART2.h:515
Device-specific pin & GPIO driver for CC26xx family [def].
uint32_t flowControl
Definition: UART2CC26X2.h:190
UART2_Mode
UART2 mode settings.
Definition: UART2.h:334
UART2CC26X2 Hardware attributes.
Definition: UART2CC26X2.h:182
SemaphoreP_Struct writeSem
Definition: UART2CC26X2.h:255
Definition: UART2CC26X2.h:95
size_t readSize
Definition: UART2CC26X2.h:239
PIN_Handle hPin
Definition: UART2CC26X2.h:261
UDMACC26XX driver implementation.
size_t rxSize
Definition: UART2CC26X2.h:242
UART2 Parameters.
Definition: UART2.h:422
unsigned int readTimeout
Definition: UART2CC26X2.h:245
Power notify object structure.
Definition: Power.h:443
UART2_StopBits
UART2 stop bit settings.
Definition: UART2.h:396
UART2_Parity parityType
Definition: UART2CC26X2.h:229
unsigned char * readBuf
Definition: UART2CC26X2.h:238
uint32_t txChannelMask
Definition: UART2CC26X2.h:202
UART2_Callback writeCallback
Definition: UART2CC26X2.h:257
UART2CC26X2_FifoThreshold rxIntFifoThr
Definition: UART2CC26X2.h:206
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:244
uint32_t nWriteTransfers
Definition: UART2CC26X2.h:251
struct UART2CC26X2_Object * UART2CC26X2_Handle
int_fast16_t UART2CC26X2_write(UART2_Handle handle, const void *buffer, size_t size, size_t *bytesWritten)
uint32_t baseAddr
Definition: UART2CC26X2.h:184
UART2_Callback readCallback
Definition: UART2CC26X2.h:246
void UART2CC26X2_setParams(UART2_Handle handle, UART2_Params *params)
HwiP_Struct hwi
Definition: UART2CC26X2.h:225
unsigned int writeTimeout
Definition: UART2CC26X2.h:256
PIN_State pinState
Definition: UART2CC26X2.h:260
size_t txSize
Definition: UART2CC26X2.h:253
size_t writeSize
Definition: UART2CC26X2.h:250
uint8_t ctsPin
Definition: UART2CC26X2.h:196
Definition: UART2CC26X2.h:96
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:326
int32_t txStatus
Definition: UART2CC26X2.h:231
UART2_Mode writeMode
Definition: UART2CC26X2.h:219
void UART2CC26X2_getParams(UART2_Handle handle, UART2_Params *params)
UART2_DataLen
UART2 data length settings.
Definition: UART2.h:384
uint32_t rxChannelMask
Definition: UART2CC26X2.h:200
uint8_t rtsPin
Definition: UART2CC26X2.h:198
volatile tDMAControlTable * rxDmaEntry
Definition: UART2CC26X2.h:234
const unsigned char * writeBuf
Definition: UART2CC26X2.h:249
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale