M480 BSP  V3.05.001
The Board Support Package for M480 Series
sclib.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __SCLIB_H__
10 #define __SCLIB_H__
11 
12 #include "NuMicro.h"
13 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 #define SCLIB_MAX_ATR_LEN 32UL
33 #define SCLIB_MIN_ATR_LEN 2UL
35 /* Protocol */
36 #define SCLIB_PROTOCOL_UNDEFINED 0x00000000UL
37 #define SCLIB_PROTOCOL_T0 0x00000001UL
38 #define SCLIB_PROTOCOL_T1 0x00000002UL
40 #define SCLIB_SUCCESS 0x00000000UL
41 /* error code generate by interrupt handler */
42 #define SCLIB_ERR_CARD_REMOVED 0x00000001UL
43 #define SCLIB_ERR_OVER_RUN 0x00000002UL
44 #define SCLIB_ERR_PARITY_ERROR 0x00000003UL
45 #define SCLIB_ERR_NO_STOP 0x00000004UL
46 #define SCLIB_ERR_SILENT_BYTE 0x00000005UL
47 /*//#define SCLIB_ERR_CMD 0x00000006UL */
48 /*//#define SCLIB_ERR_UNSUPPORTEDCARD 0x00000007UL */
49 #define SCLIB_ERR_READ 0x00000008UL
50 #define SCLIB_ERR_WRITE 0x00000009UL
51 #define SCLIB_ERR_TIME0OUT 0x0000000AUL
52 #define SCLIB_ERR_TIME1OUT 0x0000000BUL
53 #define SCLIB_ERR_TIME2OUT 0x0000000CUL
54 #define SCLIB_ERR_AUTOCONVENTION 0x0000000DUL
55 #define SCLIB_ERR_CLOCK 0x0000000EUL
56 /*//#define SCLIB_ERR_BGTIMEOUT 0x0000000EUL */
57 /* error code generate while parsing ATR and process PPS */
58 #define SCLIB_ERR_ATR_UNRECOGNIZED 0x00001001UL
59 #define SCLIB_ERR_ATR_INVALID_PARAM 0x00001002UL
60 #define SCLIB_ERR_ATR_INVALID_TCK 0x00001003UL
61 #define SCLIB_ERR_PPS 0x00001004UL
62 /* error code for T=1 protocol */
63 /*#define SCLIB_ERR_T1_PARITY 0x00002001UL ///< T=1 Parity Error Notice */
64 /*#define SCLIB_ERR_T1_ICC 0x00002002UL ///< ICC communication error */
65 #define SCLIB_ERR_T1_PROTOCOL 0x00002003UL
66 #define SCLIB_ERR_T1_ABORT_RECEIVED 0x00002004UL
67 #define SCLIB_ERR_T1_RESYNCH_RECEIVED 0x00002005UL
68 #define SCLIB_ERR_T1_VPP_ERROR_RECEIVED 0x00002006UL
69 #define SCLIB_ERR_T1_WTXRES_RECEIVED 0x00002007UL
70 #define SCLIB_ERR_T1_IFSRES_RECEIVED 0x00002008UL
71 #define SCLIB_ERR_T1_ABORTRES_RECEIVED 0x00002009UL
72 #define SCLIB_ERR_T1_CHECKSUM 0x0000200AUL
74 /* error code for T=0 protocol */
75 #define SCLIB_ERR_T0_PROTOCOL 0x00003003UL
77 /* error code indicates application control flow error */
78 #define SCLIB_ERR_DEACTIVE 0x0000F001UL
79 #define SCLIB_ERR_CARDBUSY 0x0000F002UL
81  /* end of group SCLIB_EXPORTED_CONSTANTS */
82 
90 typedef struct
91 {
92  uint32_t T;
93  uint32_t ATR_Len;
94  uint8_t ATR_Buf[SCLIB_MAX_ATR_LEN];
96  /* end of group SCLIB_EXPORTED_STRUCTS */
98 
118 int32_t SCLIB_Activate(uint32_t num, uint32_t u32EMVCheck);
119 
138 int32_t SCLIB_ActivateDelay(uint32_t num, uint32_t u32EMVCheck, uint32_t u32Delay);
139 
140 
141 
149 int32_t SCLIB_ColdReset(uint32_t num);
150 
158 int32_t SCLIB_WarmReset(uint32_t num);
159 
165 void SCLIB_Deactivate(uint32_t num);
166 
176 int32_t SCLIB_GetCardInfo(uint32_t num, SCLIB_CARD_INFO_T *s_info);
177 
191 int32_t SCLIB_StartTransmission(uint32_t num, uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *rspBuf, uint32_t *rspLen);
192 
204 int32_t SCLIB_SetIFSD(uint32_t num, uint8_t size);
205 
206 
216 #if defined (__GNUC__)
218 void SCLIB_RequestTimeExtension(uint32_t u32Protocol);
219 #else
220 __weak void SCLIB_RequestTimeExtension(uint32_t u32Protocol);
221 #endif
222 
230 uint32_t SCLIB_CheckCDEvent(uint32_t num);
231 
240 uint32_t SCLIB_CheckTimeOutEvent(uint32_t num);
241 
250 uint32_t SCLIB_CheckTxRxEvent(uint32_t num);
251 
260 uint32_t SCLIB_CheckErrorEvent(uint32_t num);
261 
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 #endif /* __SCLIB_H__ */
268  /* end of group SCLIB_EXPORTED_FUNCTIONS */
270  /* end of group SCLIB */
272  /* end of group LIBRARY */
274 
275 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
uint32_t SCLIB_CheckTimeOutEvent(uint32_t num)
Process time out event in IRQ handler.
uint32_t SCLIB_CheckCDEvent(uint32_t num)
Process card detect event in IRQ handler.
int32_t SCLIB_GetCardInfo(uint32_t num, SCLIB_CARD_INFO_T *s_info)
Get the card information (e.g., protocol selected, ATR...) after activation success.
int32_t SCLIB_ActivateDelay(uint32_t num, uint32_t u32EMVCheck, uint32_t u32Delay)
Activate a smartcard with large delay between set VCC high and start CLK output.
int32_t SCLIB_SetIFSD(uint32_t num, uint8_t size)
Set interface device max information field size (IFSD)
uint32_t ATR_Len
Definition: sclib.h:93
NuMicro peripheral access layer header file.
int32_t SCLIB_Activate(uint32_t num, uint32_t u32EMVCheck)
Activate a smartcard.
void *__dso_handle __attribute__((weak))
Definition: _syscalls.c:35
uint32_t T
Definition: sclib.h:92
void SCLIB_Deactivate(uint32_t num)
Deactivate a smartcard.
uint32_t SCLIB_CheckErrorEvent(uint32_t num)
Process error event in IRQ handler.
__weak void SCLIB_RequestTimeExtension(uint32_t u32Protocol)
A callback called by library while smartcard request for a time extension.
A structure holds smartcard information.
Definition: sclib.h:90
#define SCLIB_MAX_ATR_LEN
Definition: sclib.h:32
int32_t SCLIB_WarmReset(uint32_t num)
Warm reset a smartcard.
int32_t SCLIB_ColdReset(uint32_t num)
Cold reset a smartcard.
uint32_t SCLIB_CheckTxRxEvent(uint32_t num)
Process card transmission event in IRQ handler.
int32_t SCLIB_StartTransmission(uint32_t num, uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *rspBuf, uint32_t *rspLen)
Start a smartcard transmission.