![]() |
M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
|
Macros | |
#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... | |
#define UART_BAUD_MODE0_DIVIDER | ( | u32SrcFreq, | |
u32BaudRate | |||
) | ((((u32SrcFreq) + ((u32BaudRate)*8)) / (u32BaudRate) >> 4)-2) |
#define UART_BAUD_MODE2_DIVIDER | ( | u32SrcFreq, | |
u32BaudRate | |||
) | ((((u32SrcFreq) + ((u32BaudRate)/2)) / (u32BaudRate))-2) |
#define UART_DISABLE_INT | ( | uart, | |
u32eIntSel | |||
) | ((uart)->INTEN &= ~ (u32eIntSel)) |
Disable specified UART interrupt.
[in] | uart | The pointer of the specified UART module |
[in] | u32eIntSel | Interrupt type select
|
This macro enable specified UART interrupt.
#define UART_ENABLE_INT | ( | uart, | |
u32eIntSel | |||
) | ((uart)->INTEN |= (u32eIntSel)) |
Enable specified UART interrupt.
[in] | uart | The pointer of the specified UART module |
[in] | u32eIntSel | Interrupt type select
|
This macro enable specified UART interrupt.
#define UART_GET_INT_FLAG | ( | uart, | |
u32eIntTypeFlag | |||
) | (((uart)->INTSTS & (u32eIntTypeFlag))?1:0) |
Get specified interrupt flag/status.
[in] | uart | The pointer of the specified UART module |
[in] | u32eIntTypeFlag | Interrupt Type Flag, should be
|
0 | The specified interrupt is not happened. 1 The specified interrupt is happened. |
This macro get specified interrupt flag or interrupt indicator status.
#define UART_GET_RX_EMPTY | ( | uart | ) | ((uart)->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk) |
#define UART_GET_RX_FULL | ( | uart | ) | ((uart)->FIFOSTS & UART_FIFOSTS_RXFULL_Msk) |
#define UART_GET_TX_EMPTY | ( | uart | ) | ((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTY_Msk) |
#define UART_GET_TX_FULL | ( | uart | ) | ((uart)->FIFOSTS & UART_FIFOSTS_TXFULL_Msk) |
#define UART_IS_RX_FULL | ( | uart | ) | (((uart)->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos) |
#define UART_IS_RX_READY | ( | uart | ) | (((uart)->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos) |
Check RX is ready or not.
[in] | uart | The pointer of the specified UART module |
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 |
This macro check receive data available interrupt flag is set or not.
#define UART_IS_TX_EMPTY | ( | uart | ) | (((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos) |
Check specified uart port transmission is over.
[in] | uart | The pointer of the specified UART module |
0 | Tx transmission is not over |
1 | Tx transmission is over |
This macro return Transmitter Empty Flag register bit value. It indicates if specified uart port transmission is over nor not.
#define UART_IS_TX_FULL | ( | uart | ) | (((uart)->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos) |
#define UART_READ | ( | uart | ) | ((uart)->DAT) |
#define UART_RS485_CLEAR_ADDR_FLAG | ( | uart | ) | ((uart)->FIFOSTS = UART_FIFOSTS_ADDRDETF_Msk) |
#define UART_RS485_GET_ADDR_FLAG | ( | uart | ) | (((uart)->FIFOSTS & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos) |
Get RS-485 Address Byte Detection Flag.
[in] | uart | The pointer of the specified UART module |
0 | Receiver detects a data that is not an address bit. |
1 | Receiver detects a data that is an address bit. |
This macro get RS-485 address byte detection flag.
#define UART_WAIT_TX_EMPTY | ( | uart | ) | while(!((((uart)->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)) |
#define UART_WRITE | ( | uart, | |
u8Data | |||
) | ((uart)->DAT = (u8Data)) |
__STATIC_INLINE void UART_CLEAR_RTS | ( | UART_T * | uart | ) |
void UART_ClearIntFlag | ( | UART_T * | uart, |
uint32_t | u32InterruptFlag | ||
) |
Clear UART specified interrupt flag.
[in] | uart | The pointer of the specified UART module. |
[in] | u32InterruptFlag | The specified interrupt of UART module.
|
The function is used to clear UART specified interrupt flag.
void UART_Close | ( | UART_T * | uart | ) |
void UART_DisableFlowCtrl | ( | UART_T * | uart | ) |
void UART_DisableInt | ( | UART_T * | uart, |
uint32_t | u32InterruptFlag | ||
) |
Disable UART specified interrupt.
[in] | uart | The pointer of the specified UART module. |
[in] | u32InterruptFlag | The specified interrupt of UART module.
|
The function is used to disable UART specified interrupt and disable NVIC UART IRQ.
void UART_EnableFlowCtrl | ( | UART_T * | uart | ) |
void UART_EnableInt | ( | UART_T * | uart, |
uint32_t | u32InterruptFlag | ||
) |
The function is used to enable UART specified interrupt and enable NVIC UART IRQ.
[in] | uart | The pointer of the specified UART module. |
[in] | u32InterruptFlag | The specified interrupt of UART module:
|
The function is used to enable UART specified interrupt and enable NVIC UART IRQ.
void UART_Open | ( | UART_T * | uart, |
uint32_t | u32baudrate | ||
) |
uint32_t UART_Read | ( | UART_T * | uart, |
uint8_t * | pu8RxBuf, | ||
uint32_t | u32ReadBytes | ||
) |
Read UART data.
[in] | uart | The pointer of the specified UART module. |
[in] | pu8RxBuf | The buffer to receive the data of receive FIFO. |
[in] | u32ReadBytes | The the read bytes number of data. |
The function is used to read Rx data from RX FIFO and the data will be stored in pu8RxBuf.
void UART_SelectIrDAMode | ( | UART_T * | uart, |
uint32_t | u32Buadrate, | ||
uint32_t | u32Direction | ||
) |
Select and configure IrDA function.
[in] | uart | The pointer of the specified UART module. |
[in] | u32Buadrate | The baudrate of UART module. |
[in] | u32Direction | The direction of UART module in IrDA mode: |
The function is used to configure IrDA relative settings. It consists of TX or RX mode and baudrate.
Definition at line 345 of file uart.c.
void UART_SelectRS485Mode | ( | UART_T * | uart, |
uint32_t | u32Mode, | ||
uint32_t | u32Addr | ||
) |
Select and configure RS485 function.
[in] | uart | The pointer of the specified UART module. |
[in] | u32Mode | The operation mode(NMM/AUD/AAD). |
[in] | u32Addr | The RS485 address. |
The function is used to set RS485 relative setting.
__STATIC_INLINE void UART_SET_RTS | ( | UART_T * | uart | ) |
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.
[in] | uart | The pointer of the specified 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. |
[in] | u32parity | The parity setting (none/odd/even/mark/space) of UART module. |
[in] | u32stop_bits | The stop bit length (1/1.5/2 bit) of UART module. |
This function use to config UART line setting.
Definition at line 280 of file uart.c.
void UART_SetTimeoutCnt | ( | UART_T * | uart, |
uint32_t | u32TOC | ||
) |
uint32_t UART_Write | ( | UART_T * | uart, |
uint8_t * | pu8TxBuf, | ||
uint32_t | u32WriteBytes | ||
) |
Write UART data.
[in] | uart | The pointer of the specified UART module. |
[in] | pu8TxBuf | The buffer to send the data to UART transmission FIFO. |
[out] | u32WriteBytes | The byte number of data. |
The function is to write data into TX buffer to transmit data by UART.