TI-RTOS Drivers  tidrivers_full_2_20_00_08
UARTCC3200.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 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  */
76 #ifndef ti_drivers_uart_UARTCC3200__include
77 #define ti_drivers_uart_UARTCC3200__include
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 #include <stdint.h>
84 #include <stdbool.h>
85 
87 #include <ti/drivers/ports/HwiP.h>
89 #include <ti/drivers/Power.h>
90 #include <ti/drivers/UART.h>
92 
103 /* Add UARTCC3200_STATUS_* macros here */
104 
117 /* Add UARTCC3200_CMD_* macros here */
118 
121 /* UART function table pointer */
123 
145 typedef struct UARTCC3200_FxnSet {
146  bool (*readIsrFxn) (UART_Handle handle);
147  int (*readTaskFxn) (UART_Handle handle);
149 
194 typedef struct UARTCC3200_HWAttrs {
196  unsigned int baseAddr;
198  unsigned int intNum;
200  unsigned int intPriority;
202  uint32_t flowControl;
204  unsigned char *ringBufPtr;
206  size_t ringBufSize;
208 
214 typedef struct UARTCC3200_Object {
215  /* UART state variable */
216  struct {
217  bool opened:1; /* Has the obj been opened */
218  UART_Mode readMode:1; /* Mode for all read calls */
219  UART_Mode writeMode:1; /* Mode for all write calls */
220  UART_DataMode readDataMode:1; /* Type of data being read */
221  UART_DataMode writeDataMode:1; /* Type of data being written */
222  UART_ReturnMode readReturnMode:1; /* Receive return mode */
223  UART_Echo readEcho:1; /* Echo received data back */
224  /*
225  * Flag to determine if a timeout has occurred when the user called
226  * UART_read(). This flag is set by the timeoutClk clock object.
227  */
228  bool bufTimeout:1;
229  /*
230  * Flag to determine when an ISR needs to perform a callback; in both
231  * UART_MODE_BLOCKING or UART_MODE_CALLBACK
232  */
233  bool callCallback:1;
234  /*
235  * Flag to determine if the ISR is in control draining the ring buffer
236  * when in UART_MODE_CALLBACK
237  */
238  bool drainByISR:1;
239  /* Flag to keep the state of the read Power constraints */
240  bool rxEnabled:1;
241  /* Flag to keep the state of the write Power constraints */
242  bool txEnabled:1;
243  } state;
244 
245  HwiP_Handle hwiHandle; /* Hwi handle for interrupts */
246  ClockP_Handle timeoutClk; /* Clock object to for timeouts */
247  uint32_t baudRate; /* Baud rate for UART */
248  UART_LEN dataLength; /* Data length for UART */
249  UART_STOP stopBits; /* Stop bits for UART */
250  UART_PAR parityType; /* Parity bit type for UART */
251 
252  /* UART read variables */
253  RingBuf_Object ringBuffer; /* local circular buffer object */
254  /* A complement pair of read functions for both the ISR and UART_read() */
256  unsigned char *readBuf; /* Buffer data pointer */
257  size_t readSize; /* Desired number of bytes to read */
258  size_t readCount; /* Number of bytes left to read */
259  SemaphoreP_Handle readSem; /* UART read semaphore */
260  unsigned int readTimeout; /* Timeout for read semaphore */
261  UART_Callback readCallback; /* Pointer to read callback */
262 
263  /* UART write variables */
264  const unsigned char *writeBuf; /* Buffer data pointer */
265  size_t writeSize; /* Desired number of bytes to write*/
266  size_t writeCount; /* Number of bytes left to write */
267  SemaphoreP_Handle writeSem; /* UART write semaphore*/
268  unsigned int writeTimeout; /* Timeout for write semaphore */
269  UART_Callback writeCallback; /* Pointer to write callback */
270  unsigned int writeEmptyClkTimeout; /* TX FIFO timeout tick count */
271 
272  /* For Power management */
273  ClockP_Handle txFifoEmptyClk; /* UART TX FIFO empty clock */
274  Power_NotifyObj postNotify; /* LPDS wake-up notify object */
275  unsigned int powerMgrId; /* Determined from base address */
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif /* ti_drivers_uart_UARTCC3200__include */
HwiP_Handle hwiHandle
Definition: UARTCC3200.h:245
UART_STOP
UART stop bit settings.
Definition: UART.h:410
size_t writeCount
Definition: UARTCC3200.h:266
bool callCallback
Definition: UARTCC3200.h:233
size_t readSize
Definition: UARTCC3200.h:257
bool(* readIsrFxn)(UART_Handle handle)
Definition: UARTCC3200.h:146
UART_Echo readEcho
Definition: UARTCC3200.h:223
struct UARTCC3200_FxnSet UARTCC3200_FxnSet
Complement set of read functions to be used by the UART ISR and UARTCC3200_read(). Internal use only.
UART_LEN dataLength
Definition: UARTCC3200.h:248
unsigned int powerMgrId
Definition: UARTCC3200.h:275
unsigned int writeTimeout
Definition: UARTCC3200.h:268
Clock interface for the RTOS Porting Interface.
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:528
UART_PAR parityType
Definition: UARTCC3200.h:250
Power manager interface.
UART_PAR
UART parity type settings.
Definition: UART.h:420
bool opened
Definition: UARTCC3200.h:217
UART_Mode
UART mode settings.
Definition: UART.h:322
bool drainByISR
Definition: UARTCC3200.h:238
uint32_t baudRate
Definition: UARTCC3200.h:247
UART_DataMode
UART data mode settings.
Definition: UART.h:370
UART_ReturnMode
UART return mode settings.
Definition: UART.h:355
bool rxEnabled
Definition: UARTCC3200.h:240
UART_Mode readMode
Definition: UARTCC3200.h:218
UART_Echo
UART echo settings.
Definition: UART.h:388
size_t ringBufSize
Definition: UARTCC3200.h:206
UART_Callback readCallback
Definition: UARTCC3200.h:261
void * SemaphoreP_Handle
Opaque client reference to an instance of a SemaphoreP.
Definition: SemaphoreP.h:96
int(* readTaskFxn)(UART_Handle handle)
Definition: UARTCC3200.h:147
struct UARTCC3200_Object UARTCC3200_Object
UARTCC3200 Object.
Semaphore module for the RTOS Porting Interface.
SemaphoreP_Handle writeSem
Definition: UARTCC3200.h:267
ClockP_Handle txFifoEmptyClk
Definition: UARTCC3200.h:273
unsigned int baseAddr
Definition: UARTCC3200.h:196
UART_DataMode readDataMode
Definition: UARTCC3200.h:220
RingBuf_Object ringBuffer
Definition: UARTCC3200.h:253
unsigned int intPriority
Definition: UARTCC3200.h:200
UARTCC3200_FxnSet readFxns
Definition: UARTCC3200.h:255
unsigned char * readBuf
Definition: UARTCC3200.h:256
UART_DataMode writeDataMode
Definition: UARTCC3200.h:221
Complement set of read functions to be used by the UART ISR and UARTCC3200_read(). Internal use only.
Definition: UARTCC3200.h:145
UARTCC3200 Object.
Definition: UARTCC3200.h:214
bool txEnabled
Definition: UARTCC3200.h:242
Power notify object structure.
Definition: Power.h:112
UART driver interface.
UART_Callback writeCallback
Definition: UARTCC3200.h:269
uint32_t flowControl
Definition: UARTCC3200.h:202
struct UARTCC3200_HWAttrs UARTCC3200_HWAttrs
UARTCC3200 Hardware attributes.
ClockP_Handle timeoutClk
Definition: UARTCC3200.h:246
struct UARTCC3200_Object::@5 state
void(* UART_Callback)(UART_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:315
UARTCC3200 Hardware attributes.
Definition: UARTCC3200.h:194
unsigned int readTimeout
Definition: UARTCC3200.h:260
unsigned char * ringBufPtr
Definition: UARTCC3200.h:204
Definition: RingBuf.h:44
UART_LEN
UART data length settings.
Definition: UART.h:398
size_t readCount
Definition: UARTCC3200.h:258
UART_Mode writeMode
Definition: UARTCC3200.h:219
Power_NotifyObj postNotify
Definition: UARTCC3200.h:274
struct UARTCC3200_Object * UARTCC3200_Handle
void * HwiP_Handle
Opaque client reference to an instance of a HwiP.
Definition: HwiP.h:66
const UART_FxnTable UARTCC3200_fxnTable
unsigned int intNum
Definition: UARTCC3200.h:198
Hardware Interrupt module for the RTOS Porting Interface.
UART_ReturnMode readReturnMode
Definition: UARTCC3200.h:222
const unsigned char * writeBuf
Definition: UARTCC3200.h:264
size_t writeSize
Definition: UARTCC3200.h:265
UART Global configuration.
Definition: UART.h:571
SemaphoreP_Handle readSem
Definition: UARTCC3200.h:259
void * ClockP_Handle
Opaque client reference to an instance of a ClockP.
Definition: ClockP.h:91
bool bufTimeout
Definition: UARTCC3200.h:228
unsigned int writeEmptyClkTimeout
Definition: UARTCC3200.h:270
UART_STOP stopBits
Definition: UARTCC3200.h:249
Copyright 2016, Texas Instruments Incorporated