TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
Data Structures | Macros | Typedefs | Variables
UARTTiva.h File Reference

Detailed Description

UART driver implementation for a Tiva UART controller.

============================================================================

The UART header file should be included in an application as follows:

Refer to UART.h for a complete description of APIs & example of use.

Stack requirements

The UARTTiva driver is (ring) buffered driver where it stores data it may already received in a user-supplied background buffer.

See also
UARTTiva_HWAttrs

While permitted, it is STRONGLY suggested to avoid implementations where you call UART_read() within it own callback function (when in UART_MODE_CALLBACK).

Doing so, will require additional (task and system) stack for each nested UART_read() call.

Tool chain Number of bytes per nested UART_read() call
GNU 152 bytes + callback function stack requirements
IAR 56 bytes + callback function stack requirements
TI 120 bytes + callback function stack requirements

It is important to note a potential worst case scenario: A full ring buffer with data; say 32 bytes The callback function calls UART_read() with a size of 1 (byte) No other variables are allocated in the callback function No other function calls are made in the callback function

As a result, you need an additional task and system stack of: 32 bytes * (120 bytes for TI + 0 bytes by the callback function) = 3.75kB


#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/utils/RingBuf.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
Include dependency graph for UARTTiva.h:

Go to the source code of this file.

Data Structures

struct  UARTTiva_FxnSet
 Complement set of read functions to be used by the UART ISR and UARTTiva_read(). Internal use only. More...
 
struct  UARTTiva_HWAttrs
 UARTTiva Hardware attributes. More...
 
struct  UARTTiva_Object
 UARTTiva Object. More...
 

Macros

#define ti_sysbios_family_arm_m3_Hwi__nolocalnames
 

Typedefs

typedef struct UARTTiva_FxnSet UARTTiva_FxnSet
 Complement set of read functions to be used by the UART ISR and UARTTiva_read(). Internal use only. More...
 
typedef struct UARTTiva_HWAttrs UARTTiva_HWAttrs
 UARTTiva Hardware attributes. More...
 
typedef struct UARTTiva_Object UARTTiva_Object
 UARTTiva Object. More...
 
typedef struct UARTTiva_ObjectUARTTiva_Handle
 

Variables

const UART_FxnTable UARTTiva_fxnTable
 

Macro Definition Documentation

#define ti_sysbios_family_arm_m3_Hwi__nolocalnames

Typedef Documentation

Complement set of read functions to be used by the UART ISR and UARTTiva_read(). Internal use only.

These functions should not be used by the user and are solely intended for the UARTTiva driver. The UARTTiva_FxnSet is a pair of complement functions that are design to operate with one another in a task context and in an ISR context. The readTaskFxn is called by UARTTiva_read() to drain a circular buffer, whereas the readIsrFxn is used by the UARTTiva_hwiIntFxn to fill up the circular buffer.

readTaskFxn: Function called by UART read These variables are set and avilalable for use to the readTaskFxn. object->readBuf = buffer; //Pointer to a user buffer object->readSize = size; //Desired no. of bytes to read object->readCount = size; //Remaining no. of bytes to read

readIsrFxn: The required ISR counterpart to readTaskFxn

UARTTiva Hardware attributes.

The baseAddr, intNum, and flowControl fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For TivaWare these definitions are found in:

  • inc/hw_memmap.h
  • inc/hw_ints.h
  • driverlib/uart.h

intPriority is the UART peripheral's interrupt priority, as defined by the underlying OS. It is passed unmodified to the underlying OS's interrupt handler creation code, so you need to refer to the OS documentation for usage. For example, for SYS/BIOS applications, refer to the ti.sysbios.family.arm.m3.Hwi documentation for SYS/BIOS usage of interrupt priorities. If the driver uses the ti.drivers.ports interface instead of making OS calls directly, then the HwiP port handles the interrupt priority in an OS specific way. In the case of the SYS/BIOS port, intPriority is passed unmodified to Hwi_create().

A sample structure is shown below:

1 unsigned char uartTivaRingBuffer[2][32];
2 
3 const UARTTiva_HWAttrs uartTivaHWAttrs[] = {
4  {
5  .baseAddr = UART0_BASE,
6  .intNum = INT_UART0,
7  .intPriority = (~0),
8  .flowControl = UART_FLOWCONTROL_NONE,
9  .ringBufPtr = uartTivaRingBuffer[0],
10  .ringBufSize = sizeof(uartTivaRingBuffer[0])
11  },
12  {
13  .baseAddr = UART1_BASE,
14  .intNum = INT_UART1,
15  .intPriority = (~0),
16  .flowControl = UART_FLOWCONTROL_NONE,
17  .ringBufPtr = uartTivaRingBuffer[1],
18  .ringBufSize = sizeof(uartTivaRingBuffer[1])
19  }
20 };

UARTTiva Object.

The application must not access any member variables of this structure!

typedef struct UARTTiva_Object * UARTTiva_Handle

Variable Documentation

const UART_FxnTable UARTTiva_fxnTable
Copyright 2016, Texas Instruments Incorporated