TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
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  */
76 #ifndef ti_drivers_uart_UARTMSP432__include
77 #define ti_drivers_uart_UARTMSP432__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>
91 #include <ti/drivers/uart/RingBuf.h>
92 
93 /* UART function table pointer */
95 
117 typedef struct UARTMSP432_FxnSet {
118  bool (*readIsrFxn) (UART_Handle handle);
119  int (*readTaskFxn) (UART_Handle handle);
121 
153  uint32_t outputBaudrate;
154  uint32_t inputClockFreq;
156  uint16_t prescalar;
157  uint8_t hwRegUCBRFx;
158  uint8_t hwRegUCBRSx;
159  uint8_t oversampling;
161 
212 typedef struct UARTMSP432_HWAttrs {
214  unsigned int baseAddr;
216  unsigned int intNum;
218  unsigned int intPriority;
220  uint8_t clockSource;
222  uint32_t bitOrder;
228  unsigned char *ringBufPtr;
230  size_t ringBufSize;
232 
238 typedef struct UARTMSP432_Object {
239  /* UART state variable */
240  struct {
241  bool opened:1; /* Has the obj been opened */
242  UART_Mode readMode:1; /* Mode for all read calls */
243  UART_Mode writeMode:1; /* Mode for all write calls */
244  UART_DataMode readDataMode:1; /* Type of data being read */
245  UART_DataMode writeDataMode:1; /* Type of data being written */
246  UART_ReturnMode readReturnMode:1; /* Receive return mode */
247  UART_Echo readEcho:1; /* Echo received data back */
248  bool writeCR:1; /* Write a return character */
249  /*
250  * Flag to determine if a timeout has occurred when the user called
251  * UART_read(). This flag is set by the timeoutClk clock object.
252  */
253  bool bufTimeout:1;
254  /*
255  * Flag to determine when an ISR needs to perform a callback; in both
256  * UART_MODE_BLOCKING or UART_MODE_CALLBACK
257  */
258  bool callCallback:1;
259  /*
260  * Flag to determine if the ISR is in control draining the ring buffer
261  * when in UART_MODE_CALLBACK
262  */
263  bool drainByISR:1;
264  /* Flag to keep the state of the read Power constraints */
265  bool rxEnabled:1;
266  /* Flag to keep the state of the write Power constraints */
267  bool txEnabled:1;
268  } state;
269 
270  HwiP_Handle hwiHandle; /* Hwi handle for interrupts */
271  ClockP_Handle timeoutClk; /* Clock object to for timeouts */
272  uint32_t baudRate; /* Baud rate for UART */
273  UART_STOP stopBits; /* Stop bits for UART */
274  UART_PAR parityType; /* Parity bit type for UART */
275 
276  /* UART read variables */
277  RingBuf_Object ringBuffer; /* local circular buffer object */
278  /* A complement pair of read functions for both the ISR and UART_read() */
280  unsigned char *readBuf; /* Buffer data pointer */
281  size_t readSize; /* Desired number of bytes to read */
282  size_t readCount; /* Number of bytes left to read */
283  SemaphoreP_Handle readSem; /* UART read semaphore */
284  unsigned int readTimeout; /* Timeout for read semaphore */
285  UART_Callback readCallback; /* Pointer to read callback */
286 
287  /* UART write variables */
288  const unsigned char *writeBuf; /* Buffer data pointer */
289  size_t writeSize; /* Desired number of bytes to write*/
290  size_t writeCount; /* Number of bytes left to write */
291  SemaphoreP_Handle writeSem; /* UART write semaphore*/
292  unsigned int writeTimeout; /* Timeout for write semaphore */
293  UART_Callback writeCallback; /* Pointer to write callback */
294  unsigned int writeEmptyClkTimeout; /* TX FIFO timeout tick count */
295 
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* ti_drivers_uart_UARTMSP432__include */
UARTMSP432 Baudrate configuration.
Definition: UARTMSP432.h:152
UART_Echo readEcho
Definition: UARTMSP432.h:247
uint32_t outputBaudrate
Definition: UARTMSP432.h:153
UART_STOP
UART stop bit settings.
Definition: UART.h:379
uint32_t baudRate
Definition: UARTMSP432.h:272
uint8_t clockSource
Definition: UARTMSP432.h:220
bool callCallback
Definition: UARTMSP432.h:258
RingBuf_Object ringBuffer
Definition: UARTMSP432.h:277
bool writeCR
Definition: UARTMSP432.h:248
unsigned int intNum
Definition: UARTMSP432.h:216
SemaphoreP_Handle writeSem
Definition: UARTMSP432.h:291
unsigned int writeEmptyClkTimeout
Definition: UARTMSP432.h:294
UARTMSP432_BaudrateConfig const * baudrateLUT
Definition: UARTMSP432.h:226
unsigned int intPriority
Definition: UARTMSP432.h:218
struct UARTMSP432_BaudrateConfig UARTMSP432_BaudrateConfig
UARTMSP432 Baudrate configuration.
bool txEnabled
Definition: UARTMSP432.h:267
uint32_t inputClockFreq
Definition: UARTMSP432.h:154
uint16_t prescalar
Definition: UARTMSP432.h:156
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:497
const unsigned char * writeBuf
Definition: UARTMSP432.h:288
Power manager interface.
UART_PAR
UART parity type settings.
Definition: UART.h:389
UART_Mode
UART mode settings.
Definition: UART.h:291
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:339
UART_ReturnMode
UART return mode settings.
Definition: UART.h:324
UART_Mode writeMode
Definition: UARTMSP432.h:243
bool bufTimeout
Definition: UARTMSP432.h:253
UART_Echo
UART echo settings.
Definition: UART.h:357
ClockP_Handle timeoutClk
Definition: UARTMSP432.h:271
void * SemaphoreP_Handle
Opaque client reference to an instance of a SemaphoreP.
Definition: SemaphoreP.h:96
UART_PAR parityType
Definition: UARTMSP432.h:274
Semaphore module for the RTOS Porting Interface.
size_t writeSize
Definition: UARTMSP432.h:289
struct UARTMSP432_Object * UARTMSP432_Handle
Power_NotifyObj perfChangeNotify
Definition: UARTMSP432.h:296
size_t readCount
Definition: UARTMSP432.h:282
UARTMSP432 Hardware attributes.
Definition: UARTMSP432.h:212
Complement set of read functions to be used by the UART ISR and UARTMSP432_read(). Internal use only.
Definition: UARTMSP432.h:117
UART_Callback writeCallback
Definition: UARTMSP432.h:293
UART_DataMode writeDataMode
Definition: UARTMSP432.h:245
unsigned int baseAddr
Definition: UARTMSP432.h:214
struct UARTMSP432_Object::@9 state
unsigned char * ringBufPtr
Definition: UARTMSP432.h:228
Power notify object structure.
Definition: Power.h:112
HwiP_Handle hwiHandle
Definition: UARTMSP432.h:270
bool drainByISR
Definition: UARTMSP432.h:263
UART driver interface.
struct UARTMSP432_HWAttrs UARTMSP432_HWAttrs
UARTMSP432 Hardware attributes.
const UART_FxnTable UARTMSP432_fxnTable
uint8_t oversampling
Definition: UARTMSP432.h:159
unsigned int readTimeout
Definition: UARTMSP432.h:284
size_t readSize
Definition: UARTMSP432.h:281
size_t ringBufSize
Definition: UARTMSP432.h:230
int(* readTaskFxn)(UART_Handle handle)
Definition: UARTMSP432.h:119
UART_ReturnMode readReturnMode
Definition: UARTMSP432.h:246
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:284
uint8_t numBaudrateEntries
Definition: UARTMSP432.h:224
SemaphoreP_Handle readSem
Definition: UARTMSP432.h:283
uint32_t perfConstraintMask
Definition: UARTMSP432.h:297
UART_STOP stopBits
Definition: UARTMSP432.h:273
uint8_t hwRegUCBRFx
Definition: UARTMSP432.h:157
UARTMSP432_FxnSet readFxns
Definition: UARTMSP432.h:279
UART_Callback readCallback
Definition: UARTMSP432.h:285
bool rxEnabled
Definition: UARTMSP432.h:265
UARTMSP432 Object.
Definition: UARTMSP432.h:238
unsigned char * readBuf
Definition: UARTMSP432.h:280
bool(* readIsrFxn)(UART_Handle handle)
Definition: UARTMSP432.h:118
void * HwiP_Handle
Opaque client reference to an instance of a HwiP.
Definition: HwiP.h:66
bool opened
Definition: UARTMSP432.h:241
struct UARTMSP432_Object UARTMSP432_Object
UARTMSP432 Object.
UART_DataMode readDataMode
Definition: UARTMSP432.h:244
uint32_t bitOrder
Definition: UARTMSP432.h:222
Hardware Interrupt module for the RTOS Porting Interface.
uint8_t hwRegUCBRSx
Definition: UARTMSP432.h:158
UART_Mode readMode
Definition: UARTMSP432.h:242
UART Global configuration.
Definition: UART.h:540
unsigned int writeTimeout
Definition: UARTMSP432.h:292
void * ClockP_Handle
Opaque client reference to an instance of a ClockP.
Definition: ClockP.h:91
size_t writeCount
Definition: UARTMSP432.h:290
Copyright 2015, Texas Instruments Incorporated