| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN Series

Macros | Functions
SCUART Exported Functions
NANO100 Device Driver » SCUART Driver » SCUART Exported Constants
Collaboration diagram for SCUART Exported Functions:

## 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)
| The function is used to disable smartcard interface UART mode. More...
uint32_t | SCUART_Open (SC_T *sc, uint32_t u32baudrate)
| This function use to enable smartcard module UART mode and set baudrate. More...
uint32_t | SCUART_Read (SC_T *sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
| The function is used to read Rx data from RX FIFO. 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)
| This function is to write data into transmit FIFO to send data out. More...

## Detailed Description

## Macro Definition Documentation

## ◆ SCUART_CLR_ERR_FLAG

#define SCUART_CLR_ERR_FLAG | ( |  | sc,
|  |  | u32Mask
| ) |  |

Clear specified receive error flag/status.

Parameters

  [in] | sc | The base address of smartcard module
  [in] | u32Mask | Receive error flag/status to clear, combination following values SC_TRSR_RX_EPA_F_Msk SC_TRSR_RX_EFR_F_Msk SC_TRSR_RX_EBR_F_Msk

Returns
  None

Definition at line 240 of file scuart.h.

## ◆ SCUART_CLR_INT_FLAG

#define SCUART_CLR_INT_FLAG | ( |  | sc,
|  |  | u32Type
| ) |  |

Clear specified interrupt flag/status.

Parameters

  [in] | sc | The base address of smartcard module
  [in] | u32Type | Interrupt flag/status to clear, could be the combination of following values SC_ISR_RTMR_IS_Msk SC_ISR_TERR_IS_Msk SC_ISR_TBE_IS_Msk

Returns
  None

Definition at line 217 of file scuart.h.

## ◆ SCUART_DISABLE_INT

#define SCUART_DISABLE_INT | ( |  | sc,
|  |  | u32Mask
| ) |  |

Disable specified interrupts.

Parameters

  [in] | sc | The base address of smartcard module
  [in] | u32Mask | Interrupt masks to disable, a combination of following bits SC_IER_RTMR_IE_Msk SC_IER_TERR_IE_Msk SC_IER_TBE_IE_Msk SC_IER_RDA_IE_Msk

Returns
  None

Definition at line 190 of file scuart.h.

## ◆ SCUART_ENABLE_INT

#define SCUART_ENABLE_INT | ( |  | sc,
|  |  | u32Mask
| ) |  |

Enable specified interrupts.

Parameters

  [in] | sc | The base address of smartcard module
  [in] | u32Mask | Interrupt masks to enable, a combination of following bits SC_IER_RTMR_IE_Msk SC_IER_TERR_IE_Msk SC_IER_TBE_IE_Msk SC_IER_RDA_IE_Msk

Returns
  None

Definition at line 177 of file scuart.h.

## ◆ SCUART_GET_ERR_FLAG

#define SCUART_GET_ERR_FLAG | ( |  | sc | ) |

Get receive error flag/status.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Current receive error status, could one of following errors:

Return values

  SC_TRSR_RX_EPA_F_Msk | Parity error
  SC_TRSR_RX_EFR_F_Msk | Frame error
  SC_TRSR_RX_EBR_F_Msk | Break error

Definition at line 228 of file scuart.h.

## ◆ SCUART_GET_INT_FLAG

#define SCUART_GET_INT_FLAG | ( |  | sc,
|  |  | u32Type
| ) |  |

Get specified interrupt flag/status.

Parameters

  [in] | sc | The base address of smartcard module
  [in] | u32Type | Interrupt flag/status to check, could be one of following value SC_ISR_RTMR_IS_Msk SC_ISR_TERR_IS_Msk SC_ISR_TBE_IS_Msk SC_ISR_RDA_IS_Msk

Returns
  The status of specified interrupt

Return values

  0 | Specified interrupt does not happened
  1 | Specified interrupt happened

Definition at line 205 of file scuart.h.

## ◆ SCUART_GET_RX_EMPTY

#define SCUART_GET_RX_EMPTY | ( |  | sc | ) |

Get RX FIFO empty flag status from register.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Receive FIFO empty status

Return values

  0 | Receive FIFO is not empty
  SC_TRSR_RX_EMPTY_F_Msk | Receive FIFO is empty

Definition at line 130 of file scuart.h.

## ◆ SCUART_GET_RX_FULL

#define SCUART_GET_RX_FULL | ( |  | sc | ) |

Get RX FIFO full flag status from register.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Receive FIFO full status

Return values

  0 | Receive FIFO is not full
  SC_TRSR_TX_FULL_F_Msk | Receive FIFO is full

Definition at line 141 of file scuart.h.

## ◆ SCUART_GET_TX_EMPTY

#define SCUART_GET_TX_EMPTY | ( |  | sc | ) |

Get TX FIFO empty flag status from register.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Transmit FIFO empty status

Return values

  0 | Transmit FIFO is not empty
  SC_TRSR_TX_EMPTY_F_Msk | Transmit FIFO is empty

Definition at line 70 of file scuart.h.

## ◆ SCUART_GET_TX_FULL

#define SCUART_GET_TX_FULL | ( |  | sc | ) |

Get TX FIFO full flag status from register.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Transmit FIFO full status

Return values

  0 | Transmit FIFO is not full
  SC_TRSR_TX_FULL_F_Msk | Transmit FIFO is full

Definition at line 80 of file scuart.h.

## ◆ SCUART_IS_RX_FULL

#define SCUART_IS_RX_FULL | ( |  | sc | ) |

Check specified smartcard port receive FIFO is full or not.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Receive FIFO full status

Return values

  0 | Receive FIFO is not full
  1 | Receive FIFO is full

Definition at line 162 of file scuart.h.

## ◆ SCUART_IS_RX_READY

#define SCUART_IS_RX_READY | ( |  | sc | ) |

Check if receive data number in FIFO reach FIFO trigger level or not.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Receive FIFO data status

Return values

  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

Note
  If receive trigger level is not 1 byte, this macro return 0 does not necessary indicates there is no data in FIFO

Definition at line 152 of file scuart.h.

## ◆ SCUART_IS_TX_EMPTY

#define SCUART_IS_TX_EMPTY | ( |  | sc | ) |

Check specified smartcard port transmission is over.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Transmit complete status

Return values

  0 | Transmit is not complete
  1 | Transmit complete

Definition at line 109 of file scuart.h.

## ◆ SCUART_IS_TX_FULL

#define SCUART_IS_TX_FULL | ( |  | sc | ) |

Check specified smartcard port transmit FIFO is full or not.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  Transmit FIFO full status

Return values

  0 | Transmit FIFO is not full
  1 | Transmit FIFO is full

Definition at line 99 of file scuart.h.

## ◆ SCUART_READ

#define SCUART_READ | ( |  | sc | ) |

Read Rx data register.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  The oldest data byte in RX FIFO

Definition at line 120 of file scuart.h.

## ◆ SCUART_WAIT_TX_EMPTY

#define SCUART_WAIT_TX_EMPTY | ( |  | sc | ) |

Wait specified smartcard port transmission complete.

Parameters

  [in] | sc | The base address of smartcard module

Returns
  None

Note
  This Macro blocks until transmit complete.

Definition at line 89 of file scuart.h.

## ◆ SCUART_WRITE

#define SCUART_WRITE | ( |  | sc,
|  |  | u8Data
| ) |  |

Write Data to Tx data register.

Parameters

  [in] | sc | The base address of smartcard module.
  [in] | u8Data | Data byte to transmit

Returns
  None

Definition at line 60 of file scuart.h.

## Function Documentation

## ◆ SCUART_Close()

void SCUART_Close | ( | SC_T * | sc | ) |

The function is used to disable smartcard interface UART mode.

Parameters

  sc | The base address of smartcard module.

Returns
  None

Definition at line 32 of file scuart.c.

## ◆ SCUART_Open()

HIDDEN_SYMBOLS uint32_t SCUART_Open | ( | SC_T * | sc,
|  | uint32_t | u32baudrate
| ) |  |

This function use to enable smartcard module UART mode and set baudrate.

Parameters

  [in] | sc | The base address of smartcard module.
  [in] | u32baudrate | Target baudrate of smartcard module.

Returns
  Actual baudrate of smartcard mode

This function configures character width to 8 bits, 1 stop bit, and no parity. And can use SCUART_SetLineConfig function to update these settings The baudrate clock source comes from SC_CLK/SC_DIV, where SC_CLK is controlled by SC_S(CLKSEL2[19:18]) SC_DIV is controlled by SC0_N(CLKDIV0[31:28]), SC1_N(CLKDIV1[3:0]), and SC2_N(CLKDIV1[7:4]). Since the baudrate divider is 12-bit wide and must be larger than 4, (clock source / baudrate) must be larger or equal to 5 and smaller or equal to 4096. Otherwise this function cannot configure SCUART to work with target baudrate.

Definition at line 85 of file scuart.c.

## ◆ SCUART_Read()

uint32_t SCUART_Read | ( | SC_T * | sc,
|  | uint8_t * | pu8RxBuf,
|  | uint32_t | u32ReadBytes
| ) |  |

The function is used to read Rx data from RX FIFO.

Parameters

  [in] | sc | The base address of smartcard module.
  [in] | pu8RxBuf | The buffer to store receive the data
  [in] | u32ReadBytes | Target number of characters to receive

Returns
  Actual character number reads to buffer

Note
  This function does not block and return immediately if there's no data available

Definition at line 107 of file scuart.c.

## ◆ SCUART_SetLineConfig()

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.

Parameters

  [in] | sc | The base address 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 SCUART_CHAR_LEN_5 SCUART_CHAR_LEN_6 SCUART_CHAR_LEN_7 SCUART_CHAR_LEN_8
  [in] | u32Parity | The parity setting, could be SCUART_PARITY_NONE SCUART_PARITY_ODD SCUART_PARITY_EVEN
  [in] | u32StopBits | The stop bit length, could be SCUART_STOP_BIT_1 SCUART_STOP_BIT_2

Returns
  Actual baudrate of smartcard

The baudrate clock source comes from SC_CLK/SC_DIV, where SC_CLK is controlled by SC_S(CLKSEL2[19:18]) SC_DIV is controlled by SC0_N(CLKDIV0[31:28]), SC1_N(CLKDIV1[3:0]), and SC2_N(CLKDIV1[7:4]). Since the baudrate divider is 12-bit wide and must be larger than 4, (clock source / baudrate) must be larger or equal to 5 and smaller or equal to 4096. Otherwise this function cannot configure SCUART to work with target baudrate.

Definition at line 147 of file scuart.c.

## ◆ SCUART_SetTimeoutCnt()

void SCUART_SetTimeoutCnt | ( | SC_T * | sc,
|  | uint32_t | u32TOC
| ) |  |

This function use to set receive timeout count.

Parameters

  [in] | sc | The base address 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

Returns
  None

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.

Definition at line 179 of file scuart.c.

## ◆ SCUART_Write()

void SCUART_Write | ( | SC_T * | sc,
|  | uint8_t * | pu8TxBuf,
|  | uint32_t | u32WriteBytes
| ) |  |

This function is to write data into transmit FIFO to send data out.

Parameters

  [in] | sc | The base address of smartcard module.
  [in] | pu8TxBuf | The buffer containing data to send to transmit FIFO.
  [in] | u32WriteBytes | Number of data to send.

Returns
  None

Note
  This function blocks until all data write into FIFO

Definition at line 193 of file scuart.c.