| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

Macros | Functions
UART Exported Functions
NUC472/NUC442 Device Driver » UART Driver » UART Exported Constants
Collaboration diagram for UART Exported Functions:

## Macros
#define | UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate)
| Calculate UART baudrate mode0 divider. More...
#define | UART_BAUD_MODE2_DIVIDER(u32SrcFreq, u32BaudRate)
| Calculate UART baudrate mode2 divider. More...
#define | UART_WRITE(uart, u8Data)
| Write Data to Tx data register. More...
#define | UART_READ(uart)
| Read Rx data register. More...
#define | UART_GET_TX_EMPTY(uart)
| Get Tx empty register value. More...
#define | UART_GET_RX_EMPTY(uart)
| Get Rx empty register value. More...
#define | UART_IS_TX_EMPTY(uart)
| Check specified uart port transmission is over. More...
#define | UART_WAIT_TX_EMPTY(uart)
| Wait specified uart port transmission is over. More...
#define | UART_IS_RX_READY(uart)
| Check RDA_IF is set or not. More...
#define | UART_IS_TX_FULL(uart)
| Check TX FIFO is full or not. More...
#define | UART_IS_RX_FULL(uart)
| Check RX FIFO is full or not. More...
#define | UART_GET_TX_FULL(uart)
| Get Tx full register value. More...
#define | UART_GET_RX_FULL(uart)
| Get Rx full register value. More...
#define | UART_ENABLE_INT(uart, u32eIntSel)
| Enable specified interrupt. More...
#define | UART_DISABLE_INT(uart, u32eIntSel)
| Disable specified interrupt. More...
#define | UART_GET_INT_FLAG(uart, u32eIntTypeFlag)
| Get specified interrupt flag/status. More...
#define | UART_RS485_CLEAR_ADDR_FLAG(uart)
| Clear RS-485 Address Byte Detection Flag. More...
#define | UART_RS485_GET_ADDR_FLAG(uart)
| Get RS-485 Address Byte Detection Flag. More...

## Functions
__STATIC_INLINE void | UART_CLEAR_RTS (UART_T *uart)
| Set RTS pin is low. More...
__STATIC_INLINE void | UART_SET_RTS (UART_T *uart)
| Set RTS pin is high. More...
void | UART_ClearIntFlag (UART_T *uart, uint32_t u32InterruptFlag)
| The function is used to clear UART specified interrupt flag. More...
void | UART_Close (UART_T *uart)
| The function is used to disable UART. More...
void | UART_DisableFlowCtrl (UART_T *uart)
| The function is used to disable UART auto flow control. More...
void | UART_DisableInt (UART_T *uart, uint32_t u32InterruptFlag)
| The function is used to disable UART specified interrupt and disable NVIC UART IRQ. More...
void | UART_EnableFlowCtrl (UART_T *uart)
| The function is used to Enable UART auto flow control. More...
void | UART_EnableInt (UART_T *uart, uint32_t u32InterruptFlag)
| The function is used to enable UART specified interrupt and disable NVIC UART IRQ. More...
void | UART_Open (UART_T *uart, uint32_t u32baudrate)
| This function use to enable UART function and set baud-rate. More...
uint32_t | UART_Read (UART_T *uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
| The function is used to read Rx data from RX FIFO and the data will be stored in pu8RxBuf. More...
void | UART_SetLine_Config (UART_T *uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits)
| This function use to config UART line setting. More...
void | UART_SetTimeoutCnt (UART_T *uart, uint32_t u32TOC)
| This function use to set Rx timeout count. More...
void | UART_SelectIrDAMode (UART_T *uart, uint32_t u32Buadrate, uint32_t u32Direction)
| The function is used to configure IrDA relative settings. It consists of TX or RX mode and baudrate. More...
void | UART_SelectRS485Mode (UART_T *uart, uint32_t u32Mode, uint32_t u32Addr)
| The function is used to set RS485 relative setting. More...
uint32_t | UART_Write (UART_T *uart, uint8_t *pu8TxBuf, uint32_t u32WriteBytes)
| The function is to write data into TX buffer to transmit data by UART. More...

## Detailed Description

## Macro Definition Documentation

## ◆ UART_BAUD_MODE0_DIVIDER

#define UART_BAUD_MODE0_DIVIDER | ( |  | u32SrcFreq,
|  |  | u32BaudRate
| ) |  |

Calculate UART baudrate mode0 divider.

Parameters

  [in] | u32SrcFreq | UART clock frequency
  [in] | u32BaudRate | Baudrate of UART module

Returns
  UART baudrate mode0 divider

Definition at line 124 of file uart.h.

## ◆ UART_BAUD_MODE2_DIVIDER

#define UART_BAUD_MODE2_DIVIDER | ( |  | u32SrcFreq,
|  |  | u32BaudRate
| ) |  |

Calculate UART baudrate mode2 divider.

Parameters

  [in] | u32SrcFreq | UART clock frequency
  [in] | u32BaudRate | Baudrate of UART module

Returns
  UART baudrate mode2 divider

Definition at line 135 of file uart.h.

## ◆ UART_DISABLE_INT

#define UART_DISABLE_INT | ( |  | uart,
|  |  | u32eIntSel
| ) |  |

Disable specified interrupt.

Parameters

  [in] | uart | The base address of UART module
  [in] | u32eIntSel | Interrupt type select UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt UART_INTEN_MODEMIEN_Msk : Modem interrupt UART_INTEN_RLSIEN_Msk : Rx Line status interrupt UART_INTEN_THREIEN_Msk : Tx empty interrupt UART_INTEN_RDAIEN_Msk : Rx ready interrupt

Returns
  None

Definition at line 299 of file uart.h.

## ◆ UART_ENABLE_INT

#define UART_ENABLE_INT | ( |  | uart,
|  |  | u32eIntSel
| ) |  |

Enable specified interrupt.

Parameters

  [in] | uart | The base address of UART module
  [in] | u32eIntSel | Interrupt type select UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt UART_INTEN_MODEMIEN_Msk : Modem interrupt UART_INTEN_RLSIEN_Msk : Rx Line status interrupt UART_INTEN_THREIEN_Msk : Tx empty interrupt UART_INTEN_RDAIEN_Msk : Rx ready interrupt

Returns
  None

Definition at line 280 of file uart.h.

## ◆ UART_GET_INT_FLAG

#define UART_GET_INT_FLAG | ( |  | uart,
|  |  | u32eIntTypeFlag
| ) |  |

Get specified interrupt flag/status.

Parameters

  [in] | uart | The base address of UART module
  [in] | u32eIntTypeFlag | Interrupt type select UART_INTSTS_HWBUFEINT_Msk : In DMA Mode, Buffer Error Interrupt Indicator. UART_INTSTS_HWTOINT_Msk : In DMA Mode, Time-out Interrupt Indicator. UART_INTSTS_HWMODINT_Msk : In DMA Mode, MODEM Status Interrupt Indicator. UART_INTSTS_HWRLSINT_Msk : In DMA Mode, Receive Line Status Interrupt Indicator. UART_INTSTS_HWBUFEIF_Msk : In DMA Mode, Buffer Error Interrupt Flag. UART_INTSTS_HWTOIF_Msk : In DMA Mode, Time-out Interrupt Flag. UART_INTSTS_HWMODIF_Msk : In DMA Mode, MODEM Interrupt Flag. UART_INTSTS_HWRLSIF_Msk : In DMA Mode, Receive Line Status Flag. UART_INTSTS_LININT_Msk : LIN Bus Interrupt Indicator. UART_INTSTS_BUFERRINT_Msk : Buffer Error Interrupt Indicator. UART_INTSTS_RXTOINT_Msk : Time-out Interrupt Indicator. UART_INTSTS_MODEMINT_Msk : Modem Status Interrupt Indicator. UART_INTSTS_RLSINT_Msk : Receive Line Status Interrupt Indicator. UART_INTSTS_THREINT_Msk : Transmit Holding Register Empty Interrupt Indicator. UART_INTSTS_RDAINT_Msk : Receive Data Available Interrupt Indicator. UART_INTSTS_LINIF_Msk : LIN Bus Flag. UART_INTSTS_BUFERRIF_Msk : Buffer Error Interrupt Flag UART_INTSTS_RXTOIF_Msk : Rx time-out interrupt Flag UART_INTSTS_MODEMIF_Msk : Modem interrupt Flag UART_INTSTS_RLSIF_Msk : Rx Line status interrupt Flag UART_INTSTS_THREIF_Msk : Tx empty interrupt Flag UART_INTSTS_RDAIF_Msk : Rx ready interrupt Flag

Returns
  0 = The specified interrupt is not happened. 1 = The specified interrupt is happened.

Definition at line 335 of file uart.h.

## ◆ UART_GET_RX_EMPTY

#define UART_GET_RX_EMPTY | ( |  | uart | ) |

Get Rx empty register value.

Parameters

  [in] | uart | The base address of UART module

Returns
  Rx empty register value.

Definition at line 179 of file uart.h.

## ◆ UART_GET_RX_FULL

#define UART_GET_RX_FULL | ( |  | uart | ) |

Get Rx full register value.

Parameters

  [in] | uart | The base address of UART module

Returns
  Rx full register value

Definition at line 260 of file uart.h.

## ◆ UART_GET_TX_EMPTY

#define UART_GET_TX_EMPTY | ( |  | uart | ) |

Get Tx empty register value.

Parameters

  [in] | uart | The base address of UART module

Returns
  Tx empty register value.

Definition at line 168 of file uart.h.

## ◆ UART_GET_TX_FULL

#define UART_GET_TX_FULL | ( |  | uart | ) |

Get Tx full register value.

Parameters

  [in] | uart | The base address of UART module

Returns
  Tx full register value

Definition at line 249 of file uart.h.

## ◆ UART_IS_RX_FULL

#define UART_IS_RX_FULL | ( |  | uart | ) |

Check RX FIFO is full or not.

Parameters

  [in] | uart | The base address of UART module

Returns
  1 = RX FIFO is full 0 = RX FIFO is not full

Definition at line 238 of file uart.h.

## ◆ UART_IS_RX_READY

#define UART_IS_RX_READY | ( |  | uart | ) |

Check RDA_IF is set or not.

Parameters

  [in] | uart | The base address of UART module

Returns
  0 : The number of bytes in the RX FIFO is less than the RFITL 1 : The number of bytes in the RX FIFO equals or larger than RFITL

Definition at line 212 of file uart.h.

## ◆ UART_IS_TX_EMPTY

#define UART_IS_TX_EMPTY | ( |  | uart | ) |

Check specified uart port transmission is over.

Parameters

  [in] | uart | The base address of UART module

Returns
  TE_Flag.

Definition at line 189 of file uart.h.

## ◆ UART_IS_TX_FULL

#define UART_IS_TX_FULL | ( |  | uart | ) |

Check TX FIFO is full or not.

Parameters

  [in] | uart | The base address of UART module

Returns
  1 = TX FIFO is full 0 = TX FIFO is not full

Definition at line 225 of file uart.h.

## ◆ UART_READ

#define UART_READ | ( |  | uart | ) |

Read Rx data register.

Parameters

  [in] | uart | The base address of UART module.

Returns
  The oldest data byte in RX FIFO

Definition at line 157 of file uart.h.

## ◆ UART_RS485_CLEAR_ADDR_FLAG

#define UART_RS485_CLEAR_ADDR_FLAG | ( |  | uart | ) |

Clear RS-485 Address Byte Detection Flag.

Parameters

  [in] | uart | The base address of UART module

Returns
  None

Definition at line 368 of file uart.h.

## ◆ UART_RS485_GET_ADDR_FLAG

#define UART_RS485_GET_ADDR_FLAG | ( |  | uart | ) |

Get RS-485 Address Byte Detection Flag.

Parameters

  [in] | uart | The base address of UART module

Returns
  RS-485 Address Byte Detection Flag

Definition at line 378 of file uart.h.

## ◆ UART_WAIT_TX_EMPTY

#define UART_WAIT_TX_EMPTY | ( |  | uart | ) |

Wait specified uart port transmission is over.

Parameters

  [in] | uart | The base address of UART module

Returns
  None

Definition at line 200 of file uart.h.

## ◆ UART_WRITE

#define UART_WRITE | ( |  | uart,
|  |  | u8Data
| ) |  |

Write Data to Tx data register.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u8Data | Data byte to transmit

Returns
  None

Definition at line 147 of file uart.h.

## Function Documentation

## ◆ UART_CLEAR_RTS()

__STATIC_INLINE void UART_CLEAR_RTS | ( | UART_T * | uart | ) |

Set RTS pin is low.

Parameters

  [in] | uart | The base address of UART module

Returns
  None

Definition at line 344 of file uart.h.

## ◆ UART_ClearIntFlag()

void UART_ClearIntFlag | ( | UART_T * | uart,
|  | uint32_t | u32InterruptFlag
| ) |  |

The function is used to clear UART specified interrupt flag.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32InterruptFlag | The specified interrupt of UART module..

Returns
  None

Definition at line 43 of file uart.c.

## ◆ UART_Close()

void UART_Close | ( | UART_T * | uart | ) |

The function is used to disable UART.

Parameters

  [in] | uart | The base address of UART module.

Returns
  None

Definition at line 72 of file uart.c.

## ◆ UART_DisableFlowCtrl()

void UART_DisableFlowCtrl | ( | UART_T * | uart | ) |

The function is used to disable UART auto flow control.

Parameters

  [in] | uart | The base address of UART module.

Returns
  None

Definition at line 85 of file uart.c.

## ◆ UART_DisableInt()

void UART_DisableInt | ( | UART_T * | uart,
|  | uint32_t | u32InterruptFlag
| ) |  |

The function is used to disable UART specified interrupt and disable NVIC UART IRQ.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32InterruptFlag | The specified interrupt of UART module. UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt UART_INTEN_MODEMIEN_Msk : Modem interrupt UART_INTEN_RLSIEN_Msk : Rx Line status interrupt UART_INTEN_THREIEN_Msk : Tx empty interrupt UART_INTEN_RDAIEN_Msk : Rx ready interrupt

Returns
  None

Definition at line 107 of file uart.c.

## ◆ UART_EnableFlowCtrl()

void UART_EnableFlowCtrl | ( | UART_T * | uart | ) |

The function is used to Enable UART auto flow control.

Parameters

  [in] | uart | The base address of UART module.

Returns
  None

Definition at line 121 of file uart.c.

## ◆ UART_EnableInt()

void UART_EnableInt | ( | UART_T * | uart,
|  | uint32_t | u32InterruptFlag
| ) |  |

The function is used to enable UART specified interrupt and disable NVIC UART IRQ.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32InterruptFlag | The specified interrupt of UART module: UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt UART_INTEN_MODEMIEN_Msk : Modem interrupt UART_INTEN_RLSIEN_Msk : Rx Line status interrupt UART_INTEN_THREIEN_Msk : Tx empty interrupt UART_INTEN_RDAIEN_Msk : Rx ready interrupt

Returns
  None

Definition at line 146 of file uart.c.

## ◆ UART_Open()

void UART_Open | ( | UART_T * | uart,
|  | uint32_t | u32baudrate
| ) |  |

This function use to enable UART function and set baud-rate.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32baudrate | The baudrate of UART module.

Returns
  None

Definition at line 160 of file uart.c.

Here is the call graph for this function:

## ◆ UART_Read()

uint32_t UART_Read | ( | UART_T * | uart,
|  | uint8_t * | pu8RxBuf,
|  | uint32_t | u32ReadBytes
| ) |  |

The function is used to read Rx data from RX FIFO and the data will be stored in pu8RxBuf.

Parameters

  [in] | uart | The base address of UART module.
  [out] | pu8RxBuf | The buffer to receive the data of receive FIFO.
  [in] | u32ReadBytes | The the read bytes number of data.

Returns
  u32Count: Receive byte count

Definition at line 199 of file uart.c.

## ◆ UART_SelectIrDAMode()

void UART_SelectIrDAMode | ( | UART_T * | uart,
|  | uint32_t | u32Buadrate,
|  | uint32_t | u32Direction
| ) |  |

The function is used to configure IrDA relative settings. It consists of TX or RX mode and baudrate.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32Buadrate | The baudrate of UART module.
  [in] | u32Direction | The direction(transmit:1/receive:0) of UART module in IrDA mode.

Returns
  None

Definition at line 280 of file uart.c.

Here is the call graph for this function:

## ◆ UART_SelectRS485Mode()

void UART_SelectRS485Mode | ( | UART_T * | uart,
|  | uint32_t | u32Mode,
|  | uint32_t | u32Addr
| ) |  |

The function is used to set RS485 relative setting.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32Mode | The operation mode( UART_ALTCTL_RS485NMM_Msk / UART_ALTCTL_RS485AUD_Msk / UART_ALTCTL_RS485AAD_Msk).
  [in] | u32Addr | The RS485 address.

Returns
  None

Definition at line 310 of file uart.c.

## ◆ UART_SET_RTS()

__STATIC_INLINE void UART_SET_RTS | ( | UART_T * | uart | ) |

Set RTS pin is high.

Parameters

  [in] | uart | The base address of UART module

Returns
  None

Definition at line 356 of file uart.h.

## ◆ UART_SetLine_Config()

void UART_SetLine_Config | ( | UART_T * | uart,
|  | uint32_t | u32baudrate,
|  | uint32_t | u32data_width,
|  | uint32_t | u32parity,
|  | uint32_t | u32stop_bits
| ) |  |

This function use to config UART line setting.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32baudrate | The register value of baudrate of UART module. if u32baudrate = 0, UART baudrate will not change.
  [in] | u32data_width | The data length of UART module. [ UART_WORD_LEN_5 / UART_WORD_LEN_6 / UART_WORD_LEN_7 / UART_WORD_LEN_8]
  [in] | u32parity | The parity setting (odd/even/none) of UART module. [ UART_PARITY_NONE / UART_PARITY_ODD / UART_PARITY_EVEN / UART_PARITY_MARK / UART_PARITY_SPACE]
  [in] | u32stop_bits | The stop bit length (1/1.5/2 bit) of UART module. [ UART_STOP_BIT_1 / UART_STOP_BIT_1_5 / UART_STOP_BIT_2]

Returns
  None

Definition at line 229 of file uart.c.

Here is the call graph for this function:

## ◆ UART_SetTimeoutCnt()

void UART_SetTimeoutCnt | ( | UART_T * | uart,
|  | uint32_t | u32TOC
| ) |  |

This function use to set Rx timeout count.

Parameters

  [in] | uart | The base address of UART module.
  [in] | u32TOC | Rx timeout counter.

Returns
  None

Definition at line 264 of file uart.c.

## ◆ UART_Write()

uint32_t UART_Write | ( | UART_T * | uart,
|  | uint8_t * | pu8TxBuf,
|  | uint32_t | u32WriteBytes
| ) |  |

The function is to write data into TX buffer to transmit data by UART.

Parameters

  [in] | uart | The base address of UART module.
  [in] | pu8TxBuf | The buffer to send the data to UART transmission FIFO.
  [in] | u32WriteBytes | The byte number of data.

Returns
  u32Count: transfer byte count

Note
  This function returns when the TX FIFO is full. So the transfer byte count(u32Count) maybe less than u32WriteBytes. Application should check the return value for the actual amount of data written to UART FIFO.

Definition at line 329 of file uart.c.