| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

sclib.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __SCLIB_H__
13#define __SCLIB_H__
14
15#include "NUC472_442.h"
16
17#ifndef __WEAK
18 #define __WEAK __attribute__((weak))
19#endif
20
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38
39#define SCLIB_MAX_ATR_LEN 32
40#define SCLIB_MIN_ATR_LEN 2
41
42// Protocol
43#define SCLIB_PROTOCOL_UNDEFINED 0x00000000
44#define SCLIB_PROTOCOL_T0 0x00000001
45#define SCLIB_PROTOCOL_T1 0x00000002
46
47#define SCLIB_SUCCESS 0x00000000
48// error code generate by interrupt handler
49#define SCLIB_ERR_CARD_REMOVED 0x00000001
50#define SCLIB_ERR_OVER_RUN 0x00000002
51#define SCLIB_ERR_PARITY_ERROR 0x00000003
52#define SCLIB_ERR_NO_STOP 0x00000004
53#define SCLIB_ERR_SILENT_BYTE 0x00000005
54//#define SCLIB_ERR_CMD 0x00000006
55//#define SCLIB_ERR_UNSUPPORTEDCARD 0x00000007
56#define SCLIB_ERR_READ 0x00000008
57#define SCLIB_ERR_WRITE 0x00000009
58#define SCLIB_ERR_TIME0OUT 0x0000000A
59#define SCLIB_ERR_TIME1OUT 0x0000000B
60#define SCLIB_ERR_TIME2OUT 0x0000000C
61#define SCLIB_ERR_AUTOCONVENTION 0x0000000D
62#define SCLIB_ERR_CLOCK 0x0000000E
63//#define SCLIB_ERR_BGTIMEOUT 0x0000000E
64// error code generate while parsing ATR and process PPS
65#define SCLIB_ERR_ATR_UNRECOGNIZED 0x00001001
66#define SCLIB_ERR_ATR_INVALID_PARAM 0x00001002
67#define SCLIB_ERR_ATR_INVALID_TCK 0x00001003
68#define SCLIB_ERR_PPS 0x00001004
69// error code for T=1 protocol
70//#define SCLIB_ERR_T1_PARITY 0x00002001 ///< T=1 Parity Error Notice
71//#define SCLIB_ERR_T1_ICC 0x00002002 ///< ICC communication error
72#define SCLIB_ERR_T1_PROTOCOL 0x00002003
73#define SCLIB_ERR_T1_ABORT_RECEIVED 0x00002004
74#define SCLIB_ERR_T1_RESYNCH_RECEIVED 0x00002005
75#define SCLIB_ERR_T1_VPP_ERROR_RECEIVED 0x00002006
76#define SCLIB_ERR_T1_WTXRES_RECEIVED 0x00002007
77#define SCLIB_ERR_T1_IFSRES_RECEIVED 0x00002008
78#define SCLIB_ERR_T1_ABORTRES_RECEIVED 0x00002009
79#define SCLIB_ERR_T1_CHECKSUM 0x0000200A
80
81// error code for T=0 protocol
82#define SCLIB_ERR_T0_PROTOCOL 0x00003003
83
84// error code indicates application control flow error
85#define SCLIB_ERR_DEACTIVE 0x0000F001
86#define SCLIB_ERR_CARDBUSY 0x0000F002
87 /* end of group NUC472_442_SCLIB_EXPORTED_CONSTANTS */
89
97 typedef struct
98{
99 uint32_t T;
100 uint32_t ATR_Len;
101 uint8_t ATR_Buf[SCLIB_MAX_ATR_LEN];
102} SCLIB_CARD_INFO_T;
103 /* end of group NUC472_442_SCLIB_EXPORTED_STRUCTS */
105
124int32_t SCLIB_Activate(uint32_t num, uint32_t u32EMVCheck);
125
143int32_t SCLIB_ActivateDelay(uint32_t num, uint32_t u32EMVCheck, uint32_t u32Delay);
144
145
146
154int32_t SCLIB_ColdReset(uint32_t num);
155
163int32_t SCLIB_WarmReset(uint32_t num);
164
170 void SCLIB_Deactivate(uint32_t num);
171
181int32_t SCLIB_GetCardInfo(uint32_t num, SCLIB_CARD_INFO_T *s_info);
182
196int32_t SCLIB_StartTransmission(uint32_t num, uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *rspBuf, uint32_t *rspLen);
197
209int32_t SCLIB_SetIFSD(uint32_t num, uint8_t size);
210
211
221#if defined (__GNUC__) && !defined(__ARMCC_VERSION)
222void SCLIB_RequestTimeExtension () __attribute__ ((weak));
223void SCLIB_RequestTimeExtension(uint32_t u32Protocol);
224#else
225__WEAK void SCLIB_RequestTimeExtension(uint32_t u32Protocol);
226#endif
227
236uint32_t SCLIB_CheckCDEvent(uint32_t num);
237
246uint32_t SCLIB_CheckTimeOutEvent(uint32_t num);
247
256uint32_t SCLIB_CheckTxRxEvent(uint32_t num);
257
266uint32_t SCLIB_CheckErrorEvent(uint32_t num);
267
268
269#ifdef __cplusplus
270}
271#endif
272
273#endif //__SCLIB_H__
274 /* end of group NUC472_442_SCLIB_EXPORTED_FUNCTIONS */
276 /* end of group NUC472_442_SCLIB */
278 /* end of group NUC472_442_Library */
280
281/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
__attribute__
void *__dso_handle __attribute__((weak))
Definition: _syscalls.c:35
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
SCLIB_MAX_ATR_LEN
#define SCLIB_MAX_ATR_LEN
Max ATR length. ISO-7816 8.2.1.
Definition: sclib.h:39
SCLIB_CARD_INFO_T::T
uint32_t T
Protocol, ether SCLIB_PROTOCOL_T0 or SCLIB_PROTOCOL_T1.
Definition: sclib.h:99
SCLIB_SetIFSD
int32_t SCLIB_SetIFSD(uint32_t num, uint8_t size)
Set interface device max information field size (IFSD)
SCLIB_CheckErrorEvent
uint32_t SCLIB_CheckErrorEvent(uint32_t num)
Process error event in IRQ handler.
SCLIB_CheckCDEvent
uint32_t SCLIB_CheckCDEvent(uint32_t num)
Process card detect event in IRQ handler.
SCLIB_ActivateDelay
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.
SCLIB_RequestTimeExtension
__WEAK void SCLIB_RequestTimeExtension(uint32_t u32Protocol)
A callback called by library while smartcard request for a time extension.
SCLIB_Deactivate
void SCLIB_Deactivate(uint32_t num)
Deactivate a smartcard.
SCLIB_Activate
int32_t SCLIB_Activate(uint32_t num, uint32_t u32EMVCheck)
Activate a smartcard.
SCLIB_GetCardInfo
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.
SCLIB_StartTransmission
int32_t SCLIB_StartTransmission(uint32_t num, uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *rspBuf, uint32_t *rspLen)
Start a smartcard transmission.
SCLIB_CheckTxRxEvent
uint32_t SCLIB_CheckTxRxEvent(uint32_t num)
Process card transmission event in IRQ handler.
SCLIB_WarmReset
int32_t SCLIB_WarmReset(uint32_t num)
Warm reset a smartcard.
SCLIB_ColdReset
int32_t SCLIB_ColdReset(uint32_t num)
Cold reset a smartcard.
SCLIB_CARD_INFO_T::ATR_Len
uint32_t ATR_Len
ATR length, between SCLIB_MAX_ATR_LEN and SCLIB_MIN_ATR_LEN.
Definition: sclib.h:100
SCLIB_CheckTimeOutEvent
uint32_t SCLIB_CheckTimeOutEvent(uint32_t num)
Process time out event in IRQ handler.
__WEAK
#define __WEAK
Definition: sclib.h:18
SCLIB_CARD_INFO_T
A structure holds smartcard information.
Definition: sclib.h:98