![]() |
M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
|
Macros | |
#define | SCUART_WRITE(sc, u8Data) |
Write Data to Tx data register. More... | |
#define | SCUART_GET_TX_EMPTY(sc) |
Get TX FIFO empty flag status from register. More... | |
#define | SCUART_GET_TX_FULL(sc) |
Get TX FIFO full flag status from register. More... | |
#define | SCUART_WAIT_TX_EMPTY(sc) |
Wait specified smartcard port transmission complete. More... | |
#define | SCUART_IS_TX_FULL(sc) |
Check specified smartcard port transmit FIFO is full or not. More... | |
#define | SCUART_IS_TX_EMPTY(sc) |
Check specified smartcard port transmission is over. More... | |
#define | SCUART_READ(sc) |
Read Rx data register. More... | |
#define | SCUART_GET_RX_EMPTY(sc) |
Get RX FIFO empty flag status from register. More... | |
#define | SCUART_GET_RX_FULL(sc) |
Get RX FIFO full flag status from register. More... | |
#define | SCUART_IS_RX_READY(sc) |
Check if receive data number in FIFO reach FIFO trigger level or not. More... | |
#define | SCUART_IS_RX_FULL(sc) |
Check specified smartcard port receive FIFO is full or not. More... | |
#define | SCUART_ENABLE_INT(sc, u32Mask) |
Enable specified interrupts. More... | |
#define | SCUART_DISABLE_INT(sc, u32Mask) |
Disable specified interrupts. More... | |
#define | SCUART_GET_INT_FLAG(sc, u32Type) |
Get specified interrupt flag/status. More... | |
#define | SCUART_CLR_INT_FLAG(sc, u32Type) |
Clear specified interrupt flag/status. More... | |
#define | SCUART_GET_ERR_FLAG(sc) |
Get receive error flag/status. More... | |
#define | SCUART_CLR_ERR_FLAG(sc, u32Mask) |
Clear specified receive error flag/status. More... | |
Functions | |
void | SCUART_Close (SC_T *sc) |
Disable smartcard uart interface. More... | |
uint32_t | SCUART_Open (SC_T *sc, uint32_t u32baudrate) |
Enable smartcard uart interface. More... | |
uint32_t | SCUART_Read (SC_T *sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes) |
Read data from smartcard UART interface. More... | |
uint32_t | SCUART_SetLineConfig (SC_T *sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits) |
This function use to config smartcard UART mode line setting. More... | |
void | SCUART_SetTimeoutCnt (SC_T *sc, uint32_t u32TOC) |
This function use to set receive timeout count. More... | |
void | SCUART_Write (SC_T *sc, uint8_t *pu8TxBuf, uint32_t u32WriteBytes) |
Write data to smartcard UART interface. More... | |
#define SCUART_CLR_ERR_FLAG | ( | sc, | |
u32Mask | |||
) |
Clear specified receive error flag/status.
[in] | sc | The pointer of smartcard module. |
[in] | u32Mask | Receive error flag/status to clear, combination following values: |
The macro is used to clear receiver parity error flag, receiver frame error flag or receiver break error flag.
#define SCUART_CLR_INT_FLAG | ( | sc, | |
u32Type | |||
) |
Clear specified interrupt flag/status.
[in] | sc | The pointer of smartcard module. |
[in] | u32Type | Interrupt flag/status to clear, could be the combination of following values: |
The macro is used to clear receiver buffer time-out interrupt flag, transfer error interrupt flag or transmit buffer empty interrupt flag.
#define SCUART_DISABLE_INT | ( | sc, | |
u32Mask | |||
) |
Disable specified interrupts.
[in] | sc | The pointer of smartcard module. |
[in] | u32Mask | Interrupt masks to disable, a combination of following bits. |
The macro is used to disable receiver buffer time-out interrupt, transfer error interrupt, transmit buffer empty interrupt or receive data reach trigger level interrupt.
#define SCUART_ENABLE_INT | ( | sc, | |
u32Mask | |||
) |
Enable specified interrupts.
[in] | sc | The pointer of smartcard module. |
[in] | u32Mask | Interrupt masks to enable, a combination of following bits. |
The macro is used to enable receiver buffer time-out interrupt, transfer error interrupt, transmit buffer empty interrupt or receive data reach trigger level interrupt.
#define SCUART_GET_ERR_FLAG | ( | sc | ) |
Get receive error flag/status.
[in] | sc | The pointer of smartcard module. |
SC_STATUS_PEF_Msk | Parity error. |
SC_STATUS_FEF_Msk | Frame error. |
SC_STATUS_BEF_Msk | Break error. |
The macro is used to get receiver parity error status, receiver frame error status or receiver break error status.
#define SCUART_GET_INT_FLAG | ( | sc, | |
u32Type | |||
) |
Get specified interrupt flag/status.
[in] | sc | The pointer of smartcard module. |
[in] | u32Type | Interrupt flag/status to check, could be one of following value: |
0 | Specified interrupt does not happened. |
1 | Specified interrupt happened. |
The macro is used to get receiver buffer time-out interrupt status, transfer error interrupt status, transmit buffer empty interrupt status or receive data reach interrupt status.
#define SCUART_GET_RX_EMPTY | ( | sc | ) |
Get RX FIFO empty flag status from register.
[in] | sc | The pointer of smartcard module. |
0 | Receive FIFO is not empty. |
SC_STATUS_RXEMPTY_Msk | Receive FIFO is empty. |
When the last byte of Rx buffer has been read by CPU, hardware sets RXEMPTY(SC_STATUS[1]) high. It will be cleared when SC receives any new data.
#define SCUART_GET_RX_FULL | ( | sc | ) |
Get RX FIFO full flag status from register.
[in] | sc | The pointer of smartcard module. |
0 | Receive FIFO is not full. |
SC_STATUS_TXFULL_Msk | Receive FIFO is full. |
RXFULLF(SC_STATUS[2]) is set when RX pointer is equal to 4, otherwise it is cleared by hardware.
#define SCUART_GET_TX_EMPTY | ( | sc | ) |
Get TX FIFO empty flag status from register.
[in] | sc | The pointer of smartcard module. |
0 | Transmit FIFO is not empty. |
SC_STATUS_TXEMPTY_Msk | Transmit FIFO is empty. |
When the last byte of TX buffer has been transferred to Transmitter Shift Register, hardware sets TXEMPTY bit (SC_STATUS[9]) high. It will be cleared when writing data into DAT (SC_DAT[7:0]).
#define SCUART_GET_TX_FULL | ( | sc | ) |
Get TX FIFO full flag status from register.
[in] | sc | The pointer of smartcard module. |
0 | Transmit FIFO is not full. |
SC_STATUS_TXFULL_Msk | Transmit FIFO is full. |
TXFULL(SC_STATUS[10]) is set when TX pointer is equal to 4, otherwise is cleared by hardware.
#define SCUART_IS_RX_FULL | ( | sc | ) |
Check specified smartcard port receive FIFO is full or not.
[in] | sc | The pointer of smartcard module. |
0 | Receive FIFO is not full. |
1 | Receive FIFO is full. |
RXFULLF(SC_STATUS[2]) is set when RX pointer is equal to 4, otherwise it is cleared by hardware.
#define SCUART_IS_RX_READY | ( | sc | ) |
Check if receive data number in FIFO reach FIFO trigger level or not.
[in] | sc | The pointer of smartcard module. |
0 | The number of bytes in receive FIFO is less than trigger level. |
1 | The number of bytes in receive FIFO equals or larger than trigger level. |
RDAIF(SC_INTSTS[0]) is used for received data reaching trigger level RXTRGLV (SC_CTL[7:6]) interrupt status flag.
#define SCUART_IS_TX_EMPTY | ( | sc | ) |
Check specified smartcard port transmission is over.
[in] | sc | The pointer of smartcard module. |
0 | Transmit is not complete. |
1 | Transmit complete. |
TXACT (SC_STATUS[31]) is set by hardware when TX transfer is in active and the STOP bit of the last byte has been transmitted.
#define SCUART_IS_TX_FULL | ( | sc | ) |
Check specified smartcard port transmit FIFO is full or not.
[in] | sc | The pointer of smartcard module. |
0 | Transmit FIFO is not full. |
1 | Transmit FIFO is full. |
TXFULL(SC_STATUS[10]) indicates TX buffer full or not. This is set when TX pointer is equal to 4, otherwise is cleared by hardware.
#define SCUART_READ | ( | sc | ) |
#define SCUART_WAIT_TX_EMPTY | ( | sc | ) |
Wait specified smartcard port transmission complete.
[in] | sc | The pointer of smartcard module. |
TXACT (SC_STATUS[31]) is cleared automatically when TX transfer is finished or the last byte transmission has completed.
#define SCUART_WRITE | ( | sc, | |
u8Data | |||
) |
void SCUART_Close | ( | SC_T * | sc | ) |
HIDDEN_SYMBOLS uint32_t SCUART_Open | ( | SC_T * | sc, |
uint32_t | u32baudrate | ||
) |
Enable smartcard uart interface.
[in] | sc | The pointer of smartcard module. |
[in] | u32baudrate | Target baudrate of smartcard module. |
This function use to enable smartcard module UART mode and set baudrate.
uint32_t SCUART_Read | ( | SC_T * | sc, |
uint8_t * | pu8RxBuf, | ||
uint32_t | u32ReadBytes | ||
) |
Read data from smartcard UART interface.
[in] | sc | The pointer of smartcard module. |
[in] | pu8RxBuf | The buffer to store receive the data. |
[in] | u32ReadBytes | Target number of characters to receive. |
The function is used to read Rx data from RX FIFO.
uint32_t SCUART_SetLineConfig | ( | SC_T * | sc, |
uint32_t | u32Baudrate, | ||
uint32_t | u32DataWidth, | ||
uint32_t | u32Parity, | ||
uint32_t | u32StopBits | ||
) |
This function use to config smartcard UART mode line setting.
[in] | sc | The pointer of smartcard module. |
[in] | u32Baudrate | Target baudrate of smartcard module. If this value is 0, UART baudrate will not change. |
[in] | u32DataWidth | The data length, could be: |
[in] | u32Parity | The parity setting, could be: |
[in] | u32StopBits | The stop bit length, could be: |
Smartcard UART mode is operated in LIN data frame.
void SCUART_SetTimeoutCnt | ( | SC_T * | sc, |
uint32_t | u32TOC | ||
) |
This function use to set receive timeout count.
[in] | sc | The pointer of smartcard module. |
[in] | u32TOC | Rx timeout counter, using baudrate as counter unit. Valid range are 0~0x1FF, set this value to 0 will disable timeout counter. |
The time-out counter resets and starts counting whenever the RX buffer received a new data word. Once the counter decrease to 1 and no new data is received or CPU does not read any data from FIFO, a receiver time-out interrupt will be generated.
void SCUART_Write | ( | SC_T * | sc, |
uint8_t * | pu8TxBuf, | ||
uint32_t | u32WriteBytes | ||
) |
Write data to smartcard UART interface.
[in] | sc | The pointer of smartcard module. |
[in] | pu8TxBuf | The buffer containing data to send to transmit FIFO. |
[in] | u32WriteBytes | Number of data to send. |
This function is to write data into transmit FIFO to send data out.