Functions
euart.c File Reference
#include "inc/hw_types.h"
#include "driverlib/5xx_6xx/debug.h"
#include "driverlib/5xx_6xx/euart.h"
#include "driverlib/5xx_6xx/euart_baudrate.h"
#include "deprecated/CCS/msp430xgeneric.h"

Functions

unsigned short eUART_init (unsigned int baseAddress, unsigned char selectClockSource, unsigned long clockSourceFrequency, unsigned long desiredUartBaudRate, unsigned char parity, unsigned char msborLsbFirst, unsigned char numberofStopBits, unsigned char uartMode, unsigned short overSampling)
unsigned short eUART_initAdvance (unsigned int baseAddress, unsigned char selectClockSource, unsigned int clockPrescalar, unsigned char firstModReg, unsigned char secondModReg, unsigned char parity, unsigned char msborLsbFirst, unsigned char numberofStopBits, unsigned char uartMode, unsigned short overSampling)
void eUART_transmitData (unsigned int baseAddress, unsigned char transmitData)
unsigned char eUART_receiveData (unsigned int baseAddress)
void eUART_enableInterrupt (unsigned int baseAddress, unsigned char mask)
void eUART_disableInterrupt (unsigned int baseAddress, unsigned char mask)
unsigned char eUART_getInterruptStatus (unsigned int baseAddress, unsigned char mask)
void eUART_clearInterruptFlag (unsigned int baseAddress, unsigned char mask)
void eUART_enable (unsigned int baseAddress)
void eUART_disable (unsigned int baseAddress)
unsigned char eUART_queryStatusFlags (unsigned int baseAddress, unsigned char mask)
void eUART_setDormant (unsigned int baseAddress)
void eUART_resetDormant (unsigned int baseAddress)
void eUART_transmitAddress (unsigned int baseAddress, unsigned char transmitAddress)
void eUART_transmitBreak (unsigned int baseAddress)
unsigned long eUART_getReceiveBufferAddressForDMA (unsigned int baseAddress)
unsigned long eUART_getTransmitBufferAddressForDMA (unsigned int baseAddress)
void eUART_selectDeglitchTime (unsigned int baseAddress, unsigned long deglitchTime)

Function Documentation

unsigned short eUART_init ( unsigned int  baseAddress,
unsigned char  selectClockSource,
unsigned long  clockSourceFrequency,
unsigned long  desiredUartBaudRate,
unsigned char  parity,
unsigned char  msborLsbFirst,
unsigned char  numberofStopBits,
unsigned char  uartMode,
unsigned short  overSampling 
)

Initializes the UART block.

Parameters:
baseAddressis the base address of the UART module.
selectClockSourceselects Clock source. Valid values are eUART_CLOCKSOURCE_SMCLK eUART_CLOCKSOURCE_ACLK
clockSourceFrequencyis the frequency of the slected clock source
desiredUartClockis the desired clock rate for UART communication
parityis the desired parity. Valid values are eUART_NO_PARITY [Default Value], eUART_ODD_PARITY, eUART_EVEN_PARITY
msborLsbFirstcontrols direction of receive and transmit shift register. Valid values are eUART_MSB_FIRST eUART_LSB_FIRST [Default Value]
numberofStopBitsindicates one/two STOP bits Valid values are eUART_ONE_STOP_BIT [Default Value] eUART_TWO_STOP_BITS
uartModeselects the mode of operation Valid values are eUART_MODE [Default Value], eUART_IDLE_LINE_MULTI_PROCESSOR_MODE, eUART_ADDRESS_BIT_MULTI_PROCESSOR_MODE, eUART_AUTOMATIC_BAUDRATE_DETECTION_MODE
overSamplingindicates low frequency or oversampling baud generation Valid values are eUART_OVERSAMPLING_BAUDRATE_GENERATION eUART_LOW_FREQUENCY_BAUDRATE_GENERATION

Upon successful initialization of the UART block, this function will have initialized the module, but the UART block still remains disabled and must be enabled with eUART_enable()

Modified bits are UCPEN, UCPAR, UCMSB, UC7BIT, UCSPB, UCMODEx, UCSYNC bits of UCAxCTL0 and UCSSELx, UCSWRST bits of UCAxCTL1

Returns:
STATUS_SUCCESS or STATUS_FAIL of the initialization process

References ASSERT, eUART_ADDRESS_BIT_MULTI_PROCESSOR_MODE, eUART_AUTOMATIC_BAUDRATE_DETECTION_MODE, eUART_CLOCKSOURCE_ACLK, eUART_CLOCKSOURCE_SMCLK, eUART_EVEN_PARITY, eUART_IDLE_LINE_MULTI_PROCESSOR_MODE, eUART_LSB_FIRST, eUART_MODE, eUART_MSB_FIRST, eUART_NO_PARITY, eUART_ODD_PARITY, eUART_ONE_STOP_BIT, eUART_TWO_STOP_BITS, eUARTBAUDRATE_calculateBaudDividers(), HWREG, STATUS_FAIL, and STATUS_SUCCESS.

unsigned short eUART_initAdvance ( unsigned int  baseAddress,
unsigned char  selectClockSource,
unsigned int  clockPrescalar,
unsigned char  firstModReg,
unsigned char  secondModReg,
unsigned char  parity,
unsigned char  msborLsbFirst,
unsigned char  numberofStopBits,
unsigned char  uartMode,
unsigned short  overSampling 
)

Advanced initialization routine for the UART block. The values to be written into the UCAxBRW and UCAxMCTLW registers should be pre-computed and passed into the initialization function

Parameters:
baseAddressis the base address of the UART module.
selectClockSourceselects Clock source. Valid values are eUART_CLOCKSOURCE_SMCLK eUART_CLOCKSOURCE_ACLK
clockPrescalaris the value to be written into UCBRx bits
firstModRegis First modulation stage register setting. This value is a pre-calculated value which can be obtained from the Device Userís Guide.This value is written into UCBRFx bits of UCAxMCTLW.
secondModRegis Second modulation stage register setting. This value is a pre-calculated value which can be obtained from the Device Userís Guide. This value is written into UCBRSx bits of UCAxMCTLW.
parityis the desired parity. Valid values are eUART_NO_PARITY [Default Value], eUART_ODD_PARITY, eUART_EVEN_PARITY
msborLsbFirstcontrols direction of receive and transmit shift register. Valid values are eUART_MSB_FIRST eUART_LSB_FIRST [Default Value]
numberofStopBitsindicates one/two STOP bits Valid values are eUART_ONE_STOP_BIT [Default Value] eUART_TWO_STOP_BITS
uartModeselects the mode of operation Valid values are eUART_MODE [Default Value], eUART_IDLE_LINE_MULTI_PROCESSOR_MODE, eUART_ADDRESS_BIT_MULTI_PROCESSOR_MODE, eUART_AUTOMATIC_BAUDRATE_DETECTION_MODE
overSamplingindicates low frequency or oversampling baud generation Valid values are eUART_OVERSAMPLING_BAUDRATE_GENERATION eUART_LOW_FREQUENCY_BAUDRATE_GENERATION

Upon successful initialization of the UART block, this function will have initialized the module, but the UART block still remains disabled and must be enabled with eUART_enable()

Modified bits are UCPEN, UCPAR, UCMSB, UC7BIT, UCSPB, UCMODEx, UCSYNC bits of UCAxCTL0 and UCSSELx, UCSWRST bits of UCAxCTL1

Returns:
STATUS_SUCCESS or STATUS_FAIL of the initialization process

References ASSERT, eUART_ADDRESS_BIT_MULTI_PROCESSOR_MODE, eUART_AUTOMATIC_BAUDRATE_DETECTION_MODE, eUART_CLOCKSOURCE_ACLK, eUART_CLOCKSOURCE_SMCLK, eUART_EVEN_PARITY, eUART_IDLE_LINE_MULTI_PROCESSOR_MODE, eUART_LSB_FIRST, eUART_MODE, eUART_MSB_FIRST, eUART_NO_PARITY, eUART_ODD_PARITY, eUART_ONE_STOP_BIT, eUART_TWO_STOP_BITS, HWREG, and STATUS_SUCCESS.

void eUART_transmitData ( unsigned int  baseAddress,
unsigned char  transmitData 
)

Transmits a byte from the UART Module.

Parameters:
baseAddressis the base address of the UART module.
transmitDatadata to be transmitted from the UART module

This function will place the supplied data into UART trasmit data register to start transmission

Modified register is UCAxTXBUF

Returns:
None.

References HWREG.

unsigned char eUART_receiveData ( unsigned int  baseAddress)

Receives a byte that has been sent to the UART Module.

Parameters:
baseAddressis the base address of the UART module.

This function reads a byte of data from the UART receive data Register.

Modified register is UCAxRXBUF

Returns:
Returns the byte received from by the UART module, cast as an unsigned char.

References HWREG.

void eUART_enableInterrupt ( unsigned int  baseAddress,
unsigned char  mask 
)

Enables individual UART interrupt sources.

Parameters:
baseAddressis the base address of the UART module.
maskis the bit mask of the interrupt sources to be enabled.

Enables the indicated UART interrupt sources. The interrupt flag is first and then the corresponfing interrupt is enabled. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The mask parameter is the logical OR of any of the following:

  • eUART_RECEIVE_INTERRUPT -Receive interrupt
  • eUART_TRANSMIT_INTERRUPT - Transmit interrupt
  • eUART_RECEIVE_ERRONEOUSCHAR_INTERRUPT - Receive erroneous-character interrupt enable
  • eUART_BREAKCHAR_INTERRUPT - Receive break character interrupt enable

Modified register is UCAxIFG, UCAxIE and UCAxCTL1

Returns:
None.

References ASSERT, eUART_BREAKCHAR_INTERRUPT, eUART_RECEIVE_ERRONEOUSCHAR_INTERRUPT, eUART_RECEIVE_INTERRUPT, eUART_TRANSMIT_INTERRUPT, and HWREG.

void eUART_disableInterrupt ( unsigned int  baseAddress,
unsigned char  mask 
)

Disables individual UART interrupt sources.

Parameters:
baseAddressis the base address of the UART module.
maskis the bit mask of the interrupt sources to be disabled.

Disables the indicated UART interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The mask parameter is the logical OR of any of the following:

  • eUART_RECEIVE_INTERRUPT -Receive interrupt
  • eUART_TRANSMIT_INTERRUPT - Transmit interrupt
  • eUART_RECEIVE_ERRONEOUSCHAR_INTERRUPT - Receive erroneous-character interrupt enable
  • eUART_BREAKCHAR_INTERRUPT - Receive break character interrupt enable

Modified register is UCAxIFG, UCAxIE and UCAxCTL1

Returns:
None.

References ASSERT, eUART_BREAKCHAR_INTERRUPT, eUART_RECEIVE_ERRONEOUSCHAR_INTERRUPT, eUART_RECEIVE_INTERRUPT, eUART_TRANSMIT_INTERRUPT, and HWREG.

unsigned char eUART_getInterruptStatus ( unsigned int  baseAddress,
unsigned char  mask 
)

Gets the current UART interrupt status.

Parameters:
baseAddressis the base address of the UART module.
maskis the masked interrupt flag status to be returned.

This returns the interrupt status for the UART module based on which flag is passed. mask parameter can be either any of the following selection.

  • eUART_RECEIVE_INTERRUPT_FLAG -Receive interrupt flag
  • eUART_TRANSMIT_INTERRUPT_FLAG - Transmit interrupt flag

Modified register is UCAxIFG.

Returns:
The current interrupt status, returned as with the respective bits set if the corresponding interrupt flag is set

References ASSERT, eUART_RECEIVE_INTERRUPT_FLAG, eUART_TRANSMIT_INTERRUPT_FLAG, and HWREG.

Referenced by eUART_transmitBreak().

void eUART_clearInterruptFlag ( unsigned int  baseAddress,
unsigned char  mask 
)

Clears UART interrupt sources.

Parameters:
baseAddressis the base address of the UART module.
maskis a bit mask of the interrupt sources to be cleared.

The UART interrupt source is cleared, so that it no longer asserts. The highest interrupt flag is automatically cleared when an interrupt vector generator is used.

The mask parameter has the same definition as the mask parameter to eUART_enableInterrupt().

Modified register is UCAxIFG

Returns:
None.

References HWREG.

void eUART_enable ( unsigned int  baseAddress)

Enables the UART block.

Parameters:
baseAddressis the base address of the USCI UART module.

This will enable operation of the UART block.

Modified register is UCAxCTL1

Returns:
None.

References HWREG.

void eUART_disable ( unsigned int  baseAddress)

Disables the UART block.

Parameters:
baseAddressis the base address of the USCI UART module.

This will disable operation of the UART block.

Modified register is UCAxCTL1

Returns:
None.

References HWREG.

unsigned char eUART_queryStatusFlags ( unsigned int  baseAddress,
unsigned char  mask 
)

Gets the current UART status flags.

Parameters:
baseAddressis the base address of the UART module.
maskis the masked interrupt flag status to be returned.

This returns the status for the UART module based on which flag is passed. mask parameter can be either any of the following selection.

  • eUART_LISTEN_ENABLE
  • eUART_FRAMING_ERROR
  • eUART_OVERRUN_ERROR
  • eUART_PARITY_ERROR
  • UARTBREAK_DETECT
  • eUART_RECEIVE_ERROR
  • eUART_ADDRESS_RECEIVED
  • eUART_IDLELINE
  • eUART_BUSY

Modified register is UCAxSTAT

Returns:
the masked status flag

References ASSERT, eUART_ADDRESS_RECEIVED, eUART_BUSY, eUART_FRAMING_ERROR, eUART_IDLELINE, eUART_LISTEN_ENABLE, eUART_OVERRUN_ERROR, eUART_PARITY_ERROR, eUART_RECEIVE_ERROR, HWREG, and UARTBREAK_DETECT.

void eUART_setDormant ( unsigned int  baseAddress)

Sets the UART module in dormant mode

Parameters:
baseAddressis the base address of the UART module.

Puts USCI in sleep mode Only characters that are preceded by an idle-line or with address bit set UCRXIFG. In UART mode with automatic baud-rate detection, only the combination of a break and synch field sets UCRXIFG.

Modified register is UCAxCTL1

Returns:
None.

References HWREG.

void eUART_resetDormant ( unsigned int  baseAddress)

Re-enables UART module from dormant mode

Parameters:
baseAddressis the base address of the UART module.

Not dormant. All received characters set UCRXIFG.

Modified bits are UCDORM of UCAxCTL1 register.

Returns:
None.

References HWREG.

void eUART_transmitAddress ( unsigned int  baseAddress,
unsigned char  transmitAddress 
)

Transmits the next byte to be transmitted marked as address depending on selected multiprocessor mode

Parameters:
baseAddressis the base address of the UART module.
transmitAddressis the next byte to be transmitted

Modified register is UCAxCTL1, UCAxTXBUF

Returns:
None.

References HWREG.

void eUART_transmitBreak ( unsigned int  baseAddress)

Transmit break. Transmits a break with the next write to the transmit buffer. In UART mode with automatic baud-rate detection, eUART_AUTOMATICBAUDRATE_SYNC(0x55) must be written into UCAxTXBUF to generate the required break/synch fields. Otherwise, DEFAULT_SYNC(0x00) must be written into the transmit buffer. Also ensures module is ready for transmitting the next data

Parameters:
baseAddressis the base address of the UART module.

Modified register is UCAxCTL1, UCAxTXBUF

Returns:
None.

References DEFAULT_SYNC, eUART_AUTOMATIC_BAUDRATE_DETECTION_MODE, eUART_AUTOMATICBAUDRATE_SYNC, eUART_getInterruptStatus(), and HWREG.

unsigned long eUART_getReceiveBufferAddressForDMA ( unsigned int  baseAddress)

Returns the address of the RX Buffer of the UART for the DMA module.

Parameters:
baseAddressis the base address of the UART module.

Returns the address of the UART RX Buffer. This can be used in conjunction with the DMA to store the received data directly to memory.

Returns:
None
unsigned long eUART_getTransmitBufferAddressForDMA ( unsigned int  baseAddress)

Returns the address of the TX Buffer of the UART for the DMA module.

Parameters:
baseAddressis the base address of the UART module.

Returns the address of the UART TX Buffer. This can be used in conjunction with the DMA to obtain transmitted data directly from memory.

Returns:
None
void eUART_selectDeglitchTime ( unsigned int  baseAddress,
unsigned long  deglitchTime 
)

Sets the deglitch time

Parameters:
baseAddressis the base address of the UART module.
deglitchTimeis the selected deglitch time Valid values are
  • eUART_DEGLITCH_TIME_2ns
  • eUART_DEGLITCH_TIME_50ns
  • eUART_DEGLITCH_TIME_100ns
  • eUART_DEGLITCH_TIME_200ns

Returns the address of the UART TX Buffer. This can be used in conjunction with the DMA to obtain transmitted data directly from memory.

Returns:
None

References ASSERT, eUART_DEGLITCH_TIME_100ns, eUART_DEGLITCH_TIME_200ns, eUART_DEGLITCH_TIME_2ns, eUART_DEGLITCH_TIME_50ns, and HWREG.


Copyright 2012, Texas Instruments Incorporated