nfc test on MQX4.1
[nfc-test.git] / ccid.h
blob271f1dd8e80ef16232a99abfad07039710e18a47
3 #ifndef CCID_H
4 #define CCID_H
5 #include "common.h"
7 // Slot error register when bmCommandStatus = 1 refer to Table 6.2-2 in CCID specification
8 #define RDR_TO_PC_SLOTERROR_COMMAND_NOT_SUPPORTED 0 // 0x00
9 #define RDR_TO_PC_SLOTERROR_CMD_ABORTED 1 // 0xFF, Host aborted the current activity
10 #define RDR_TO_PC_SLOTERROR_ICC_MUTE 2 // 0xFE, CCID timed out while talking to the ICC
11 #define RDR_TO_PC_SLOTERROR_XFR_PARITY_ERROR 3 // 0xFD, Parity error while talking to the ICC
12 #define RDR_TO_PC_SLOTERROR_XFR_OVERRUN 4 // 0xFC, Overrun error while talking to the ICC
13 #define RDR_TO_PC_SLOTERROR_HW_ERROR 5 // 0xFB, An all inclusive hardware error occurred
14 #define RDR_TO_PC_SLOTERROR_BAD_ATR_TS 8 // 0xF8
15 #define RDR_TO_PC_SLOTERROR_BAD_ATR_TCK 9 // 0xF7
16 #define RDR_TO_PC_SLOTERROR_ICC_PROTOCOL_NOT_SUPPORTED 10 // 0xF6
17 #define RDR_TO_PC_SLOTERROR_ICC_CLASS_NOT_SUPPORTED 11 // 0xF5
18 #define RDR_TO_PC_SLOTERROR_PROCEDURE_BYTE_CONFLICT 12 // 0xF4
19 #define RDR_TO_PC_SLOTERROR_DEACTIVATED_PROTOCOL 13 // 0xF3
20 #define RDR_TO_PC_SLOTERROR_BUSY_WITH_AUTO_SEQUENCE 14 // 0xF2, Automatic Sequence Ongoing
21 #define RDR_TO_PC_SLOTERROR_PIN_TIMEOUT 16 // 0xF0
22 #define RDR_TO_PC_SLOTERROR_PIN_CANCELLED 17 // 0xEF
23 #define RDR_TO_PC_SLOTERROR_CMD_SLOT_BUSY 32 // 0xE0, A second command was sent to a slot which was already processing a command
24 // these following slot error number is the supplement for above
25 #define RDR_TO_PC_SLOTERROR_NONE 0
26 #define RDR_TO_PC_SLOTERROR_BAD_LENGTGH 1
27 #define RDR_TO_PC_SLOTERROR_SLOT_NO_EXIST 5
28 #define RDR_TO_PC_SLOTERROR_POWERSELECT_NO_SUPPORTED 7
29 #define RDR_TO_PC_SLOTERROR_PROTOCOL_INVALID_OR_NOT_SUPPORTED 7
30 #define RDR_TO_PC_SLOTERROR_BAD_LEVEL_PARAMETER 8
31 #define RDR_TO_PC_SLOTERROR_FI_DI_PAIR_INVALID_OR_NOT_SUPPORTED 10
32 #define RDR_TO_PC_SLOTERROR_INVALID_TCCKTS_PARAMETER 11
33 #define RDR_TO_PC_SLOTERROR_GUARD_TIME_NOT_SUPPORTED 12
34 #define RDR_TO_PC_SLOTERROR_WI_BWI_CWI_INVALID_OR_NOT_SUPPORTED 13
35 #define RDR_TO_PC_SLOTERROR_CLOCK_STOP_REQUEST_FALID 14
36 #define RDR_TO_PC_SLOTERROR_IFSC_SIZE_INVALID_OR_NOT_SUPPORTED 15
37 #define RDR_TO_PC_SLOTERROR_NAD_VALUE_INVALID_OR_NOT_SUPPORTED 16
39 // Defines for bICCStatus in slot status (2 Bits)
40 #define RDR_TO_PC_ICCSTATUS_NONE 0x00
41 #define RDR_TO_PC_ICCSTATUS_ACTIVE 0x00 // Present and active
42 #define RDR_TO_PC_ICCSTATUS_INACTIVE 0x01 // Present and inactive
43 #define RDR_TO_PC_ICCSTATUS_NOICC 0x02 // Absent
44 #define RDR_TO_PC_ICCSTATUS_RFU 0x03
46 struct ccid_msg_data {
47 unsigned char *sBuf;
48 unsigned char *rBuf;
49 unsigned int sLen;
50 unsigned int rLen;
51 unsigned int param;
52 unsigned char cardStatus;
53 unsigned char slot;
54 signed int errCode;
57 struct ccid_operations {
58 void (*card_power_on)(struct ccid_msg_data *);
59 void (*card_power_off)(struct ccid_msg_data *);
60 void (*get_slot_status)(struct ccid_msg_data *);
61 void (*xfr_block)(struct ccid_msg_data *);
62 void (*get_parameters)(struct ccid_msg_data *);
63 void (*reset_parameters)(struct ccid_msg_data *);
64 void (*set_parameters)(struct ccid_msg_data *);
65 void (*escape)(struct ccid_msg_data *);
66 void (*card_clock)(struct ccid_msg_data *);
67 void (*t0_APDU)(struct ccid_msg_data *);
68 void (*secure)(struct ccid_msg_data *);
69 void (*mechanical)(struct ccid_msg_data *);
70 void (*abort)(struct ccid_msg_data *);
71 void (*set_data_rate_and_clock_frequency)(struct ccid_msg_data *);
73 #endif