TI-RTOS Drivers  tidrivers_full_2_20_00_08
UARTMSP432.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  */
78 #ifndef ti_drivers_uart_UARTMSP432__include
79 #define ti_drivers_uart_UARTMSP432__include
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 #include <stdint.h>
86 #include <stdbool.h>
87 
89 #include <ti/drivers/ports/HwiP.h>
91 #include <ti/drivers/Power.h>
92 #include <ti/drivers/UART.h>
94 
105 /* Add UARTMSP432_STATUS_* macros here */
106 
119 /* Add UARTMSP432_CMD_* macros here */
120 
123 /* UART function table pointer */
125 
147 typedef struct UARTMSP432_FxnSet {
148  bool (*readIsrFxn) (UART_Handle handle);
149  int (*readTaskFxn) (UART_Handle handle);
151 
183  uint32_t outputBaudrate;
184  uint32_t inputClockFreq;
186  uint16_t prescalar;
187  uint8_t hwRegUCBRFx;
188  uint8_t hwRegUCBRSx;
189  uint8_t oversampling;
191 
242 typedef struct UARTMSP432_HWAttrs {
244  unsigned int baseAddr;
246  unsigned int intNum;
248  unsigned int intPriority;
250  uint8_t clockSource;
252  uint32_t bitOrder;
258  unsigned char *ringBufPtr;
260  size_t ringBufSize;
262 
268 typedef struct UARTMSP432_Object {
269  /* UART state variable */
270  struct {
271  bool opened:1; /* Has the obj been opened */
272  UART_Mode readMode:1; /* Mode for all read calls */
273  UART_Mode writeMode:1; /* Mode for all write calls */
274  UART_DataMode readDataMode:1; /* Type of data being read */
275  UART_DataMode writeDataMode:1; /* Type of data being written */
276  UART_ReturnMode readReturnMode:1; /* Receive return mode */
277  UART_Echo readEcho:1; /* Echo received data back */
278  bool writeCR:1; /* Write a return character */
279  /*
280  * Flag to determine if a timeout has occurred when the user called
281  * UART_read(). This flag is set by the timeoutClk clock object.
282  */
283  bool bufTimeout:1;
284  /*
285  * Flag to determine when an ISR needs to perform a callback; in both
286  * UART_MODE_BLOCKING or UART_MODE_CALLBACK
287  */
288  bool callCallback:1;
289  /*
290  * Flag to determine if the ISR is in control draining the ring buffer
291  * when in UART_MODE_CALLBACK
292  */
293  bool drainByISR:1;
294  /* Flag to keep the state of the read Power constraints */
295  bool rxEnabled:1;
296  /* Flag to keep the state of the write Power constraints */
297  bool txEnabled:1;
298  } state;
299 
300  HwiP_Handle hwiHandle; /* Hwi handle for interrupts */
301  ClockP_Handle timeoutClk; /* Clock object to for timeouts */
302  uint32_t baudRate; /* Baud rate for UART */
303  UART_STOP stopBits; /* Stop bits for UART */
304  UART_PAR parityType; /* Parity bit type for UART */
305 
306  /* UART read variables */
307  RingBuf_Object ringBuffer; /* local circular buffer object */
308  /* A complement pair of read functions for both the ISR and UART_read() */
310  unsigned char *readBuf; /* Buffer data pointer */
311  size_t readSize; /* Desired number of bytes to read */
312  size_t readCount; /* Number of bytes left to read */
313  SemaphoreP_Handle readSem; /* UART read semaphore */
314  unsigned int readTimeout; /* Timeout for read semaphore */
315  UART_Callback readCallback; /* Pointer to read callback */
316 
317  /* UART write variables */
318  const unsigned char *writeBuf; /* Buffer data pointer */
319  size_t writeSize; /* Desired number of bytes to write*/
320  size_t writeCount; /* Number of bytes left to write */
321  SemaphoreP_Handle writeSem; /* UART write semaphore*/
322  unsigned int writeTimeout; /* Timeout for write semaphore */
323  UART_Callback writeCallback; /* Pointer to write callback */
324  unsigned int writeEmptyClkTimeout; /* TX FIFO timeout tick count */
325 
329 
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif /* ti_drivers_uart_UARTMSP432__include */
UARTMSP432 Baudrate configuration.
Definition: UARTMSP432.h:182
UART_Echo readEcho
Definition: UARTMSP432.h:277
uint32_t outputBaudrate
Definition: UARTMSP432.h:183
UART_STOP
UART stop bit settings.
Definition: UART.h:410
uint32_t baudRate
Definition: UARTMSP432.h:302
uint8_t clockSource
Definition: UARTMSP432.h:250
bool callCallback
Definition: UARTMSP432.h:288
RingBuf_Object ringBuffer
Definition: UARTMSP432.h:307
bool writeCR
Definition: UARTMSP432.h:278
unsigned int intNum
Definition: UARTMSP432.h:246
SemaphoreP_Handle writeSem
Definition: UARTMSP432.h:321
unsigned int writeEmptyClkTimeout
Definition: UARTMSP432.h:324
UARTMSP432_BaudrateConfig const * baudrateLUT
Definition: UARTMSP432.h:256
unsigned int intPriority
Definition: UARTMSP432.h:248
struct UARTMSP432_BaudrateConfig UARTMSP432_BaudrateConfig
UARTMSP432 Baudrate configuration.
bool txEnabled
Definition: UARTMSP432.h:297
uint32_t inputClockFreq
Definition: UARTMSP432.h:184
uint16_t prescalar
Definition: UARTMSP432.h:186
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
const unsigned char * writeBuf
Definition: UARTMSP432.h:318
Power manager interface.
UART_PAR
UART parity type settings.
Definition: UART.h:420
UART_Mode
UART mode settings.
Definition: UART.h:322
struct UARTMSP432_FxnSet UARTMSP432_FxnSet
Complement set of read functions to be used by the UART ISR and UARTMSP432_read(). Internal use only.
UART_DataMode
UART data mode settings.
Definition: UART.h:370
UART_ReturnMode
UART return mode settings.
Definition: UART.h:355
UART_Mode writeMode
Definition: UARTMSP432.h:273
bool bufTimeout
Definition: UARTMSP432.h:283
UART_Echo
UART echo settings.
Definition: UART.h:388
ClockP_Handle timeoutClk
Definition: UARTMSP432.h:301
void * SemaphoreP_Handle
Opaque client reference to an instance of a SemaphoreP.
Definition: SemaphoreP.h:96
UART_PAR parityType
Definition: UARTMSP432.h:304
Semaphore module for the RTOS Porting Interface.
size_t writeSize
Definition: UARTMSP432.h:319
struct UARTMSP432_Object * UARTMSP432_Handle
Power_NotifyObj perfChangeNotify
Definition: UARTMSP432.h:326
size_t readCount
Definition: UARTMSP432.h:312
UARTMSP432 Hardware attributes.
Definition: UARTMSP432.h:242
Complement set of read functions to be used by the UART ISR and UARTMSP432_read(). Internal use only.
Definition: UARTMSP432.h:147
UART_Callback writeCallback
Definition: UARTMSP432.h:323
UART_DataMode writeDataMode
Definition: UARTMSP432.h:275
unsigned int baseAddr
Definition: UARTMSP432.h:244
unsigned char * ringBufPtr
Definition: UARTMSP432.h:258
Power notify object structure.
Definition: Power.h:112
HwiP_Handle hwiHandle
Definition: UARTMSP432.h:300
bool drainByISR
Definition: UARTMSP432.h:293
UART driver interface.
struct UARTMSP432_HWAttrs UARTMSP432_HWAttrs
UARTMSP432 Hardware attributes.
const UART_FxnTable UARTMSP432_fxnTable
uint8_t oversampling
Definition: UARTMSP432.h:189
unsigned int readTimeout
Definition: UARTMSP432.h:314
size_t readSize
Definition: UARTMSP432.h:311
size_t ringBufSize
Definition: UARTMSP432.h:260
int(* readTaskFxn)(UART_Handle handle)
Definition: UARTMSP432.h:149
UART_ReturnMode readReturnMode
Definition: UARTMSP432.h:276
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
uint8_t numBaudrateEntries
Definition: UARTMSP432.h:254
SemaphoreP_Handle readSem
Definition: UARTMSP432.h:313
uint32_t perfConstraintMask
Definition: UARTMSP432.h:327
UART_STOP stopBits
Definition: UARTMSP432.h:303
Definition: RingBuf.h:44
uint8_t hwRegUCBRFx
Definition: UARTMSP432.h:187
UARTMSP432_FxnSet readFxns
Definition: UARTMSP432.h:309
UART_Callback readCallback
Definition: UARTMSP432.h:315
bool rxEnabled
Definition: UARTMSP432.h:295
UARTMSP432 Object.
Definition: UARTMSP432.h:268
unsigned char * readBuf
Definition: UARTMSP432.h:310
bool(* readIsrFxn)(UART_Handle handle)
Definition: UARTMSP432.h:148
void * HwiP_Handle
Opaque client reference to an instance of a HwiP.
Definition: HwiP.h:66
bool opened
Definition: UARTMSP432.h:271
struct UARTMSP432_Object UARTMSP432_Object
UARTMSP432 Object.
UART_DataMode readDataMode
Definition: UARTMSP432.h:274
uint32_t bitOrder
Definition: UARTMSP432.h:252
Hardware Interrupt module for the RTOS Porting Interface.
uint8_t hwRegUCBRSx
Definition: UARTMSP432.h:188
UART_Mode readMode
Definition: UARTMSP432.h:272
struct UARTMSP432_Object::@6 state
UART Global configuration.
Definition: UART.h:571
unsigned int writeTimeout
Definition: UARTMSP432.h:322
void * ClockP_Handle
Opaque client reference to an instance of a ClockP.
Definition: ClockP.h:91
size_t writeCount
Definition: UARTMSP432.h:320
Copyright 2016, Texas Instruments Incorporated