39#define UART_FIFO_RFITL_1BYTE (0x0 << UART_FIFO_RFITL_Pos)
40#define UART_FIFO_RFITL_4BYTES (0x1 << UART_FIFO_RFITL_Pos)
41#define UART_FIFO_RFITL_8BYTES (0x2 << UART_FIFO_RFITL_Pos)
42#define UART_FIFO_RFITL_14BYTES (0x3 << UART_FIFO_RFITL_Pos)
44#define UART_FIFO_RTSTRGLV_1BYTE (0x0 << UART_FIFO_RTSTRGLV_Pos)
45#define UART_FIFO_RTSTRGLV_4BYTES (0x1 << UART_FIFO_RTSTRGLV_Pos)
46#define UART_FIFO_RTSTRGLV_8BYTES (0x2 << UART_FIFO_RTSTRGLV_Pos)
47#define UART_FIFO_RTSTRGLV_14BYTES (0x3 << UART_FIFO_RTSTRGLV_Pos)
52#define UART_WORD_LEN_5 (0)
53#define UART_WORD_LEN_6 (1)
54#define UART_WORD_LEN_7 (2)
55#define UART_WORD_LEN_8 (3)
57#define UART_PARITY_NONE (0x0 << UART_LINE_PBE_Pos)
58#define UART_PARITY_ODD (0x1 << UART_LINE_PBE_Pos)
59#define UART_PARITY_EVEN (0x3 << UART_LINE_PBE_Pos)
60#define UART_PARITY_MARK (0x5 << UART_LINE_PBE_Pos)
61#define UART_PARITY_SPACE (0x7 << UART_LINE_PBE_Pos)
63#define UART_STOP_BIT_1 (0x0 << UART_LINE_NSB_Pos)
64#define UART_STOP_BIT_1_5 (0x1 << UART_LINE_NSB_Pos)
65#define UART_STOP_BIT_2 (0x1 << UART_LINE_NSB_Pos)
71#define UART_RTS_IS_HIGH_LEV_TRG (0x1 << UART_MODEM_RTSACTLV_Pos)
72#define UART_RTS_IS_LOW_LEV_TRG (0x0 << UART_MODEM_RTSACTLV_Pos)
77#define UART_CTS_IS_HIGH_LEV_TRG (0x1 << UART_MODEMSTS_CTSACTLV_Pos)
78#define UART_CTS_IS_LOW_LEV_TRG (0x0 << UART_MODEMSTS_CTSACTLV_Pos)
83#define UART_FUNCSEL_UART (0x0 << UART_FUNCSEL_FUNCSEL_Pos)
84#define UART_FUNCSEL_LIN (0x1 << UART_FUNCSEL_FUNCSEL_Pos)
85#define UART_FUNCSEL_IrDA (0x2 << UART_FUNCSEL_FUNCSEL_Pos)
86#define UART_FUNCSEL_RS485 (0x3 << UART_FUNCSEL_FUNCSEL_Pos)
91#define UART_LINCTL_BRKFL(x) (((x)-1) << UART_LINCTL_BRKFL_Pos)
92#define UART_LINCTL_BSL(x) (((x)-1) << UART_LINCTL_BSL_Pos)
93#define UART_LINCTL_HSEL_BREAK (0x0UL << UART_LINCTL_HSEL_Pos)
94#define UART_LINCTL_HSEL_BREAK_SYNC (0x1UL << UART_LINCTL_HSEL_Pos)
95#define UART_LINCTL_HSEL_BREAK_SYNC_ID (0x2UL << UART_LINCTL_HSEL_Pos)
96#define UART_LINCTL_PID(x) ((x) << UART_LINCTL_PID_Pos)
101#define UART_BAUD_MODE0 (0)
102#define UART_BAUD_MODE2 (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk)
124#define UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate) (((u32SrcFreq + (u32BaudRate*8)) / u32BaudRate >> 4)-2)
135#define UART_BAUD_MODE2_DIVIDER(u32SrcFreq, u32BaudRate) (((u32SrcFreq + (u32BaudRate/2)) / u32BaudRate)-2)
147#define UART_WRITE(uart, u8Data) (uart->DAT = (u8Data))
157#define UART_READ(uart) (uart->DAT)
168#define UART_GET_TX_EMPTY(uart) (uart->FIFOSTS & UART_FIFOSTS_TXEMPTY_Msk)
179#define UART_GET_RX_EMPTY(uart) (uart->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk)
189#define UART_IS_TX_EMPTY(uart) ((uart->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)
200#define UART_WAIT_TX_EMPTY(uart) while(!(((uart->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos))
212#define UART_IS_RX_READY(uart) ((uart->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos)
225#define UART_IS_TX_FULL(uart) ((uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos)
238#define UART_IS_RX_FULL(uart) ((uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos)
249#define UART_GET_TX_FULL(uart) (uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)
260#define UART_GET_RX_FULL(uart) (uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)
280#define UART_ENABLE_INT(uart, u32eIntSel) (uart->INTEN |= (u32eIntSel))
299#define UART_DISABLE_INT(uart, u32eIntSel) (uart->INTEN &= ~ (u32eIntSel))
335#define UART_GET_INT_FLAG(uart,u32eIntTypeFlag) ((uart->INTSTS & (u32eIntTypeFlag))?1:0)
368#define UART_RS485_CLEAR_ADDR_FLAG(uart) (uart->FIFOSTS |= UART_FIFOSTS_ADDRDETF_Msk)
378#define UART_RS485_GET_ADDR_FLAG(uart) ((uart->FIFOSTS & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos)
388uint32_t
UART_Read(
UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes);
389void UART_SetLine_Config(
UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits);
#define UART_MODEM_RTS_Msk
#define UART_MODEM_RTSACTLV_Msk
void UART_SelectRS485Mode(UART_T *uart, uint32_t u32Mode, uint32_t u32Addr)
The function is used to set RS485 relative setting.
void UART_EnableInt(UART_T *uart, uint32_t u32InterruptFlag)
The function is used to enable UART specified interrupt and disable NVIC UART IRQ.
__STATIC_INLINE void UART_CLEAR_RTS(UART_T *uart)
Set RTS pin is low.
__STATIC_INLINE void UART_SET_RTS(UART_T *uart)
Set RTS pin is high.
void UART_SetTimeoutCnt(UART_T *uart, uint32_t u32TOC)
This function use to set Rx timeout count.
void UART_Close(UART_T *uart)
The function is used to disable UART.
void UART_ClearIntFlag(UART_T *uart, uint32_t u32InterruptFlag)
The function is used to clear UART specified interrupt flag.
void UART_DisableFlowCtrl(UART_T *uart)
The function is used to disable UART auto flow control.
void UART_EnableFlowCtrl(UART_T *uart)
The function is used to Enable UART auto flow control.
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.
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.
void UART_DisableInt(UART_T *uart, uint32_t u32InterruptFlag)
The function is used to disable UART specified interrupt and disable NVIC UART IRQ.
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.
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.
void UART_Open(UART_T *uart, uint32_t u32baudrate)
This function use to enable UART function and set baud-rate.