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

sclib.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __SCLIB_H__
13#define __SCLIB_H__
14
15#include "Nano100Series.h"
16
30#ifdef __cplusplus
31 extern "C"
32{
33#endif
34
35#define SCLIB_MAX_ATR_LEN 32
36#define SCLIB_MIN_ATR_LEN 2
37
38// Protocol
39#define SCLIB_PROTOCOL_UNDEFINED 0x00000000
40#define SCLIB_PROTOCOL_T0 0x00000001
41#define SCLIB_PROTOCOL_T1 0x00000002
42
43#define SCLIB_SUCCESS 0x00000000
44// error code generate by interrupt handler
45#define SCLIB_ERR_CARD_REMOVED 0x00000001
46#define SCLIB_ERR_OVER_RUN 0x00000002
47#define SCLIB_ERR_PARITY_ERROR 0x00000003
48#define SCLIB_ERR_NO_STOP 0x00000004
49#define SCLIB_ERR_SILENT_BYTE 0x00000005
50#define SCLIB_ERR_CMD 0x00000006
51#define SCLIB_ERR_UNSUPPORTEDCARD 0x00000007
52#define SCLIB_ERR_READ 0x00000008
53#define SCLIB_ERR_WRITE 0x00000009
54#define SCLIB_ERR_TIME0OUT 0x0000000A
55#define SCLIB_ERR_TIME1OUT 0x0000000B
56#define SCLIB_ERR_TIME2OUT 0x0000000C
57#define SCLIB_ERR_AUTOCONVENTION 0x0000000D
58#define SCLIB_ERR_CLOCK 0x0000000E
59#define SCLIB_ERR_BGTIMEOUT 0x0000000E
60// error code generate while parsing ATR and process PPS
61#define SCLIB_ERR_ATR_UNRECOGNIZED 0x00001001
62#define SCLIB_ERR_ATR_INVALID_PARAM 0x00001002
63#define SCLIB_ERR_ATR_INVALID_TCK 0x00001003
64#define SCLIB_ERR_PPS 0x00001004
65// error code for T=1 protocol
66#define SCLIB_ERR_T1_PARITY 0x00002001
67#define SCLIB_ERR_T1_ICC 0x00002002
68#define SCLIB_ERR_T1_PROTOCOL 0x00002003
69#define SCLIB_ERR_T1_ABORT_RECEIVED 0x00002004
70#define SCLIB_ERR_T1_RESYNCH_RECEIVED 0x00002005
71#define SCLIB_ERR_T1_VPP_ERROR_RECEIVED 0x00002006
72#define SCLIB_ERR_T1_WTXRES_RECEIVED 0x00002007
73#define SCLIB_ERR_T1_IFSRES_RECEIVED 0x00002008
74#define SCLIB_ERR_T1_ABORTRES_RECEIVED 0x00002009
75#define SCLIB_ERR_T1_CHECKSUM 0x0000200A
76
77// error code for T=0 protocol
78#define SCLIB_ERR_T0_PROTOCOL 0x00003003
79
80// error code indicates application control flow error
81#define SCLIB_ERR_DEACTIVE 0x0000F001
82#define SCLIB_ERR_CARDBUSY 0x0000F002
83 /* end of group NANO100_SCLIB_EXPORTED_CONSTANTS */
85
93 typedef struct
94{
95 uint32_t T;
96 uint32_t ATR_Len;
97 uint8_t ATR_Buf[SCLIB_MAX_ATR_LEN];
98} SCLIB_CARD_INFO_T;
99
103 typedef struct
104{
105 uint8_t Fi;
106 uint8_t Di;
107 uint8_t conv;
108 uint8_t chksum;
109 uint8_t GT;
110 uint8_t WI;
111 uint8_t BWI;
112 uint8_t CWI;
113 uint8_t clkStop;
114 uint8_t IFSC;
115 uint8_t NAD;
116} SCLIB_CARD_ATTRIB_T;
117
118 /* end of group NUC400_SCLIB_EXPORTED_STRUCTS */
120
140int32_t SCLIB_Activate(uint32_t num, uint32_t u32EMVCheck);
141
159int32_t SCLIB_ActivateDelay(uint32_t num, uint32_t u32EMVCheck, uint32_t u32Delay);
160
168int32_t SCLIB_ColdReset(uint32_t num);
169
177int32_t SCLIB_WarmReset(uint32_t num);
178
184 void SCLIB_Deactivate(uint32_t num);
185
195int32_t SCLIB_GetCardInfo(uint32_t num, SCLIB_CARD_INFO_T *s_info);
196
197
207int32_t SCLIB_GetCardAttrib(uint32_t num, SCLIB_CARD_ATTRIB_T *s_attrib);
208
222int32_t SCLIB_StartTransmission(uint32_t num, uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *rspBuf, uint32_t *rspLen);
223
235int32_t SCLIB_SetIFSD(uint32_t num, uint8_t size);
236
237
247#if defined (__GNUC__) && !defined (__ARMCC_VERSION)
248 void SCLIB_RequestTimeExtension () __attribute__ ((weak));
249 void SCLIB_RequestTimeExtension(uint32_t u32Protocol);
250#else
251__attribute__((weak)) void SCLIB_RequestTimeExtension(uint32_t u32Protocol);
252#endif
253
263uint32_t SCLIB_CheckCDEvent(uint32_t num);
264
273uint32_t SCLIB_CheckTimeOutEvent(uint32_t num);
274
283uint32_t SCLIB_CheckTxRxEvent(uint32_t num);
284
293uint32_t SCLIB_CheckErrorEvent(uint32_t num);
294
295
296#ifdef __cplusplus
297}
298#endif
299
300#endif //__SCLIB_H__
301 /* end of group NANO100_SCLIB_EXPORTED_FUNCTIONS */
303 /* end of group NANO100_SC_Library */
305 /* end of group NANO100_Library */
307
308/*** (C) COPYRIGHT 2013-2014 Nuvoton Technology Corp. ***/
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
SCLIB_MAX_ATR_LEN
#define SCLIB_MAX_ATR_LEN
Max ATR length. ISO-7816 8.2.1.
Definition: sclib.h:35
SCLIB_CARD_INFO_T::T
uint32_t T
Protocol, ether SCLIB_PROTOCOL_T0 or SCLIB_PROTOCOL_T1.
Definition: sclib.h:95
SCLIB_CARD_ATTRIB_T::NAD
uint8_t NAD
NAD value.
Definition: sclib.h:115
SCLIB_SetIFSD
int32_t SCLIB_SetIFSD(uint32_t num, uint8_t size)
Set interface device max information field size (IFSD)
SCLIB_CARD_ATTRIB_T::WI
uint8_t WI
Wait integer for T0.
Definition: sclib.h:110
SCLIB_CARD_ATTRIB_T::Fi
uint8_t Fi
F index.
Definition: sclib.h:105
SCLIB_CheckErrorEvent
uint32_t SCLIB_CheckErrorEvent(uint32_t num)
Process error event in IRQ handler.
SCLIB_CARD_ATTRIB_T::GT
uint8_t GT
Guard Time.
Definition: sclib.h:109
SCLIB_CheckCDEvent
uint32_t SCLIB_CheckCDEvent(uint32_t num)
Process card detect event in IRQ handler.
SCLIB_CARD_ATTRIB_T::Di
uint8_t Di
D index.
Definition: sclib.h:106
SCLIB_CARD_ATTRIB_T::chksum
uint8_t chksum
Checksum type.
Definition: sclib.h:108
SCLIB_CARD_ATTRIB_T::CWI
uint8_t CWI
Character waiting integer for T1;.
Definition: sclib.h:112
SCLIB_CARD_ATTRIB_T::BWI
uint8_t BWI
Block waiting integer for T1;.
Definition: sclib.h:111
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_CARD_ATTRIB_T::clkStop
uint8_t clkStop
Card clock stop status. 00 Not allowed, 01 low, 02, high, 03 ether high or low.
Definition: sclib.h:113
SCLIB_Deactivate
void SCLIB_Deactivate(uint32_t num)
Deactivate a smartcard.
SCLIB_GetCardAttrib
int32_t SCLIB_GetCardAttrib(uint32_t num, SCLIB_CARD_ATTRIB_T *s_attrib)
Get the card attribute (e.g., Fi, Di, convention, guard time... etc. ) after activation success.
SCLIB_Activate
int32_t SCLIB_Activate(uint32_t num, uint32_t u32EMVCheck)
Activate a smartcard.
SCLIB_CARD_ATTRIB_T::conv
uint8_t conv
Convention, direct or inverse. 0 direct, 1 inverse.
Definition: sclib.h:107
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_CARD_ATTRIB_T::IFSC
uint8_t IFSC
size of negotiated IFCS
Definition: sclib.h:114
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:96
SCLIB_CheckTimeOutEvent
uint32_t SCLIB_CheckTimeOutEvent(uint32_t num)
Process time out event in IRQ handler.
__attribute__
__attribute__((weak)) void SCLIB_RequestTimeExtension(uint32_t u32Protocol)
A callback called by library while smartcard request for a time extension.
Definition: _syscalls.c:35
SCLIB_CARD_ATTRIB_T
A structure holds smartcard attribute, including convention, guard time, waiting time,...
Definition: sclib.h:104
SCLIB_CARD_INFO_T
A structure holds smartcard information.
Definition: sclib.h:94