MSP430™CapTIvateSoftwareLibraryAPIGuide  1_83_00_05
Data Structures | Macros | Enumerations | Functions | Variables
UART

UART driver module for the eUSCI_A UART peripheral. More...

Data Structures

struct  tUARTPort
 

Macros

#define UART__EUSCI_VECTOR   (USCI_A0_VECTOR)
 
#define UART__EUSCI_IV   (UCA0IV)
 
#define UART__ERROR_MASK   (0x60)
 
#define UART__EUSCI_A_PERIPHERAL   (EUSCI_A0_BASE)
 CAPT_CommConfig is used to control UART__ENABLE. More...
 
#define UART__LPMx_bits   (LPM0_bits)
 
#define UART__SAMPLING_MODE   (EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION)
 def UART__SAMPLING_MODE defines the eUSCI_A LF or HF mode. More...
 
#define UART__PRESCALER   (0x08)
 
#define UART__FIRST_STAGE_MOD   (0x00)
 
#define UART__SECOND_STAGE_MOD   (0x00)
 

Enumerations

enum  tUARTStates { eUARTIsClosed, eUARTIsIdle, eUARTIsTransmitting }
 enumerates the possible UART driver states. More...
 
enum  tUARTErrors { eUARTFramingError = 0x40, eUARTOverrunError = 0x20 }
 

Functions

void UART_openPort (const tUARTPort *pPort)
 
void UART_closePort (void)
 This API closes the UART port on the specified HW eUSCI_A peripheral. More...
 
uint8_t UART_getPortStatus (void)
 
void UART_transmitBuffer (const uint8_t *pBuffer, uint16_t ui16Length)
 
void UART_transmitByteImmediately (uint8_t ui8Data)
 
__interrupt void UART_ISR (void)
 UART Interrupt Service Routine. More...
 

Variables

const tUARTPortg_pUARTPort
 
volatile const uint8_t * g_pUARTTransmitPtr
 var g_pUARTTransmitPtr stores a pointer to the current byte to transmit. More...
 
volatile uint16_t g_ui16UARTTransmitBytesLeft
 
volatile uint8_t g_UARTStatus
 var g_UARTStatus stores the current status of the UART port driver. More...
 

Detailed Description

UART driver module for the eUSCI_A UART peripheral.

This is the UART port driver header file. This driver enables interrupt driven, full-duplex UART communication via a simple API. The UART port driver requires one eUSCI_A instance, and is built on top of the MSP430 DriverLib version 2.10.00.00 or greater.

Version
VERSION Released on RELEASE_DATE

This is the UART port driver definitions file. This file sets the configuration parameters for the UART port.

Author
MSP Microcontroller Products
Version
VERSION Released on RELEASE_DATE

Macro Definition Documentation

§ UART__EUSCI_VECTOR

#define UART__EUSCI_VECTOR   (USCI_A0_VECTOR)

def UART__EUSCI_VECTOR defines the interrupt vector location of the selected eUSCI_A UART peripheral. def UART__EUSCI_IV defines the interrupt vector of the selected eUSCI_A UART peripheral.

§ UART__EUSCI_IV

#define UART__EUSCI_IV   (UCA0IV)

Referenced by UART_ISR().

§ UART__ERROR_MASK

#define UART__ERROR_MASK   (0x60)

def UART__ERROR_MASK defines the error bits from the eUSCI_A peripheral that cause an error callback to occur. The errors communicated are UCOE and UCFE for overrun errors and framing errors, respectivly.

Referenced by UART_ISR().

§ UART__EUSCI_A_PERIPHERAL

#define UART__EUSCI_A_PERIPHERAL   (EUSCI_A0_BASE)

CAPT_CommConfig is used to control UART__ENABLE.

def UART__ENABLE controls whether the UART port is included during build. To use the UART port, set this definition to true. def UART__EUSCI_A_PERIPHERAL defines the MSP430 base address of the eUSCI_A instance being used with this UART port.

Referenced by UART_closePort(), UART_ISR(), UART_openPort(), UART_transmitBuffer(), and UART_transmitByteImmediately().

§ UART__LPMx_bits

#define UART__LPMx_bits   (LPM0_bits)

def I2CSLAVE__LPMx_bits defines the low power mode to enter when pending on a resource.

Referenced by UART_ISR(), and UART_transmitBuffer().

§ UART__SAMPLING_MODE

#define UART__SAMPLING_MODE   (EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION)

def UART__SAMPLING_MODE defines the eUSCI_A LF or HF mode.

def UART__PRESCALER defines the eUSCI_A pre-scaler. def UART__FIRST_STAGE_MOD defines the eUSCI_A first stage modulation. def UART__SECOND_STAGE_MOD defines the eUSCI_A second stage modulation.

§ UART__PRESCALER

#define UART__PRESCALER   (0x08)

§ UART__FIRST_STAGE_MOD

#define UART__FIRST_STAGE_MOD   (0x00)

§ UART__SECOND_STAGE_MOD

#define UART__SECOND_STAGE_MOD   (0x00)

Enumeration Type Documentation

§ tUARTStates

enumerates the possible UART driver states.

Enumerator
eUARTIsClosed 
eUARTIsIdle 
eUARTIsTransmitting 

§ tUARTErrors

enumerates the possible UART driver errors. These error codes are passed to the error callback function.

Enumerator
eUARTFramingError 
eUARTOverrunError 

Function Documentation

§ UART_openPort()

void UART_openPort ( const tUARTPort pPort)

This API opens the UART port on the specified HW eUSCI_A peripheral. This API must be called before the port is used.

Parameters
pPortis a pointer to the UART Port configuration structure. The user must populate and provide this structure to the port driver. The data structure must remain at the same address throughout the operation of the driver.
Returns
none

References eUARTIsIdle, g_UARTStatus, tUARTPort::peripheralParameters, UART__EUSCI_A_PERIPHERAL, and UART_closePort().

§ UART_closePort()

void UART_closePort ( void  )

This API closes the UART port on the specified HW eUSCI_A peripheral.

Parameters
none
Returns
none

References eUARTIsClosed, g_UARTStatus, and UART__EUSCI_A_PERIPHERAL.

Referenced by UART_openPort().

§ UART_getPortStatus()

uint8_t UART_getPortStatus ( void  )

This API returns the status of the UART port when called. The possible statuses are enumerated under tUARTStates.

Parameters
none
Returns
tUARTStates enumeration indicating the current status.

References g_UARTStatus.

§ UART_transmitBuffer()

void UART_transmitBuffer ( const uint8_t *  pBuffer,
uint16_t  ui16Length 
)

This API begins transmission of the buffer pointed to as soon as the UART hardware resources are available. If a previous transmission is still in progress, this function will block until it is complete. The blocking may take place in a low power mode if desired by configuring UART__LPMx_bits in the UART_Definitions.h header file.

Parameters
pBufferis a pointer to the buffer to transmit
ui16Lengthindicates the valid byte length of the buffer to transmit
Returns
none

References eUARTIsClosed, eUARTIsIdle, eUARTIsTransmitting, g_pUARTTransmitPtr, g_UARTStatus, g_ui16UARTTransmitBytesLeft, UART__EUSCI_A_PERIPHERAL, and UART__LPMx_bits.

§ UART_transmitByteImmediately()

void UART_transmitByteImmediately ( uint8_t  ui8Data)

This function transmits a single byte of data as soon as the UART peripheral is available. It blocks until this time. This function is useful for terminal emulators where keystrokes should be echoed.

Parameters
ui8Datais the single byte of data to send
Returns
none

References UART__EUSCI_A_PERIPHERAL.

§ UART_ISR()

__interrupt void UART_ISR ( void  )

Variable Documentation

§ g_pUARTPort

const tUARTPort* g_pUARTPort

var g_pUARTPort stores a pointer to the UART port configuration structure that was passed to the UART_openPort function. The UART driver does not modify this structure.

§ g_pUARTTransmitPtr

volatile const uint8_t* g_pUARTTransmitPtr

var g_pUARTTransmitPtr stores a pointer to the current byte to transmit.

Referenced by UART_ISR(), and UART_transmitBuffer().

§ g_ui16UARTTransmitBytesLeft

volatile uint16_t g_ui16UARTTransmitBytesLeft

var g_ui16UARTTransmitBytesLeft stores how many bytes remain to be sent in the current transmission.

Referenced by UART_ISR(), and UART_transmitBuffer().

§ g_UARTStatus

volatile uint8_t g_UARTStatus

var g_UARTStatus stores the current status of the UART port driver.

Referenced by UART_closePort(), UART_getPortStatus(), UART_ISR(), UART_openPort(), and UART_transmitBuffer().

© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale