NANO102/112 BSP V3.03.003
The Board Support Package for Nano102/112 Series
sc.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __SC_H__
13#define __SC_H__
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
20
32#define SC_INTERFACE_NUM 2
33#define SC_PIN_STATE_HIGH 1
34#define SC_PIN_STATE_LOW 0
35#define SC_PIN_STATE_IGNORE 0xFFFFFFFF
36#define SC_CLK_ON 1
37#define SC_CLK_OFF 0
39#define SC_TMR_MODE_0 (0ul << SC_TMR0_MODE_Pos)
40#define SC_TMR_MODE_1 (1ul << SC_TMR0_MODE_Pos)
41#define SC_TMR_MODE_2 (2ul << SC_TMR0_MODE_Pos)
42#define SC_TMR_MODE_3 (3ul << SC_TMR0_MODE_Pos)
43#define SC_TMR_MODE_4 (4ul << SC_TMR0_MODE_Pos)
44#define SC_TMR_MODE_5 (5ul << SC_TMR0_MODE_Pos)
45#define SC_TMR_MODE_6 (6ul << SC_TMR0_MODE_Pos)
46#define SC_TMR_MODE_7 (7ul << SC_TMR0_MODE_Pos)
47#define SC_TMR_MODE_8 (8ul << SC_TMR0_MODE_Pos)
48#define SC_TMR_MODE_F (0xF << SC_TMR0_MODE_Pos) /* end of group NANO1X2_SC_EXPORTED_CONSTANTS */
52
53
76#define SC_ENABLE_INT(sc, u32Mask) ((sc)->IER |= (u32Mask))
77
96#define SC_DISABLE_INT(sc, u32Mask) ((sc)->IER &= ~(u32Mask))
97
105#define SC_SET_VCC_PIN(sc, u32State) \
106 do {\
107 if(u32State)\
108 (sc)->PINCSR |= SC_PINCSR_POW_EN_Msk;\
109 else\
110 (sc)->PINCSR &= ~SC_PINCSR_POW_EN_Msk;\
111 }while(0)
112
113
121#define SC_SET_CLK_PIN(sc, u32OnOff)\
122 do {\
123 if(u32OnOff)\
124 (sc)->PINCSR |= SC_PINCSR_CLK_KEEP_Msk;\
125 else\
126 (sc)->PINCSR &= ~(SC_PINCSR_CLK_KEEP_Msk);\
127 }while(0)
128
136#define SC_SET_IO_PIN(sc, u32State)\
137 do {\
138 if(u32State)\
139 (sc)->PINCSR |= SC_PINCSR_SC_DATA_O_Msk;\
140 else\
141 (sc)->PINCSR &= ~SC_PINCSR_SC_DATA_O_Msk;\
142 }while(0)
143
151#define SC_SET_RST_PIN(sc, u32State)\
152 do {\
153 if(u32State)\
154 (sc)->PINCSR |= SC_PINCSR_SC_RST_Msk;\
155 else\
156 (sc)->PINCSR &= ~SC_PINCSR_SC_RST_Msk;\
157 }while(0)
158
165#define SC_READ(sc) ((char)((sc)->RBR))
166
174#define SC_WRITE(sc, u8Data) ((sc)->THR = (u8Data))
175
184#define SC_SET_STOP_BIT_LEN(sc, u32Len) ((sc)->CTL = ((sc)->CTL & ~SC_CTL_SLEN_Msk) | (u32Len == 1 ? SC_CTL_SLEN_Msk : 0))
185
192__STATIC_INLINE void SC_SetTxRetry(SC_T *sc, uint32_t u32Count)
193{
194 // Retry count must set while enable bit disabled, so disable it first
196
197 if(u32Count != 0) {
198 sc->CTL |= ((u32Count - 1) << SC_CTL_TX_ERETRY_Pos) | SC_CTL_TX_ERETRY_EN_Msk;
199 }
200}
201
208__STATIC_INLINE void SC_SetRxRetry(SC_T *sc, uint32_t u32Count)
209{
210 // Retry count must set while enable bit disabled, so disable it first
212
213 if(u32Count != 0) {
214 sc->CTL |= ((u32Count - 1) << SC_CTL_RX_ERETRY_Pos) | SC_CTL_RX_ERETRY_EN_Msk;
215 }
216}
217
218
219uint32_t SC_IsCardInserted(SC_T *sc);
220void SC_ClearFIFO(SC_T *sc);
221void SC_Close(SC_T *sc);
222void SC_Open(SC_T *sc, uint32_t u32CardDet, uint32_t u32PWR);
223void SC_ResetReader(SC_T *sc);
224void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT);
225void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT);
226void SC_StopAllTimer(SC_T *sc);
227void SC_StartTimer(SC_T *sc, uint32_t u32TimerNum, uint32_t u32Mode, uint32_t u32ETUCount);
228void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum);
229
230 /* end of group NANO1X2_SC_EXPORTED_FUNCTIONS */
232 /* end of group NANO1X2_SC_Driver */
234 /* end of group NANO1X2_Device_Driver */
236
237#ifdef __cplusplus
238}
239#endif
240
241#endif //__SC_H__
242
243/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
#define SC_CTL_TX_ERETRY_EN_Msk
#define SC_CTL_RX_ERETRY_EN_Msk
#define SC_CTL_TX_ERETRY_Pos
#define SC_CTL_TX_ERETRY_Msk
#define SC_CTL_RX_ERETRY_Pos
#define SC_CTL_RX_ERETRY_Msk
void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT)
This function block guard time (BGT) of specified smartcard module.
Definition: sc.c:174
void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT)
This function character guard time (CGT) of specified smartcard module.
Definition: sc.c:185
void SC_ResetReader(SC_T *sc)
This function reset specified smartcard module to its default state for activate smartcard.
Definition: sc.c:119
void SC_Open(SC_T *sc, uint32_t u32CardDet, uint32_t u32PWR)
This function initialized smartcard module.
Definition: sc.c:91
void SC_StopAllTimer(SC_T *sc)
This function stop all smartcard timer of specified smartcard module.
Definition: sc.c:197
uint32_t SC_IsCardInserted(SC_T *sc)
This function indicates specified smartcard slot status.
Definition: sc.c:40
void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum)
This function stop a smartcard timer of specified smartcard module.
Definition: sc.c:251
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.
Definition: sc.c:223
__STATIC_INLINE void SC_SetRxRetry(SC_T *sc, uint32_t u32Count)
Enable/Disable Rx error retry, and set Rx error retry count.
Definition: sc.h:208
void SC_ClearFIFO(SC_T *sc)
This function reset both transmit and receive FIFO of specified smartcard module.
Definition: sc.c:61
__STATIC_INLINE void SC_SetTxRetry(SC_T *sc, uint32_t u32Count)
Enable/Disable Tx error retry, and set Tx error retry count.
Definition: sc.h:192
void SC_Close(SC_T *sc)
This function disable specified smartcard module.
Definition: sc.c:71
__IO uint32_t CTL