MINI55_BSP V3.02.004
The Board Support Package for Mini55 Series MCU
Macros | Functions
Collaboration diagram for UART Exported Functions:

Macros

#define UART_BAUD_MODE0   (0)
 Calculate UART baudrate mode0 divider. More...
 
#define UART_BAUD_MODE2   (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk)
 Calculate UART baudrate mode0 divider. More...
 
#define UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate)   (((u32SrcFreq + (u32BaudRate*8)) / u32BaudRate >> 4)-2)
 Calculate UART baudrate mode0 divider. More...
 
#define UART_BAUD_MODE2_DIVIDER(u32SrcFreq, u32BaudRate)   (((u32SrcFreq + (u32BaudRate/2)) / u32BaudRate)-2)
 Calculate UART baudrate mode2 divider. More...
 
#define UART_WRITE(uart, u8Data)   (uart->DAT = (u8Data))
 Write Data to Tx data register. More...
 
#define UART_READ(uart)   (uart->DAT)
 Read Rx data register. More...
 
#define UART_GET_TX_EMPTY(uart)   (uart->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk)
 Get Tx empty register value. More...
 
#define UART_GET_RX_EMPTY(uart)   (uart->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk)
 Get Rx empty register value. More...
 
#define UART_IS_TX_EMPTY(uart)   ((uart->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)
 Check specified uart port transmission is over. More...
 
#define UART_WAIT_TX_EMPTY(uart)   while(!(((uart->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos))
 Wait specified uart port transmission is over. More...
 
#define UART_IS_RX_READY(uart)   ((uart->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos)
 Check RDA_IF is set or not. More...
 
#define UART_IS_TX_FULL(uart)   ((uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos)
 Check TX FIFO is full or not. More...
 
#define UART_IS_RX_FULL(uart)   ((uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos)
 Check RX FIFO is full or not. More...
 
#define UART_GET_TX_FULL(uart)   (uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)
 Get Tx full register value. More...
 
#define UART_GET_RX_FULL(uart)   (uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)
 Get Rx full register value. More...
 
#define UART_ENABLE_INT(uart, u32eIntSel)   (uart->INTEN |= (u32eIntSel))
 Enable specified interrupt. More...
 
#define UART_DISABLE_INT(uart, u32eIntSel)   (uart->INTEN &= ~ (u32eIntSel))
 Disable specified interrupt. More...
 
#define UART_GET_INT_FLAG(uart, u32eIntTypeFlag)   ((uart->INTSTS & (u32eIntTypeFlag))?1:0)
 Get specified interrupt flag/status. More...
 
#define UART_RS485_CLEAR_ADDR_FLAG(uart)   (uart->FIFOSTS |= UART_FIFOSTS_ADDRDETF_Msk)
 Clear RS-485 Address Byte Detection Flag. More...
 
#define UART_RS485_GET_ADDR_FLAG(uart)   ((uart->FIFOSTS & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos)
 Get RS-485 Address Byte Detection Flag. More...
 

Functions

__INLINE void UART_CLEAR_RTS (UART_T *uart)
 Set RTS pin is low. More...
 
__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

#define UART_BAUD_MODE0   (0)

Calculate UART baudrate mode0 divider.

Parameters
None
Returns
UART baudrate mode0 register setting value

Definition at line 95 of file uart.h.

◆ UART_BAUD_MODE0_DIVIDER

#define UART_BAUD_MODE0_DIVIDER (   u32SrcFreq,
  u32BaudRate 
)    (((u32SrcFreq + (u32BaudRate*8)) / u32BaudRate >> 4)-2)

Calculate UART baudrate mode0 divider.

Parameters
[in]u32SrcFreqUART clock frequency
[in]u32BaudRateBaudrate of UART module
Returns
UART baudrate mode0 divider

Definition at line 117 of file uart.h.

◆ UART_BAUD_MODE2

#define UART_BAUD_MODE2   (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk)

Calculate UART baudrate mode0 divider.

Parameters
None
Returns
UART baudrate mode2 register setting value

Definition at line 105 of file uart.h.

◆ UART_BAUD_MODE2_DIVIDER

#define UART_BAUD_MODE2_DIVIDER (   u32SrcFreq,
  u32BaudRate 
)    (((u32SrcFreq + (u32BaudRate/2)) / u32BaudRate)-2)

Calculate UART baudrate mode2 divider.

Parameters
[in]u32SrcFreqUART clock frequency
[in]u32BaudRateBaudrate of UART module
Returns
UART baudrate mode2 divider

Definition at line 127 of file uart.h.

◆ UART_DISABLE_INT

#define UART_DISABLE_INT (   uart,
  u32eIntSel 
)    (uart->INTEN &= ~ (u32eIntSel))

Disable specified interrupt.

Parameters
[in]uartThe base address of UART module
[in]u32eIntSelInterrupt type select
Returns
None

Definition at line 278 of file uart.h.

◆ UART_ENABLE_INT

#define UART_ENABLE_INT (   uart,
  u32eIntSel 
)    (uart->INTEN |= (u32eIntSel))

Enable specified interrupt.

Parameters
[in]uartThe base address of UART module
[in]u32eIntSelInterrupt type select
Returns
None

Definition at line 260 of file uart.h.

◆ UART_GET_INT_FLAG

#define UART_GET_INT_FLAG (   uart,
  u32eIntTypeFlag 
)    ((uart->INTSTS & (u32eIntTypeFlag))?1:0)

Get specified interrupt flag/status.

Parameters
[in]uartThe base address of UART module
[in]u32eIntTypeFlagInterrupt Type Flag,should be
Returns
0 = The specified interrupt is not happened. 1 = The specified interrupt is happened.

Definition at line 299 of file uart.h.

◆ UART_GET_RX_EMPTY

#define UART_GET_RX_EMPTY (   uart)    (uart->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk)

Get Rx empty register value.

Parameters
[in]uartThe base address of UART module
Returns
Rx empty register value.

Definition at line 167 of file uart.h.

◆ UART_GET_RX_FULL

#define UART_GET_RX_FULL (   uart)    (uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)

Get Rx full register value.

Parameters
[in]uartThe base address of UART module
Returns
Rx full register value

Definition at line 241 of file uart.h.

◆ UART_GET_TX_EMPTY

#define UART_GET_TX_EMPTY (   uart)    (uart->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk)

Get Tx empty register value.

Parameters
[in]uartThe base address of UART module
Returns
Tx empty register value.

Definition at line 157 of file uart.h.

◆ UART_GET_TX_FULL

#define UART_GET_TX_FULL (   uart)    (uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)

Get Tx full register value.

Parameters
[in]uartThe base address of UART module
Returns
Tx full register value

Definition at line 231 of file uart.h.

◆ UART_IS_RX_FULL

#define UART_IS_RX_FULL (   uart)    ((uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos)

Check RX FIFO is full or not.

Parameters
[in]uartThe base address of UART module
Returns
1 = RX FIFO is full 0 = RX FIFO is not full

Definition at line 221 of file uart.h.

◆ UART_IS_RX_READY

#define UART_IS_RX_READY (   uart)    ((uart->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos)

Check RDA_IF is set or not.

Parameters
[in]uartThe 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 197 of file uart.h.

◆ UART_IS_TX_EMPTY

#define UART_IS_TX_EMPTY (   uart)    ((uart->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)

Check specified uart port transmission is over.

Parameters
[in]uartThe base address of UART module
Returns
TE_Flag.

Definition at line 176 of file uart.h.

◆ UART_IS_TX_FULL

#define UART_IS_TX_FULL (   uart)    ((uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos)

Check TX FIFO is full or not.

Parameters
[in]uartThe base address of UART module
Returns
1 = TX FIFO is full 0 = TX FIFO is not full

Definition at line 209 of file uart.h.

◆ UART_READ

#define UART_READ (   uart)    (uart->DAT)

Read Rx data register.

Parameters
[in]uartThe base address of UART module.
Returns
The oldest data byte in RX FIFO

Definition at line 147 of file uart.h.

◆ UART_RS485_CLEAR_ADDR_FLAG

#define UART_RS485_CLEAR_ADDR_FLAG (   uart)    (uart->FIFOSTS |= UART_FIFOSTS_ADDRDETF_Msk)

Clear RS-485 Address Byte Detection Flag.

Parameters
[in]uartThe base address of UART module
Returns
None

Definition at line 331 of file uart.h.

◆ UART_RS485_GET_ADDR_FLAG

#define UART_RS485_GET_ADDR_FLAG (   uart)    ((uart->FIFOSTS & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos)

Get RS-485 Address Byte Detection Flag.

Parameters
[in]uartThe base address of UART module
Returns
RS-485 Address Byte Detection Flag

Definition at line 340 of file uart.h.

◆ UART_WAIT_TX_EMPTY

#define UART_WAIT_TX_EMPTY (   uart)    while(!(((uart->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos))

Wait specified uart port transmission is over.

Parameters
[in]uartThe base address of UART module
Returns
None

Definition at line 186 of file uart.h.

◆ UART_WRITE

#define UART_WRITE (   uart,
  u8Data 
)    (uart->DAT = (u8Data))

Write Data to Tx data register.

Parameters
[in]uartThe base address of UART module.
[in]u8DataData byte to transmit
Returns
None

Definition at line 138 of file uart.h.

Function Documentation

◆ UART_CLEAR_RTS()

__INLINE void UART_CLEAR_RTS ( UART_T uart)

Set RTS pin is low.

Parameters
[in]uartThe base address of UART module
Returns
None

Definition at line 308 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]uartThe base address of UART module.
[in]u32InterruptFlagThe specified interrupt of UART module.
Returns
None

Definition at line 37 of file uart.c.

◆ UART_Close()

void UART_Close ( UART_T uart)

The function is used to disable UART.

Parameters
[in]uartThe base address of UART module.
Returns
None

Definition at line 67 of file uart.c.

◆ UART_DisableFlowCtrl()

void UART_DisableFlowCtrl ( UART_T uart)

The function is used to disable UART auto flow control.

Parameters
[in]uartThe base address of UART module.
Returns
None

Definition at line 80 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]uartThe base address of UART module.
[in]u32InterruptFlagThe specified interrupt of UART module.
Returns
None

Definition at line 102 of file uart.c.

◆ UART_EnableFlowCtrl()

void UART_EnableFlowCtrl ( UART_T uart)

The function is used to Enable UART auto flow control.

Parameters
[in]uartThe base address of UART module.
Returns
None

Definition at line 116 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]uartThe base address of UART module.
[in]u32InterruptFlagThe specified interrupt of UART module:
Returns
None

Definition at line 141 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]uartThe base address of UART module.
[in]u32baudrateThe baudrate of UART module.
Returns
None

Definition at line 155 of file uart.c.

◆ 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]uartThe base address of UART module.
[in]pu8RxBufThe buffer to receive the data of receive FIFO.
[in]u32ReadBytesThe the read bytes number of data.
Returns
u32Count: Receive byte count

Definition at line 205 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]uartThe base address of UART module.
[in]u32BuadrateThe baudrate of UART module.
[in]u32DirectionThe direction(transmit:1/receive:0) of UART module in IrDA mode.
Returns
None

Definition at line 302 of file uart.c.

◆ 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]uartThe base address of UART module.
[in]u32ModeThe operation mode(NMM/AUD/AAD).
[in]u32AddrThe RS485 address.
Returns
None

Definition at line 345 of file uart.c.

◆ UART_SET_RTS()

__INLINE void UART_SET_RTS ( UART_T uart)

Set RTS pin is high.

Parameters
[in]uartThe base address of UART module
Returns
None

Definition at line 320 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]uartThe base address of UART module.
[in]u32baudrateThe register value of baudrate of UART module. if u32baudrate = 0, UART baudrate will not change.
[in]u32data_widthThe data length of UART module.
[in]u32parityThe parity setting (odd/even/none) of UART module.
[in]u32stop_bitsThe stop bit length (1/1.5 bit) of UART module.
Returns
None

Definition at line 239 of file uart.c.

◆ UART_SetTimeoutCnt()

void UART_SetTimeoutCnt ( UART_T uart,
uint32_t  u32TOC 
)

This function use to set Rx timeout count.

Parameters
[in]uartThe base address of UART module.
[in]u32TOCRx timeout counter.
Returns
None

Definition at line 286 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]uartThe base address of UART module.
[in]pu8TxBufThe buffer to send the data to UART transmission FIFO.
[in]u32WriteBytesThe byte number of data.
Returns
u32Count: transfer byte count

Definition at line 362 of file uart.c.