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

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

## Macros
#define | SC_ENABLE_INT(sc, u32Mask)
| This macro enable smartcard interrupt. More...
#define | SC_DISABLE_INT(sc, u32Mask)
| This macro disable smartcard interrupt. More...
#define | SC_SET_VCC_PIN(sc, u32State)
| This macro set VCC pin state of smartcard interface. More...
#define | SC_SET_CLK_PIN(sc, u32OnOff)
| This macro turns CLK output on or off. More...
#define | SC_SET_IO_PIN(sc, u32State)
| This macro set I/O pin state of smartcard interface. More...
#define | SC_SET_RST_PIN(sc, u32State)
| This macro set RST pin state of smartcard interface. More...
#define | SC_READ(sc)
| This macro read one byte from smartcard module receive FIFO. More...
#define | SC_WRITE(sc, u8Data)
| This macro write one byte to smartcard module transmit FIFO. More...
#define | SC_SET_STOP_BIT_LEN(sc, u32Len)
| This macro set smartcard stop bit length. More...

## Functions
__STATIC_INLINE void | SC_SetTxRetry (SC_T *sc, uint32_t u32Count)
| Enable/Disable Tx error retry, and set Tx error retry count. More...
__STATIC_INLINE void | SC_SetRxRetry (SC_T *sc, uint32_t u32Count)
| Enable/Disable Rx error retry, and set Rx error retry count. More...
uint32_t | SC_IsCardInserted (SC_T *sc)
| This function indicates specified smartcard slot status. More...
void | SC_ClearFIFO (SC_T *sc)
| This function reset both transmit and receive FIFO of specified smartcard module. More...
void | SC_Close (SC_T *sc)
| This function disable specified smartcard module. More...
void | SC_Open (SC_T *sc, uint32_t u32CD, uint32_t u32PWR)
| This function initialized smartcard module. More...
void | SC_ResetReader (SC_T *sc)
| This function reset specified smartcard module to its default state for activate smartcard. More...
void | SC_SetBlockGuardTime (SC_T *sc, uint32_t u32BGT)
| This function block guard time (BGT) of specified smartcard module. More...
void | SC_SetCharGuardTime (SC_T *sc, uint32_t u32CGT)
| This function character guard time (CGT) of specified smartcard module. More...
void | SC_StopAllTimer (SC_T *sc)
| This function stop all smartcard timer of specified smartcard module. More...
void | SC_StartTimer (SC_T *sc, uint32_t u32TimerNum, uint32_t u32Mode, uint32_t u32ETUCount)
| This function configure and start a smartcard timer of specified smartcard module. More...
void | SC_StopTimer (SC_T *sc, uint32_t u32TimerNum)
| This function stop a smartcard timer of specified smartcard module. More...

## Detailed Description

## Macro Definition Documentation

## ◆ SC_DISABLE_INT

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

This macro disable smartcard interrupt.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32Mask | Interrupt mask to be disabled. A combination of SC_IER_ACON_ERR_IE_Msk SC_IER_RTMR_IE_Msk SC_IER_INIT_IE_Msk SC_IER_CD_IE_Msk SC_IER_BGT_IE_Msk SC_IER_TMR2_IE_Msk SC_IER_TMR1_IE_Msk SC_IER_TMR0_IE_Msk SC_IER_TERR_IE_Msk SC_IER_TBE_IE_Msk SC_IER_RDA_IE_Msk

Returns
  None

Definition at line 96 of file sc.h.

## ◆ SC_ENABLE_INT

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

This macro enable smartcard interrupt.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32Mask | Interrupt mask to be enabled. A combination of SC_IER_ACON_ERR_IE_Msk SC_IER_RTMR_IE_Msk SC_IER_INIT_IE_Msk SC_IER_CD_IE_Msk SC_IER_BGT_IE_Msk SC_IER_TMR2_IE_Msk SC_IER_TMR1_IE_Msk SC_IER_TMR0_IE_Msk SC_IER_TERR_IE_Msk SC_IER_TBE_IE_Msk SC_IER_RDA_IE_Msk

Returns
  None

Definition at line 76 of file sc.h.

## ◆ SC_READ

#define SC_READ | ( |  | sc | ) |

This macro read one byte from smartcard module receive FIFO.

Parameters

  [in] | sc | Base address of smartcard module

Returns
  [in] One byte read from receive FIFO

Definition at line 189 of file sc.h.

## ◆ SC_SET_CLK_PIN

#define SC_SET_CLK_PIN | ( |  | sc,
|  |  | u32OnOff
| ) |  |

This macro turns CLK output on or off.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32OnOff | Clock on or off for selected smartcard module, valid values are SC_CLK_ON and SC_CLK_OFF

Returns
  None

Definition at line 127 of file sc.h.

## ◆ SC_SET_IO_PIN

#define SC_SET_IO_PIN | ( |  | sc,
|  |  | u32State
| ) |  |

This macro set I/O pin state of smartcard interface.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32State | Pin state of I/O pin, valid parameters are SC_PIN_STATE_HIGH and SC_PIN_STATE_LOW

Returns
  None

Definition at line 148 of file sc.h.

## ◆ SC_SET_RST_PIN

#define SC_SET_RST_PIN | ( |  | sc,
|  |  | u32State
| ) |  |

This macro set RST pin state of smartcard interface.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32State | Pin state of RST pin, valid parameters are SC_PIN_STATE_HIGH and SC_PIN_STATE_LOW

Returns
  None

Definition at line 169 of file sc.h.

## ◆ SC_SET_STOP_BIT_LEN

#define SC_SET_STOP_BIT_LEN | ( |  | sc,
|  |  | u32Len
| ) |  |

This macro set smartcard stop bit length.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32Len | Stop bit length, ether 1 or 2.

Returns
  None

Stop bit length must be 1 for T = 1 protocol and 2 for T = 0 protocol.

Definition at line 208 of file sc.h.

## ◆ SC_SET_VCC_PIN

#define SC_SET_VCC_PIN | ( |  | sc,
|  |  | u32State
| ) |  |

This macro set VCC pin state of smartcard interface.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32State | Pin state of VCC pin, valid parameters are SC_PIN_STATE_HIGH and SC_PIN_STATE_LOW

Returns
  None

Definition at line 105 of file sc.h.

## ◆ SC_WRITE

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

This macro write one byte to smartcard module transmit FIFO.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u8Data | Data to write to transmit FIFO

Returns
  None

Definition at line 198 of file sc.h.

## Function Documentation

## ◆ SC_ClearFIFO()

void SC_ClearFIFO | ( | SC_T * | sc | ) |

This function reset both transmit and receive FIFO of specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module

Returns
  None

Definition at line 63 of file sc.c.

## ◆ SC_Close()

void SC_Close | ( | SC_T * | sc | ) |

This function disable specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module

Returns
  None

Definition at line 73 of file sc.c.

## ◆ SC_IsCardInserted()

uint32_t SC_IsCardInserted | ( | SC_T * | sc | ) |

This function indicates specified smartcard slot status.

Parameters

  [in] | sc | Base address of smartcard module

Returns
  Card insert status

Return values

  TRUE | Card insert
  FALSE | Card remove

Definition at line 40 of file sc.c.

## ◆ SC_Open()

void SC_Open | ( | SC_T * | sc,
|  | uint32_t | u32CD,
|  | uint32_t | u32PWR
| ) |  |

This function initialized smartcard module.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32CD | Card detect polarity, select the CD pin state which indicates card absent. Could be SC_PIN_STATE_HIGH SC_PIN_STATE_LOW SC_PIN_STATE_IGNORE, no card detect pin, always assumes card present
  [in] | u32PWR | Power off polarity, select the PWR pin state which could set smartcard VCC to high level. Could be SC_PIN_STATE_HIGH SC_PIN_STATE_LOW

Returns
  None

Definition at line 93 of file sc.c.

## ◆ SC_ResetReader()

void SC_ResetReader | ( | SC_T * | sc | ) |

This function reset specified smartcard module to its default state for activate smartcard.

Parameters

  [in] | sc | Base address of smartcard module

Returns
  None

Definition at line 123 of file sc.c.

## ◆ SC_SetBlockGuardTime()

void SC_SetBlockGuardTime | ( | SC_T * | sc,
|  | uint32_t | u32BGT
| ) |  |

This function block guard time (BGT) of specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32BGT | Block guard time using ETU as unit, valid range are between 1 ~ 32

Returns
  None

Definition at line 180 of file sc.c.

## ◆ SC_SetCharGuardTime()

void SC_SetCharGuardTime | ( | SC_T * | sc,
|  | uint32_t | u32CGT
| ) |  |

This function character guard time (CGT) of specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32CGT | Character guard time using ETU as unit, valid range are between 11 ~ 267

Returns
  None

Definition at line 191 of file sc.c.

## ◆ SC_SetRxRetry()

__STATIC_INLINE void SC_SetRxRetry | ( | SC_T * | sc,
|  | uint32_t | u32Count
| ) |  |

Enable/Disable Rx error retry, and set Rx error retry count.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32Count | The number of times of Rx error retry count, between 0~8. 0 means disable Rx error retry

Returns
  None

Definition at line 233 of file sc.h.

## ◆ SC_SetTxRetry()

__STATIC_INLINE void SC_SetTxRetry | ( | SC_T * | sc,
|  | uint32_t | u32Count
| ) |  |

Enable/Disable Tx error retry, and set Tx error retry count.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32Count | The number of times of Tx error retry count, between 0~8. 0 means disable Tx error retry

Returns
  None

Definition at line 216 of file sc.h.

## ◆ SC_StartTimer()

void SC_StartTimer | ( | SC_T * | sc,
|  | uint32_t | u32TimerNum,
|  | uint32_t | u32Mode,
|  | uint32_t | u32ETUCount
| ) |  |

This function configure and start a smartcard timer of specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32TimerNum | Timer(s) to start. Valid values are 0, 1, 2.
  [in] | u32Mode | Timer operating mode, valid values are: SC_TMR_MODE_0 SC_TMR_MODE_1 SC_TMR_MODE_2 SC_TMR_MODE_3 SC_TMR_MODE_4 SC_TMR_MODE_5 SC_TMR_MODE_6 SC_TMR_MODE_7 SC_TMR_MODE_8 SC_TMR_MODE_F
  [in] | u32ETUCount | Timer timeout duration, ETU based. For timer 0, valid range are between 1~0x1000000ETUs. For timer 1 and timer 2, valid range are between 1 ~ 0x100 ETUs

Returns
  None

Note
  This function start the timer within smartcard module, not timer module
  Depend on the timer operating mode, timer may not start counting immediately

Definition at line 229 of file sc.c.

## ◆ SC_StopAllTimer()

void SC_StopAllTimer | ( | SC_T * | sc | ) |

This function stop all smartcard timer of specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module

Returns
  None

Note
  This function stop the timers within smartcard module, not timer module

Definition at line 203 of file sc.c.

## ◆ SC_StopTimer()

void SC_StopTimer | ( | SC_T * | sc,
|  | uint32_t | u32TimerNum
| ) |  |

This function stop a smartcard timer of specified smartcard module.

Parameters

  [in] | sc | Base address of smartcard module
  [in] | u32TimerNum | Timer(s) to stop. Valid values are 0, 1, 2.

Returns
  None

Note
  This function stop the timer within smartcard module, not timer module

Definition at line 257 of file sc.c.