UART Module¶
The UART driver provides functions which can configure the data word length, baud rate, parity, and stop bits of the UART communication. It can also be used to enable or disable loopback mode, enable the FIFO enhancement, configure interrupts, and send and receive data. If FIFO enhancement is enabled, we must use the provided FIFO functions to configure and guarantee proper execution.
-
group
uart_api The UART module is used for UART configurations.
Defines
-
UART_INT_DMATX0x20000U¶ DMA TX interrupt.
-
UART_INT_DMARX0x10000U¶ DMA RX interrupt.
-
UART_INT_9BIT0x1000U¶ 9-bit address match interrupt
-
UART_INT_EOT0x800U¶ Receive Interrupt Mask.
-
UART_INT_OE0x400U¶ Overrun Error Interrupt Mask.
-
UART_INT_BE0x200U¶ Break Error Interrupt Mask.
-
UART_INT_PE0x100U¶ Parity Error Interrupt Mask.
-
UART_INT_FE0x080U¶ Framing Error Interrupt Mask.
-
UART_INT_RT0x040U¶ Receive Timeout Interrupt Mask.
-
UART_INT_TX0x020U¶ Transmit Interrupt Mask.
-
UART_INT_RX0x010U¶ Receive Interrupt Mask.
-
UART_CONFIG_WLEN_MASK0x00000060UL¶ Mask for extracting wordlength.
-
UART_CONFIG_WLEN_80x00000060UL¶ 8 bit data
-
UART_CONFIG_WLEN_70x00000040UL¶ 7 bit data
-
UART_CONFIG_WLEN_60x00000020UL¶ 6 bit data
-
UART_CONFIG_WLEN_50x00000000UL¶ 5 bit data
-
UART_CONFIG_STOP_MASK0x00000008UL¶ Mask for extracting stop bits.
-
UART_CONFIG_STOP_ONE0x00000000UL¶ One stop bit.
-
UART_CONFIG_STOP_TWO0x00000008UL¶ Two stop bits.
-
UART_CONFIG_PAR_MASK0x00000086UL¶ Mask for extracting parity.
-
UART_CONFIG_PAR_NONE0x00000000UL¶ No parity.
-
UART_CONFIG_PAR_EVEN0x00000006UL¶ Even parity.
-
UART_CONFIG_PAR_ODD0x00000002UL¶ Odd parity.
-
UART_CONFIG_PAR_ONE0x00000082UL¶ Parity bit is one.
-
UART_CONFIG_PAR_ZERO0x00000086UL¶ Parity bit is zero.
-
UART_DMA_ERR_RXSTOP0x00000004UL¶ Stop DMA receive if UART error.
-
UART_DMA_TX0x00000002UL¶ Enable DMA for transmit.
-
UART_DMA_RX0x00000001UL¶ Enable DMA for receive.
-
UART_RXERROR_OVERRUN0x00000008UL¶
-
UART_RXERROR_BREAK0x00000004UL¶
-
UART_RXERROR_PARITY0x00000002UL¶
-
UART_RXERROR_FRAMING0x00000001UL¶
-
UART_TXINT_MODE_FIFO0x00000000UL¶ trigger based on tx FIFOlevel
-
UART_TXINT_MODE_EOT0x00000010UL¶ trigger when transmitter idle
-
UART_CLK_DIVIDER8U¶
-
UART_CLK_FREQDEVICE_SYSCLK_FREQ¶ CPU SYSCLK frequency.
-
UART_RSR_ALL_M(UART_RSR_BE | UART_RSR_FE | UART_RSR_OE | UART_RSR_PE)¶
-
UART_CLK_IRLPBAUD161843200U¶
-
UART_RAW_INTfalse¶ raw interrupt
-
UART_MASKED_INTtrue¶ masked interrupt
-
UART_SIR_LOWPOWER_DISABLEfalse¶ raw interrupt
-
UART_SIR_LOWPOWER_ENABLEtrue¶ masked interrupt
-
UART_FIFO_TX1_80x00000000UL¶ Transmit interrupt at 1/8 Full.
-
UART_FIFO_TX2_80x00000001UL¶ Transmit interrupt at 1/4 Full.
-
UART_FIFO_TX4_80x00000002UL¶ Transmit interrupt at 1/2 Full.
-
UART_FIFO_TX6_80x00000003UL¶ Transmit interrupt at 3/4 Full.
-
UART_FIFO_TX7_80x00000004UL¶ Transmit interrupt at 7/8 Full.
-
UART_FIFO_RX1_80x00000000UL¶ Receive interrupt at 1/8 Full.
-
UART_FIFO_RX2_80x00000008UL¶ Receive interrupt at 1/4 Full.
-
UART_FIFO_RX4_80x00000010UL¶ Receive interrupt at 1/2 Full.
-
UART_FIFO_RX6_80x00000018UL¶ Receive interrupt at 3/4 Full.
-
UART_FIFO_RX7_80x00000020UL¶ Receive interrupt at 7/8 Full.
Functions
-
void
UART_setParityMode(uint32_t base, uint32_t parity)¶ Sets the type of parity.
This function configures the type of parity to use for transmitting and expect when receiving. The
parity parameter must be one of UART_CONFIG_PAR_NONE, UART_CONFIG_PAR_EVEN, UART_CONFIG_PAR_ODD, UART_CONFIG_PAR_ONE, or UART_CONFIG_PAR_ZERO. The last two parameters allow direct control of the parity bit; it is always either one or zero based on the mode.- Parameters
base: is the base address of the UART port.parity: specifies the type of parity to use.
- Return
None.
-
uint32_t
UART_getParityMode(uint32_t base)¶ Gets the type of parity currently being used.
This function gets the type of parity used for transmitting data and expected when receiving data.
- Parameters
base: is the base address of the UART port.
- Return
Returns the current parity settings, specified as one of UART_CONFIG_PAR_NONE, UART_CONFIG_PAR_EVEN, UART_CONFIG_PAR_ODD, UART_CONFIG_PAR_ONE, or UART_CONFIG_PAR_ZERO.
-
void
UART_setFIFOLevel(uint32_t base, uint32_t txLevel, uint32_t rxLevel)¶ Sets the FIFO level at which interrupts are generated.
This function configures the FIFO level at which transmit and receive interrupts are generated.
- Parameters
base: is the base address of the UART port.txLevel: is the transmit FIFO interrupt level, specified as one of UART_FIFO_TX1_8, UART_FIFO_TX2_8, UART_FIFO_TX4_8, UART_FIFO_TX6_8, or UART_FIFO_TX7_8.rxLevel: is the receive FIFO interrupt level, specified as one of UART_FIFO_RX1_8, UART_FIFO_RX2_8, UART_FIFO_RX4_8, UART_FIFO_RX6_8, or UART_FIFO_RX7_8.
- Return
None.
-
void
UART_getFIFOLevel(uint32_t base, uint32_t *txLevel, uint32_t *rxLevel)¶ Gets the FIFO level at which interrupts are generated.
This function gets the FIFO level at which transmit and receive interrupts are generated.
- Parameters
base: is the base address of the UART port.txLevel: is a pointer to storage for the transmit FIFO level, returned as one of UART_FIFO_TX1_8, UART_FIFO_TX2_8, UART_FIFO_TX4_8, UART_FIFO_TX6_8, or UART_FIFO_TX7_8.rxLevel: is a pointer to storage for the receive FIFO level, returned as one of UART_FIFO_RX1_8, UART_FIFO_RX2_8, UART_FIFO_RX4_8, UART_FIFO_RX6_8, or UART_FIFO_RX7_8.
- Return
None.
-
void
UART_enableModule(uint32_t base)¶ Enables transmitting and receiving.
This function enables the UART and its transmit and receive FIFOs.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_disableModule(uint32_t base)¶ Disables transmitting and receiving.
This function disables the UART, waits for the end of transmission of the current character, and flushes the transmit FIFO.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_enableFIFO(uint32_t base)¶ Enables the transmit and receive FIFOs.
This functions enables the transmit and receive FIFOs in the UART.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_disableFIFO(uint32_t base)¶ Disables the transmit and receive FIFOs.
This function disables the transmit and receive FIFOs in the UART.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_enableModuleNonFIFO(uint32_t base)¶ Enables transmitting and receiving without FIFO.
This function enables the UART.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_disableModuleNonFIFO(uint32_t base)¶ Disables transmitting and receiving without FIFO.
This function disables the UART, waits for the end of transmission of the current character.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
bool
UART_isFIFOEnabled(uint32_t base)¶ Determines if the transmit and receive FIFOs are enabled
This function returns a flag indicating whether or not the transmit and receive FIFOs are enabled.
- Parameters
base: is the base address of the UART port.
- Return
Returns true if FIFOs are enabled or false if FIFOs are not enabled.
-
void
UART_enableSIR(uint32_t base, Uart_SirLPMode bLowPower)¶ Enables SIR (IrDA) mode on the specified UART.
This function enables SIR (IrDA) mode on the UART. If the
bLowPower flag is set, then SIR low power mode will be selected as well. This function only has an effect if the UART has not been enabled by a call to UART_enableModule(). The call UART_enableSIR() must be made before a call to UART_setConfig() because the UART_setConfig() function calls the UART_enableModule() function. Another option is to call UART_disableModule() followed by UART_enableSIR() and then enable the UART by calling UART_enableModule().- Parameters
base: is the base address of the UART port.bLowPower: indicates if SIR Low Power Mode is to be used. This parameter is of type UART_SirLPMode.
- Note
The IrDA SIR physical layer specifies a minimum 10-ms delay between transmission and reception which needs to be provided.
- Return
None.
-
void
UART_disableSIR(uint32_t base)¶ Disables SIR (IrDA) mode on the specified UART.
This function disables SIR(IrDA) mode on the UART. This function only has an effect if the UART has not been enabled by a call to
UART_enableModule(). The call UART_enableSIR() must be made before a call to UART_setConfig() because the UART_setConfig() function calls the UART_enableModule() function. Another option is to call UART_disableModule() followed by UART_enableSIR() and then enable the UART by calling UART_enableModule().- Parameters
base: is the base address of the UART port.
- Note
The IrDA SIR physical layer specifies a minimum 10-ms delay between transmission and reception which needs to be provided.
- Return
None.
-
void
UART_setTxIntMode(uint32_t base, uint32_t mode)¶ Sets the operating mode for the UART transmit interrupt.
This function allows the mode of the UART transmit interrupt to be set. By default, the transmit interrupt is asserted when the FIFO level falls past a threshold set via a call to
UART_setFIFOLevel(). Alternatively, if this function is called with mode set to UART_TXINT_MODE_EOT, the transmit interrupt is asserted once the transmitter is completely idle - the transmit FIFO is empty and all bits, including any stop bits, have cleared the transmitter.- Parameters
base: is the base address of the UART port.mode: is the operating mode for the transmit interrupt. It may be UART_TXINT_MODE_EOT to trigger interrupts when the transmitter is idle or UART_TXINT_MODE_FIFO to trigger based on the current transmit FIFO level.
- Return
None.
-
uint32_t
UART_getTxIntMode(uint32_t base)¶ Returns the current operating mode for the UART transmit interrupt.
This function returns the current operating mode for the UART transmit interrupt. The return value is
UART_TXINT_MODE_EOT if the transmit interrupt is currently configured to be asserted once the transmitter is completely idle - the transmit FIFO is empty and all bits, including any stop bits, have cleared the transmitter. The return value is UART_TXINT_MODE_FIFO if the interrupt is configured to be asserted based on the level of the transmit FIFO.- Parameters
base: is the base address of the UART port.
- Return
Returns UART_TXINT_MODE_FIFO or UART_TXINT_MODE_EOT.
-
bool
UART_isDataAvailable(uint32_t base)¶ Determines if there are any characters in the receive FIFO.
This function returns a flag indicating whether or not there is data available in the receive FIFO.
- Parameters
base: is the base address of the UART port.
- Return
Returns true if there is data in the receive FIFO or false if there is no data in the receive FIFO.
-
bool
UART_isSpaceAvailable(uint32_t base)¶ Determines if there is any space in the transmit FIFO.
This function returns a flag indicating whether or not there is space available in the transmit FIFO.
- Parameters
base: is the base address of the UART port.
- Return
Returns true if there is space available in the transmit FIFO or false if there is no space available in the transmit FIFO.
-
int32_t
UART_readCharNonBlocking(uint32_t base)¶ Receives a character from the specified port.
This function gets a character from the receive FIFO for the specified port.
- Parameters
base: is the base address of the UART port.
- Return
Returns the character read from the specified port, cast as a int32_t. A -1 is returned if there are no characters present in the receive FIFO. The UART_isDataAvailable() function should be called before attempting to call this function.
-
int32_t
UART_readChar(uint32_t base)¶ Waits for a character from the specified port.
This function gets a character from the receive FIFO for the specified port. If there are no characters available, this function waits until a character is received before returning.
- Parameters
base: is the base address of the UART port.
- Return
Returns the character read from the specified port, cast as a int32_t.
-
void
UART_writeChar(uint32_t base, uint8_t data)¶ Waits to send a character from the specified port.
This function sends the character
data to the transmit FIFO for the specified port. If there is no space available in the transmit FIFO, this function waits until there is space available before returning.- Parameters
base: is the base address of the UART port.data: is the character to be transmitted.
- Return
None.
-
void
UART_setBreakConfig(uint32_t base, bool breakState)¶ Causes a BREAK to be sent.
Calling this function with
bBreakState set to true asserts a break condition on the UART. Calling this function with bBreakState set to false removes the break condition. For proper transmission of a break command, the break must be asserted for at least two complete frames.- Parameters
base: is the base address of the UART port.breakState: controls the output level.
- Return
None.
-
bool
UART_isBusy(uint32_t base)¶ Determines whether the UART transmitter is busy or not.
This function allows the caller to determine whether all transmitted bytes have cleared the transmitter hardware. If
false is returned, the transmit FIFO is empty and all bits of the last transmitted character, including all stop bits, have left the hardware shift register.- Parameters
base: is the base address of the UART port.
- Return
Returns true if the UART is transmitting or false if all transmissions are complete.
-
void
UART_registerInterrupt(uint32_t interruptNum, void (*pfnHandler)(void))¶ Registers an interrupt handler for a UART interrupt.
This function does the actual registering of the interrupt handler. This function enables the global interrupt in the interrupt controller; specific UART interrupts must be enabled via
UART_enableInterrupt(). It is the interrupt handler’s responsibility to clear the interrupt source.- Parameters
interruptNum: specifies the interrupt in question.pfnHandler: is a pointer to the function to be called when the UART interrupt occurs.
- See
Interrupt_register() for important information about registering interrupt handlers.
- Return
None.
-
void
UART_unregisterInterrupt(uint32_t interruptNum)¶ Unregisters an interrupt handler for a UART interrupt.
This function does the actual unregistering of the interrupt handler. It clears the handler to be called when a UART interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.
- Parameters
interruptNum: specifies the interrupt in question.
- See
Interrupt_unregister() for important information about registering interrupt handlers.
- Return
None.
-
void
UART_clearGlobalInterruptFlag(uint32_t base)¶ Clears UART global interrupt flag.
This function clears the indicated UART global interrupt flag register.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
bool
UART_getGlobalInterruptFlagStatus(uint32_t base)¶ Returns the status of UART global interrupt flag.
This function returns the status of UART global interrupt flag register.
- Parameters
base: is the base address of the UART port.
- Return
Returns the status of UART global interrupt flag register.
-
void
UART_enableInterrupt(uint32_t base, uint32_t intFlags)¶ Enables individual UART interrupt sources.
This function enables 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.
- Parameters
base: is the base address of the UART port.intFlags: is the bit mask of the interrupt sources to be enabled.
The intFlags parameter is the logical OR of any of the following:
UART_INT_DMATX - Transmit DMA interrupt
UART_INT_DMARX - Receive DMA interrupt
UART_INT_9BIT - 9-bit Address Match interrupt
UART_INT_EOT - End of Transmission interrupt
UART_INT_OE - Overrun Error interrupt
UART_INT_BE - Break Error interrupt
UART_INT_PE - Parity Error interrupt
UART_INT_FE - Framing Error interrupt
UART_INT_RT - Receive Timeout interrupt
UART_INT_TX - Transmit interrupt
UART_INT_RX - Receive interrupt
- Return
None.
-
void
UART_disableInterrupt(uint32_t base, uint32_t intFlags)¶ Disables individual UART interrupt sources.
This function 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.
- Parameters
base: is the base address of the UART port.intFlags: is the bit mask of the interrupt sources to be disabled.
The intFlags parameter has the same definition as the intFlags parameter to UART_enableInterrupt().
- Return
None.
-
uint32_t
UART_getInterruptStatus(uint32_t base, Uart_IntType masked)¶ Gets the current interrupt status.
This function returns the interrupt status for the specified UART. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.
- Parameters
base: is the base address of the UART port.masked: of type Uart_IntType is UART_RAW_INT if the raw interrupt status is requested and UART_MASKED_INT if the masked interrupt status is requested.
- Return
Returns the current interrupt status, enumerated as a bit field of values described in UART_enableInterrupt().
-
void
UART_clearInterruptStatus(uint32_t base, uint32_t intFlags)¶ Clears UART interrupt sources.
The specified UART interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.
- Parameters
base: is the base address of the UART port.intFlags: is a bit mask of the interrupt sources to be cleared.
The intFlags parameter has the same definition as the intFlags parameter to UART_enableInterrupt().
- Return
None.
-
void
UART_enableDMA(uint32_t base, uint32_t dmaFlags)¶ Enable UART uDMA operation.
The specified UART uDMA features are enabled. The UART can be configured to use uDMA for transmit or receive and to disable receive if an error occurs. The
dmaFlags parameter is the logical OR of any of the following values:- Parameters
base: is the base address of the UART port.dmaFlags: is a bit mask of the uDMA features to enable.
UART_DMA_RX - enable uDMA for receive
UART_DMA_TX - enable uDMA for transmit
UART_DMA_ERR_RXSTOP - disable uDMA receive on UART error
- Note
The uDMA controller must also be set up before DMA can be used with the UART.
- Return
None.
-
void
UART_disableDMA(uint32_t base, uint32_t dmaFlags)¶ Disable UART uDMA operation.
This function is used to disable UART uDMA features that were enabled by
UART_enableDMA(). The specified UART uDMA features are disabled. The dmaFlags parameter is the logical OR of any of the following values:- Parameters
base: is the base address of the UART port.dmaFlags: is a bit mask of the uDMA features to disable.
UART_DMA_RX - disable uDMA for receive
UART_DMA_TX - disable uDMA for transmit
UART_DMA_ERR_RXSTOP - do not disable uDMA receive on UART error
- Return
None.
-
uint32_t
UART_getRxError(uint32_t base)¶ Gets current receiver errors.
This function returns the current state of each of the 4 receiver error sources. The returned errors are equivalent to the four error bits returned via the previous call to
UART_readChar() or UART_readCharNonBlocking() with the exception that the overrun error is set immediately when the overrun occurs rather than when a character is next read.- Parameters
base: is the base address of the UART port.
- Return
Returns a logical OR combination of the receiver error flags, UART_RXERROR_FRAMING, UART_RXERROR_PARITY, UART_RXERROR_BREAK and UART_RXERROR_OVERRUN.
-
void
UART_clearRxError(uint32_t base)¶ Clears all reported receiver errors.
This function is used to clear all receiver error conditions reported via
UART_getRxError(). If using the overrun, framing error, parity error or break interrupts, this function must be called after clearing the interrupt to ensure that later errors of the same type trigger another interrupt.- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_enable9Bit(uint32_t base)¶ Enables 9-bit mode on the specified UART.
This function enables the 9-bit operational mode of the UART.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_disable9Bit(uint32_t base)¶ Disables 9-bit mode on the specified UART.
This function disables the 9-bit operational mode of the UART.
- Parameters
base: is the base address of the UART port.
- Return
None.
-
void
UART_set9BitAddress(uint32_t base, uint8_t addr, uint8_t mask)¶ Sets the device address(es) for 9-bit mode.
This function configures the device address or range of device addresses that respond to requests on the 9-bit UART port. The received address is masked with the mask and then compared against the given address, allowing either a single address (if
mask is 0xff) or a set of addresses to be matched.- Parameters
base: is the base address of the UART port.addr: is the device address.mask: is the device address mask.
- Return
None.
-
void
UART_setIrDALPDivisor(uint32_t base, uint32_t uartClk)¶ Sets the SIR (IrDA) Low Power Divisor.
This function configures the SIR (IrDA) Low power divisor. This function is used only if the SIR ( IrDA ) is to be used in Low Power mode which is indicated as part of the
UART_enableSIR().- Parameters
base: is the base address of the UART port.uartClk: is the rate of the clock supplied to the UART module. It should be provided as UART_CLK_FREQ using the updated clk rate.
- Return
None.
-
void
UART_enableLoopback(uint32_t base)¶ Enables internal loopback mode for an UART port.
This function configures an UART port in internal loopback mode to help with diagnostics and debug.In this mode, the UART Tx path is fed through the UARTRx path. This allows data to be transferred between the TX and RX of the same UART port, without having to go through I/O’s.UART_writeChar() &
UART_writeCharNonBlocking() can be used along with this function.- Parameters
base: is the base address of the UART module.
- Return
None.
-
void
UART_disableLoopback(uint32_t base)¶ Disables internal loopback mode for an UART port.
This function disables internal loopback mode in an UART port. In this mode, the UARTTx path is not fed through the UARTRx path. This prevents data to be transferred between the TX and RX of the same UART port, without having to go through I/O’s.
- Parameters
base: is the base address of the UART module.
- Return
None.
-
void
UART_send9BitAddress(uint32_t base, uint8_t addr)¶ Sends an address character from the specified port when operating in 9-bit mode.
This function waits until all data has been sent from the specified port and then sends the given address as an address byte. It then waits until the address byte has been transmitted before returning.
- Parameters
base: is the base address of the UART port.addr: is the address to be transmitted.
- Return
None.
-
void
UART_stop9BitDataMode(uint32_t base, uint32_t lcrh)¶ Exits the 9-bit data transmission mode for the specified port.
This function waits until all data has been sent from the specified port and then restores the settings for the normal transmission mode.
- Parameters
base: is the base address of the UART port.lcrh: is the address/data setting needed to restore the normal transmission mode after the full 9-bit data transmission.
- Return
None.
-
uint32_t
UART_configure9BitDataMode(uint32_t base)¶ Configures the specified port to operate in 9-bit data mode.
This function waits until all data has been sent from the specified port and then configures to send 9-bit data.
- Parameters
base: is the base address of the UART port.
- Note
The 9-bit data is sent after the UART_send9BitAddress() is complete. The data transmission is left to the user to handle outside this API. This can be done using UART_writeChar() or UART_writeCharNonBlocking().
- Return
Returns the address/data setting needed to restore the normal transmission mode after the full 9-bit data transmission.
-
void
UART_setConfig(uint32_t base, uint32_t uartClk, uint32_t baud, uint32_t config)¶ Sets the configuration of a UART.
This function configures the UART for operation in the specified data format. The baud rate is provided in the
baud parameter and the data format in the config parameter.- Parameters
base: is the base address of the UART port.uartClk: is the rate of the clock supplied to the UART module. It should be provided as UART_CLK_FREQ using the updated clk ratebaud: is the desired baud rate.config: is the data format for the port (number of data bits, number of stop bits, and parity).
The config parameter is the logical OR of three values: the number of data bits, the number of stop bits, and the parity. UART_CONFIG_WLEN_8, UART_CONFIG_WLEN_7, UART_CONFIG_WLEN_6, and UART_CONFIG_WLEN_5 select from eight to five data bits per byte (respectively). UART_CONFIG_STOP_ONE and UART_CONFIG_STOP_TWO select one or two stop bits (respectively). UART_CONFIG_PAR_NONE UART_CONFIG_PAR_EVEN, UART_CONFIG_PAR_ODD, UART_CONFIG_PAR_ONE, and UART_CONFIG_PAR_ZERO select the parity mode (no parity bit, even parity bit, odd parity bit, parity bit always one, and parity bit always zero, respectively).
- Return
None.
-
void
UART_getConfig(uint32_t base, uint32_t uartClk, uint32_t *baud, uint32_t *config)¶ Gets the current configuration of a UART.
This function determines the baud rate and data format for the UART, given an explicitly provided peripheral clock. The returned baud rate is the actual baud rate; it may not be the exact baud rate requested or an `
official’ baud rate. The data format returned in config is enumerated the same as the config parameter of UART_setConfig().- Parameters
base: is the base address of the UART port.uartClk: is the rate of the clock supplied to the UART module. It should be provided as UART_CLK_FREQ using the updated clk ratebaud: is the desired baud rate.baud: is a pointer to storage for the baud rate.config: is a pointer to storage for the data format.
- Return
None.
-
bool
UART_writeCharNonBlocking(uint32_t base, uint8_t data)¶ Sends a character to the specified port.
This function writes the character
data to the transmit FIFO for the specified port. This function does not block, so if there is no space available, then a false is returned and the application must retry the function later.- Parameters
base: is the base address of the UART port.data: is the character to be transmitted.
- Return
Returns true if the character was successfully placed in the transmit FIFO or false if there was no space available in the transmit FIFO.
-
The code for this module is contained in driverlib/uart.c, with driverlib/uart.h containing the API declarations for use by applications.