![]() |
![]() |
MSP430™CapTIvateSoftwareLibraryAPIGuide
1_83_00_05
|
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 tUARTPort * | g_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... | |
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.
This is the UART port driver definitions file. This file sets the configuration parameters for the UART port.
#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.
#define UART__EUSCI_IV (UCA0IV) |
Referenced by UART_ISR().
#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().
#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().
#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().
#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.
#define UART__PRESCALER (0x08) |
#define UART__FIRST_STAGE_MOD (0x00) |
#define UART__SECOND_STAGE_MOD (0x00) |
enum tUARTStates |
enum tUARTErrors |
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.
pPort | is 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. |
References eUARTIsIdle, g_UARTStatus, tUARTPort::peripheralParameters, UART__EUSCI_A_PERIPHERAL, and UART_closePort().
void UART_closePort | ( | void | ) |
This API closes the UART port on the specified HW eUSCI_A peripheral.
References eUARTIsClosed, g_UARTStatus, and UART__EUSCI_A_PERIPHERAL.
Referenced by UART_openPort().
uint8_t UART_getPortStatus | ( | void | ) |
This API returns the status of the UART port when called. The possible statuses are enumerated under tUARTStates.
References g_UARTStatus.
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.
pBuffer | is a pointer to the buffer to transmit |
ui16Length | indicates the valid byte length of the buffer to transmit |
References eUARTIsClosed, eUARTIsIdle, eUARTIsTransmitting, g_pUARTTransmitPtr, g_UARTStatus, g_ui16UARTTransmitBytesLeft, UART__EUSCI_A_PERIPHERAL, and UART__LPMx_bits.
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.
ui8Data | is the single byte of data to send |
References UART__EUSCI_A_PERIPHERAL.
__interrupt void UART_ISR | ( | void | ) |
UART Interrupt Service Routine.
References eUARTIsIdle, g_pUARTTransmitPtr, g_UARTStatus, g_ui16UARTTransmitBytesLeft, tUARTPort::pbErrorCallback, tUARTPort::pbReceiveCallback, UART__ERROR_MASK, UART__EUSCI_A_PERIPHERAL, UART__EUSCI_IV, and UART__LPMx_bits.
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.
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().
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().
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().