Nano102_112 Series BSP  V3.03.002
The Board Support Package for Nano102_112 Series
Macros | Functions
uart.h File Reference

Nano102/112 Series UART control header file. More...

Go to the source code of this file.

Macros

#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_TLCTL_PBE_Pos)
 
#define UART_PARITY_ODD   (0x1 << UART_TLCTL_PBE_Pos)
 
#define UART_PARITY_EVEN   (0x3 << UART_TLCTL_PBE_Pos)
 
#define UART_PARITY_MARK   (0x5 << UART_TLCTL_PBE_Pos)
 
#define UART_PARITY_SPACE   (0x7 << UART_TLCTL_PBE_Pos)
 
#define UART_STOP_BIT_1   (0x0 << UART_TLCTL_NSB_Pos)
 
#define UART_STOP_BIT_1_5   (0x1 << UART_TLCTL_NSB_Pos)
 
#define UART_STOP_BIT_2   (0x1 << UART_TLCTL_NSB_Pos)
 
#define UART_TLCTL_RFITL_1BYTE   (0x0 << UART_TLCTL_RFITL_Pos)
 
#define UART_TLCTL_RFITL_4BYTES   (0x1 << UART_TLCTL_RFITL_Pos)
 
#define UART_TLCTL_RFITL_8BYTES   (0x2 << UART_TLCTL_RFITL_Pos)
 
#define UART_TLCTL_RFITL_14BYTES   (0x3 << UART_TLCTL_RFITL_Pos)
 
#define UART_TLCTL_RTS_TRI_LEV_1BYTE   (0x0 << UART_TLCTL_RTS_TRI_LEV_Pos)
 
#define UART_TLCTL_RTS_TRI_LEV_4BYTES   (0x1 << UART_TLCTL_RTS_TRI_LEV_Pos)
 
#define UART_TLCTL_RTS_TRI_LEV_8BYTES   (0x2 << UART_TLCTL_RTS_TRI_LEV_Pos)
 
#define UART_TLCTL_RTS_TRI_LEV_14BYTES   (0x3 << UART_TLCTL_RTS_TRI_LEV_Pos)
 
#define UART_RTS_IS_HIGH_LEV_TRG   (0x1 << UART_MCSR_LEV_RTS_Pos)
 
#define UART_RTS_IS_LOW_LEV_TRG   (0x0 << UART_MCSR_LEV_RTS_Pos)
 
#define UART_FUNC_SEL_UART   (0x0 << UART_FUN_SEL_FUN_SEL_Pos)
 
#define UART_FUNC_SEL_LIN   (0x1 << UART_FUN_SEL_FUN_SEL_Pos)
 
#define UART_FUNC_SEL_IrDA   (0x2 << UART_FUN_SEL_FUN_SEL_Pos)
 
#define UART_FUNC_SEL_RS485   (0x3 << UART_FUN_SEL_FUN_SEL_Pos)
 
#define UART_BAUD_MODE0   (0)
 Calculate UART baudrate mode0 divider. More...
 
#define UART_BAUD_MODE1   (UART_BAUD_DIV_16_EN_Msk)
 Calculate UART baudrate mode0 divider. More...
 
#define UART_BAUD_MODE1_DIVIDER(u32SrcFreq, u32BaudRate)   (((u32SrcFreq + (u32BaudRate*8)) / u32BaudRate >> 4)-1)
 Calculate UART baudrate mode0 divider. More...
 
#define UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate)   (((u32SrcFreq + (u32BaudRate/2)) / u32BaudRate)-1)
 Calculate UART baudrate mode2 divider. More...
 
#define UART_WRITE(uart, u8Data)   (uart->THR = (u8Data))
 Write Data to Tx data register. More...
 
#define UART_READ(uart)   (uart->RBR)
 Read Rx data register. More...
 
#define UART_GET_TX_EMPTY(uart)   (uart->FSR & UART_FSR_TX_EMPTY_F_Msk)
 Get Tx empty register value. More...
 
#define UART_GET_RX_EMPTY(uart)   (uart->FSR & UART_FSR_RX_EMPTY_F_Msk)
 Get Rx empty register value. More...
 
#define UART_IS_TX_EMPTY(uart)   ((uart->FSR & UART_FSR_TE_F_Msk) >> UART_FSR_TE_F_Pos)
 Check specified UART port transmission is over. More...
 
#define UART_WAIT_TX_EMPTY(uart)   while(!(((uart->FSR) & UART_FSR_TX_EMPTY_F_Msk) >> UART_FSR_TX_EMPTY_F_Pos))
 Wait specified UART port transmission is over. More...
 
#define UART_IS_RX_READY(uart)   ((uart->ISR & UART_ISR_RDA_IS_Msk)>>UART_ISR_RDA_IS_Pos)
 Check RDA_IF is set or not. More...
 
#define UART_IS_TX_FULL(uart)   ((uart->FSR & UART_FSR_TX_FULL_F_Msk)>>UART_FSR_TX_FULL_F_Pos)
 Check TX FIFO is full or not. More...
 
#define UART_IS_RX_FULL(uart)   ((uart->FSR & UART_FSR_RX_FULL_F_Msk)>>UART_FSR_RX_FULL_F_Pos)
 Check RX FIFO is full or not. More...
 
#define UART_GET_TX_FULL(uart)   (uart->FSR & UART_FSR_TX_FULL_F_Msk)
 Get Tx full register value. More...
 
#define UART_GET_RX_FULL(uart)   (uart->FSR & UART_FSR_RX_FULL_F_Msk)
 Get Rx full register value. More...
 
#define UART_SET_RX_FIFO_INTTRGLV(uart, u32TriggerLevel)   ((uart)->TLCTL = ((uart)->TLCTL & ~UART_TLCTL_RFITL_Msk) | (u32TriggerLevel))
 Set Rx FIFO interrupt Trigger Level. More...
 
#define UART_ENABLE_INT(uart, u32eIntSel)   (uart->IER |= (u32eIntSel))
 Enable specified interrupt. More...
 
#define UART_DISABLE_INT(uart, u32eIntSel)   (uart->IER &= ~ (u32eIntSel))
 Disable specified interrupt. More...
 
#define UART_GET_INT_FLAG(uart, u32eIntTypeFlag)   ((uart->ISR & (u32eIntTypeFlag))?1:0)
 Get specified interrupt flag/status. More...
 
#define UART_RS485_CLEAR_ADDR_FLAG(uart)   (uart->TRSR = UART_TRSR_RS485_ADDET_F_Msk)
 Clear RS-485 Address Byte Detection Flag. More...
 
#define UART_RS485_GET_ADDR_FLAG(uart)   ((uart->TRSR & UART_TRSR_RS485_ADDET_F_Msk) >> UART_TRSR_RS485_ADDET_F_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. 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. 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...
 
void UART_SelectLINMode (UART_T *uart, uint32_t u32Mode, uint32_t u32BreakLength)
 Select and configure LIN function. 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

Nano102/112 Series UART control header file.

Version
V1.00
Revision
14
Date
15/06/17 1:36p
Note
SPDX-License-Identifier: Apache-2.0 Copyright (C) 2013~2014 Nuvoton Technology Corp. All rights reserved.

Definition in file uart.h.