M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
sc.h
Go to the documentation of this file.
1/**************************************************************************/
8#ifndef __SC_H__
9#define __SC_H__
10
11#ifdef __cplusplus
12extern "C"
13{
14#endif
15
16
28#define SC_INTERFACE_NUM 1
29#define SC_PIN_STATE_HIGH 1
30#define SC_PIN_STATE_LOW 0
31#define SC_PIN_STATE_IGNORE 0xFFFFFFFF
32#define SC_CLK_ON 1
33#define SC_CLK_OFF 0
35#define SC_TMR_MODE_0 (0ul << SC_TMRCTL0_OPMODE_Pos)
36#define SC_TMR_MODE_1 (1ul << SC_TMRCTL0_OPMODE_Pos)
37#define SC_TMR_MODE_2 (2ul << SC_TMRCTL0_OPMODE_Pos)
38#define SC_TMR_MODE_3 (3ul << SC_TMRCTL0_OPMODE_Pos)
39#define SC_TMR_MODE_4 (4ul << SC_TMRCTL0_OPMODE_Pos)
40#define SC_TMR_MODE_5 (5ul << SC_TMRCTL0_OPMODE_Pos)
41#define SC_TMR_MODE_6 (6ul << SC_TMRCTL0_OPMODE_Pos)
42#define SC_TMR_MODE_7 (7ul << SC_TMRCTL0_OPMODE_Pos)
43#define SC_TMR_MODE_8 (8ul << SC_TMRCTL0_OPMODE_Pos)
44#define SC_TMR_MODE_F (0xF << SC_TMRCTL0_OPMODE_Pos) /* end of group SC_EXPORTED_CONSTANTS */
48
49
75#define SC_ENABLE_INT(sc, u32Mask) ((sc)->INTEN |= (u32Mask))
76
98#define SC_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask))
99
110#define SC_SET_VCC_PIN(sc, u32State) \
111 do {\
112 while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\
113 if(u32State)\
114 (sc)->PINCTL |= SC_PINCTL_PWREN_Msk;\
115 else\
116 (sc)->PINCTL &= ~SC_PINCTL_PWREN_Msk;\
117 }while(0)
118
119
130#define SC_SET_CLK_PIN(sc, u32OnOff)\
131 do {\
132 while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\
133 if(u32OnOff)\
134 (sc)->PINCTL |= SC_PINCTL_CLKKEEP_Msk;\
135 else\
136 (sc)->PINCTL &= ~(SC_PINCTL_CLKKEEP_Msk);\
137 }while(0)
138
149#define SC_SET_IO_PIN(sc, u32State)\
150 do {\
151 while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\
152 if(u32State)\
153 (sc)->PINCTL |= SC_PINCTL_SCDOUT_Msk;\
154 else\
155 (sc)->PINCTL &= ~SC_PINCTL_SCDOUT_Msk;\
156 }while(0)
157
168#define SC_SET_RST_PIN(sc, u32State)\
169 do {\
170 while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\
171 if(u32State)\
172 (sc)->PINCTL |= SC_PINCTL_SCRST_Msk;\
173 else\
174 (sc)->PINCTL &= ~SC_PINCTL_SCRST_Msk;\
175 }while(0)
176
184#define SC_READ(sc) ((char)((sc)->DAT))
185
194#define SC_WRITE(sc, u8Data) ((sc)->DAT = (u8Data))
195
204#define SC_SET_STOP_BIT_LEN(sc, u32Len) ((sc)->CTL = ((sc)->CTL & ~SC_CTL_NSB_Msk) | ((u32Len) == 1 ? SC_CTL_NSB_Msk : 0))
205
213__STATIC_INLINE void SC_SetTxRetry(SC_T *sc, uint32_t u32Count)
214{
215 while((sc)->CTL & SC_CTL_SYNC_Msk);
216 if(u32Count == 0) // disable Tx error retry
217 {
218 (sc)->CTL &= ~(SC_CTL_TXRTY_Msk | SC_CTL_TXRTYEN_Msk);
219 }
220 else
221 {
222 (sc)->CTL = ((sc)->CTL & ~SC_CTL_TXRTY_Msk) | ((u32Count - 1) << SC_CTL_TXRTY_Pos) | SC_CTL_TXRTYEN_Msk;
223 }
224}
225
233__STATIC_INLINE void SC_SetRxRetry(SC_T *sc, uint32_t u32Count)
234{
235 while((sc)->CTL & SC_CTL_SYNC_Msk);
236 if(u32Count == 0) // disable Rx error retry
237 {
238 (sc)->CTL &= ~(SC_CTL_RXRTY_Msk | SC_CTL_RXRTYEN_Msk);
239 }
240 else
241 {
242 (sc)->CTL = ((sc)->CTL & ~SC_CTL_RXRTY_Msk) | ((u32Count - 1) << SC_CTL_RXRTY_Pos) | SC_CTL_RXRTYEN_Msk;
243 }
244}
245
246
247uint32_t SC_IsCardInserted(SC_T *sc);
248void SC_ClearFIFO(SC_T *sc);
249void SC_Close(SC_T *sc);
250void SC_Open(SC_T *sc, uint32_t u32CardDet, uint32_t u32PWR);
251void SC_ResetReader(SC_T *sc);
252void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT);
253void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT);
254void SC_StopAllTimer(SC_T *sc);
255void SC_StartTimer(SC_T *sc, uint32_t u32TimerNum, uint32_t u32Mode, uint32_t u32ETUCount);
256void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum);
257
258 /* end of group SC_EXPORTED_FUNCTIONS */
260 /* end of group SC_Driver */
262 /* end of group Standard_Driver */
264
265#ifdef __cplusplus
266}
267#endif
268
269#endif //__SC_H__
270
271
#define SC_CTL_TXRTYEN_Msk
Definition: M471M_R1_S.h:8558
#define SC_CTL_RXRTYEN_Msk
Definition: M471M_R1_S.h:8552
#define SC_CTL_SYNC_Msk
Definition: M471M_R1_S.h:8567
#define SC_CTL_RXRTY_Pos
Definition: M471M_R1_S.h:8548
#define SC_CTL_TXRTY_Pos
Definition: M471M_R1_S.h:8554
#define SC_CTL_RXRTY_Msk
Definition: M471M_R1_S.h:8549
#define SC_CTL_TXRTY_Msk
Definition: M471M_R1_S.h:8555
void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT)
Set Block Guard Time.
Definition: sc.c:180
void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT)
Set character guard time.
Definition: sc.c:193
void SC_ResetReader(SC_T *sc)
This function reset specified smartcard module to its default state for activate smartcard.
Definition: sc.c:130
void SC_Open(SC_T *sc, uint32_t u32CardDet, uint32_t u32PWR)
This function initialized smartcard module.
Definition: sc.c:88
void SC_StopAllTimer(SC_T *sc)
Stop all Timer counting.
Definition: sc.c:206
uint32_t SC_IsCardInserted(SC_T *sc)
This function indicates specified smartcard slot status.
Definition: sc.c:36
void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum)
Stop Timer counting.
Definition: sc.c:262
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:233
__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:233
void SC_ClearFIFO(SC_T *sc)
Reset the Tx/Rx FIFO.
Definition: sc.c:56
__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:213
void SC_Close(SC_T *sc)
This function disable specified smartcard module.
Definition: sc.c:67