M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
Macros | Functions
uart.h File Reference

M471M/R1/S UART driver header file. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UART0_FIFO_SIZE   16
 
#define UART1_FIFO_SIZE   16
 
#define UART2_FIFO_SIZE   16
 
#define UART3_FIFO_SIZE   16
 
#define UART_FIFO_RFITL_1BYTE   (0x0 << UART_FIFO_RFITL_Pos)
 
#define UART_FIFO_RFITL_4BYTES   (0x1 << UART_FIFO_RFITL_Pos)
 
#define UART_FIFO_RFITL_8BYTES   (0x2 << UART_FIFO_RFITL_Pos)
 
#define UART_FIFO_RFITL_14BYTES   (0x3 << UART_FIFO_RFITL_Pos)
 
#define UART_FIFO_RTSTRGLV_1BYTE   (0x0 << UART_FIFO_RTSTRGLV_Pos)
 
#define UART_FIFO_RTSTRGLV_4BYTES   (0x1 << UART_FIFO_RTSTRGLV_Pos)
 
#define UART_FIFO_RTSTRGLV_8BYTES   (0x2 << UART_FIFO_RTSTRGLV_Pos)
 
#define UART_FIFO_RTSTRGLV_14BYTES   (0x3 << UART_FIFO_RTSTRGLV_Pos)
 
#define UART_WORD_LEN_5   (0)
 
#define UART_WORD_LEN_6   (1)
 
#define UART_WORD_LEN_7   (2)
 
#define UART_WORD_LEN_8   (3)
 
#define UART_PARITY_NONE   (0x0 << UART_LINE_PBE_Pos)
 
#define UART_PARITY_ODD   (0x1 << UART_LINE_PBE_Pos)
 
#define UART_PARITY_EVEN   (0x3 << UART_LINE_PBE_Pos)
 
#define UART_PARITY_MARK   (0x5 << UART_LINE_PBE_Pos)
 
#define UART_PARITY_SPACE   (0x7 << UART_LINE_PBE_Pos)
 
#define UART_STOP_BIT_1   (0x0 << UART_LINE_NSB_Pos)
 
#define UART_STOP_BIT_1_5   (0x1 << UART_LINE_NSB_Pos)
 
#define UART_STOP_BIT_2   (0x1 << UART_LINE_NSB_Pos)
 
#define UART_RTS_IS_LOW_LEV_ACTIVE   (0x1 << UART_MODEM_RTSACTLV_Pos)
 
#define UART_RTS_IS_HIGH_LEV_ACTIVE   (0x0 << UART_MODEM_RTSACTLV_Pos)
 
#define UART_IRDA_TXEN   (0x1 << UART_IRDA_TXEN_Pos)
 
#define UART_IRDA_RXEN   (0x0 << UART_IRDA_TXEN_Pos)
 
#define UART_FUNCSEL_UART   (0x0 << UART_FUNCSEL_FUNCSEL_Pos)
 
#define UART_FUNCSEL_IrDA   (0x2 << UART_FUNCSEL_FUNCSEL_Pos)
 
#define UART_FUNCSEL_RS485   (0x3 << UART_FUNCSEL_FUNCSEL_Pos)
 
#define UART_BAUD_MODE0   (0)
 
#define UART_BAUD_MODE2   (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk)
 
#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 UART data. More...
 
#define UART_READ(uart)   ((uart)->DAT)
 Read UART data. More...
 
#define UART_GET_TX_EMPTY(uart)   ((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTY_Msk)
 Get Tx empty. More...
 
#define UART_GET_RX_EMPTY(uart)   ((uart)->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk)
 Get Rx empty. 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 RX is ready 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 UART interrupt. More...
 
#define UART_DISABLE_INT(uart, u32eIntSel)   ((uart)->INTEN &= ~ (u32eIntSel))
 Disable specified UART 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

__STATIC_INLINE void UART_CLEAR_RTS (UART_T *uart)
 Set RTS pin to low. More...
 
__STATIC_INLINE void UART_SET_RTS (UART_T *uart)
 Set RTS pin to high. More...
 
void UART_ClearIntFlag (UART_T *uart, uint32_t u32InterruptFlag)
 Clear UART specified interrupt flag. More...
 
void UART_Close (UART_T *uart)
 Disable UART interrupt. More...
 
void UART_DisableFlowCtrl (UART_T *uart)
 Disable UART auto flow control function. More...
 
void UART_DisableInt (UART_T *uart, uint32_t u32InterruptFlag)
 Disable UART specified interrupt. More...
 
void UART_EnableFlowCtrl (UART_T *uart)
 Enable UART auto flow control function. More...
 
void UART_EnableInt (UART_T *uart, uint32_t u32InterruptFlag)
 The function is used to enable UART specified interrupt and enable NVIC UART IRQ. More...
 
void UART_Open (UART_T *uart, uint32_t u32baudrate)
 Open and set UART function. More...
 
uint32_t UART_Read (UART_T *uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
 Read UART data. More...
 
void UART_SetLine_Config (UART_T *uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits)
 Set UART line configuration. More...
 
void UART_SetTimeoutCnt (UART_T *uart, uint32_t u32TOC)
 Set Rx timeout count. More...
 
void UART_SelectIrDAMode (UART_T *uart, uint32_t u32Buadrate, uint32_t u32Direction)
 Select and configure IrDA function. More...
 
void UART_SelectRS485Mode (UART_T *uart, uint32_t u32Mode, uint32_t u32Addr)
 Select and configure RS485 function. More...
 
uint32_t UART_Write (UART_T *uart, uint8_t *pu8TxBuf, uint32_t u32WriteBytes)
 Write UART data. More...
 

Detailed Description

M471M/R1/S UART driver header file.

SPDX-License-Identifier: Apache-2.0

Definition in file uart.h.