TI-RTOS for SimpleLink Wireless MCUs  2.14.02.22
UARTTiva.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  */
73 #ifndef ti_drivers_uart_UARTTiva__include
74 #define ti_drivers_uart_UARTTiva__include
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 #include <stdint.h>
81 #include <stdbool.h>
82 #include <ti/drivers/UART.h>
83 #include <ti/drivers/uart/RingBuf.h>
84 
85 #include <ti/sysbios/knl/Clock.h>
86 #include <ti/sysbios/knl/Semaphore.h>
87 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
88 #include <ti/sysbios/family/arm/m3/Hwi.h>
89 
90 /* UART function table pointer */
91 extern const UART_FxnTable UARTTiva_fxnTable;
92 
114 typedef struct UARTTiva_FxnSet {
115  bool (*readIsrFxn) (UART_Handle handle);
116  int (*readTaskFxn) (UART_Handle handle);
118 
152 typedef struct UARTTiva_HWAttrs {
154  unsigned int baseAddr;
156  unsigned int intNum;
158  unsigned int intPriority;
160  uint32_t flowControl;
162  unsigned char *ringBufPtr;
164  size_t ringBufSize;
166 
172 typedef struct UARTTiva_Object {
173  /* UART state variable */
174  struct {
175  bool opened:1; /* Has the obj been opened */
176  UART_Mode readMode:1; /* Mode for all read calls */
177  UART_Mode writeMode:1; /* Mode for all write calls */
178  UART_DataMode readDataMode:1; /* Type of data being read */
179  UART_DataMode writeDataMode:1; /* Type of data being written */
180  UART_ReturnMode readReturnMode:1; /* Receive return mode */
181  UART_Echo readEcho:1; /* Echo received data back */
182  /*
183  * Flag to determine if a timeout has occurred when the user called
184  * UART_read(). This flag is set by the timeoutClk clock object.
185  */
186  bool bufTimeout:1;
187  /*
188  * Flag to determine when an ISR needs to perform a callback; in both
189  * UART_MODE_BLOCKING or UART_MODE_CALLBACK
190  */
191  bool callCallback:1;
192  /*
193  * Flag to determine if the ISR is in control draining the ring buffer
194  * when in UART_MODE_CALLBACK
195  */
196  bool drainByISR:1;
197  /* Flag to keep the state of the read ring buffer */
198  bool rxEnabled:1;
199  } state;
200 
201  Clock_Struct timeoutClk; /* Clock object to for timeouts */
202  uint32_t baudRate; /* Baud rate for UART */
203  UART_LEN dataLength; /* Data length for UART */
204  UART_STOP stopBits; /* Stop bits for UART */
205  UART_PAR parityType; /* Parity bit type for UART */
206 
207  /* UART read variables */
208  RingBuf_Object ringBuffer; /* local circular buffer object */
209  /* A complement pair of read functions for both the ISR and UART_read() */
211  unsigned char *readBuf; /* Buffer data pointer */
212  size_t readSize; /* Desired number of bytes to read */
213  size_t readCount; /* Number of bytes left to read */
214  Semaphore_Struct readSem; /* UART read semaphore */
215  unsigned int readTimeout; /* Timeout for read semaphore */
216  UART_Callback readCallback; /* Pointer to read callback */
217 
218  /* UART write variables */
219  const unsigned char *writeBuf; /* Buffer data pointer */
220  size_t writeSize; /* Desired number of bytes to write*/
221  size_t writeCount; /* Number of bytes left to write */
222  Semaphore_Struct writeSem; /* UART write semaphore*/
223  unsigned int writeTimeout; /* Timeout for write semaphore */
224  UART_Callback writeCallback; /* Pointer to write callback */
225 
226  ti_sysbios_family_arm_m3_Hwi_Struct hwi; /* Hwi object */
228 
229 /* Do not interfere with the app if they include the family Hwi module */
230 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 
236 #endif /* ti_drivers_uart_UARTTiva__include */
struct UARTTiva_Object UARTTiva_Object
UARTTiva Object.
UARTTiva Object.
Definition: UARTTiva.h:172
UART_STOP
UART stop bit settings.
Definition: UART.h:379
UART_STOP stopBits
Definition: UARTTiva.h:204
struct UARTTiva_HWAttrs UARTTiva_HWAttrs
UARTTiva Hardware attributes.
unsigned char * readBuf
Definition: UARTTiva.h:211
size_t writeCount
Definition: UARTTiva.h:221
UART_Mode readMode
Definition: UARTTiva.h:176
uint32_t baudRate
Definition: UARTTiva.h:202
UART_LEN dataLength
Definition: UARTTiva.h:203
UARTTiva_FxnSet readFxns
Definition: UARTTiva.h:210
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:497
size_t ringBufSize
Definition: UARTTiva.h:164
UART_PAR
UART parity type settings.
Definition: UART.h:389
UART_Mode
UART mode settings.
Definition: UART.h:291
UART_DataMode
UART data mode settings.
Definition: UART.h:339
unsigned int intPriority
Definition: UARTTiva.h:158
size_t readCount
Definition: UARTTiva.h:213
bool opened
Definition: UARTTiva.h:175
UART_ReturnMode
UART return mode settings.
Definition: UART.h:324
size_t writeSize
Definition: UARTTiva.h:220
Semaphore_Struct readSem
Definition: UARTTiva.h:214
UART_Callback readCallback
Definition: UARTTiva.h:216
UART_Echo
UART echo settings.
Definition: UART.h:357
bool(* readIsrFxn)(UART_Handle handle)
Definition: UARTTiva.h:115
UART_DataMode readDataMode
Definition: UARTTiva.h:178
UART_Echo readEcho
Definition: UARTTiva.h:181
UARTTiva Hardware attributes.
Definition: UARTTiva.h:152
int(* readTaskFxn)(UART_Handle handle)
Definition: UARTTiva.h:116
unsigned int readTimeout
Definition: UARTTiva.h:215
UART_Mode writeMode
Definition: UARTTiva.h:177
unsigned int baseAddr
Definition: UARTTiva.h:154
bool rxEnabled
Definition: UARTTiva.h:198
UART_PAR parityType
Definition: UARTTiva.h:205
Clock_Struct timeoutClk
Definition: UARTTiva.h:201
unsigned char * ringBufPtr
Definition: UARTTiva.h:162
const UART_FxnTable UARTTiva_fxnTable
UART driver interface.
unsigned int intNum
Definition: UARTTiva.h:156
size_t readSize
Definition: UARTTiva.h:212
struct UARTTiva_Object * UARTTiva_Handle
const unsigned char * writeBuf
Definition: UARTTiva.h:219
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
UART_ReturnMode readReturnMode
Definition: UARTTiva.h:180
unsigned int writeTimeout
Definition: UARTTiva.h:223
Complement set of read functions to be used by the UART ISR and UARTTiva_read(). Internal use only...
Definition: UARTTiva.h:114
struct UARTTiva_Object::@10 state
UART_LEN
UART data length settings.
Definition: UART.h:367
bool drainByISR
Definition: UARTTiva.h:196
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: UARTTiva.h:226
struct UARTTiva_FxnSet UARTTiva_FxnSet
Complement set of read functions to be used by the UART ISR and UARTTiva_read(). Internal use only...
UART_Callback writeCallback
Definition: UARTTiva.h:224
Semaphore_Struct writeSem
Definition: UARTTiva.h:222
uint32_t flowControl
Definition: UARTTiva.h:160
bool bufTimeout
Definition: UARTTiva.h:186
RingBuf_Object ringBuffer
Definition: UARTTiva.h:208
UART_DataMode writeDataMode
Definition: UARTTiva.h:179
UART Global configuration.
Definition: UART.h:540
bool callCallback
Definition: UARTTiva.h:191
Copyright 2015, Texas Instruments Incorporated