4 static uint8_t ccid_get_picc_status(void)
6 if(BITISCLEAR(common
->picc
.status
, PRESENT
))
7 return PICC_ICCSTATUS_NOICC
;
8 else if(BITISCLEAR(common
->picc
.status
, ACTIVATED
))
9 return PICC_ICCSTATUS_INACTIVE
;
11 return PICC_ICCSTATUS_ACTIVE
;
14 static void ccid_picc_power_on(struct ccid_msg_data
*picc_data
)
18 ret
= picc_power_on(&common
->picc
, picc_data
->rBuf
, &picc_data
->rLen
);
20 picc_data
->errCode
= ret
;
21 picc_data
->cardStatus
= ccid_get_picc_status();
24 static void ccid_picc_power_off(struct ccid_msg_data
*picc_data
)
26 picc_power_off(&common
->picc
);
28 picc_data
->errCode
= PICC_ERRORCODE_NONE
;
31 picc_data
->cardStatus
= ccid_get_picc_status();
34 static void ccid_picc_get_slot_status(struct ccid_msg_data
*picc_data
)
36 picc_data
->errCode
= PICC_ERRORCODE_NONE
;
39 picc_data
->cardStatus
= ccid_get_picc_status();
42 static void ccid_picc_xfr_block(struct ccid_msg_data
*picc_data
)
44 uint8_t level
= (uint8_t)picc_data
->param
;
47 // pr_debug("slen = %08X, rlen = %08X\n", picc_data->sLen, picc_data->rLen);
48 ret
= picc_command_exchange(&common
->picc
, picc_data
->sBuf
, picc_data
->sLen
,
49 picc_data
->rBuf
, &picc_data
->rLen
,
51 // pr_debug("slen = %08X, rlen = %08X\n", picc_data->sLen, picc_data->rLen);
52 picc_data
->errCode
= ret
;
55 picc_data
->cardStatus
= ccid_get_picc_status();
58 static void ccid_picc_get_parameters(struct ccid_msg_data
*picc_data
)
61 picc_data
->rBuf
[0] = 0x11;
63 picc_data
->rBuf
[1] = 0x10;
65 picc_data
->rBuf
[2] = 0x01;
66 // bmWaitingIntegersT1
67 picc_data
->rBuf
[3] = 0x4D;
69 picc_data
->rBuf
[4] = 0x00;
72 if(fsdi_to_fsd
[common
->picc
.FSCI
] > (uint16_t)0xFE)
73 picc_data
->rBuf
[5] = 0xFE;
75 picc_data
->rBuf
[5] = (uint8_t)fsdi_to_fsd
[common
->picc
.FSCI
];
77 picc_data
->rBuf
[6] = 0x00;
79 picc_data
->param
= 0x01;
80 picc_data
->rLen
= 0x07;
81 picc_data
->errCode
= PICC_ERRORCODE_NONE
;
82 picc_data
->cardStatus
= ccid_get_picc_status();
85 static void ccid_picc_set_parameters(struct ccid_msg_data
*picc_data
)
87 ccid_picc_get_parameters(picc_data
);
90 static void ccid_picc_reset_parameters(struct ccid_msg_data
*picc_data
)
92 ccid_picc_get_parameters(picc_data
);
95 static void ccid_picc_escape(struct ccid_msg_data
*picc_data
)
100 static struct ccid_operations ccid_picc_ops
=
102 .card_power_on
= ccid_picc_power_on
,
103 .card_power_off
= ccid_picc_power_off
,
104 .get_slot_status
= ccid_picc_get_slot_status
,
105 .xfr_block
= ccid_picc_xfr_block
,
106 .get_parameters
= ccid_picc_get_parameters
,
107 .set_parameters
= ccid_picc_set_parameters
,
108 .reset_parameters
= ccid_picc_reset_parameters
,
109 .escape
= ccid_picc_escape
,
112 int picc_interrput_in(uint8_t slot_status
)
114 if(!common
->slot_changed_notify
)
116 return(common
->slot_changed_notify(common
->private_data
, slot_status
));
119 void ccid_picc_init(struct ccid_operations
**ops
,
121 int (*picc_intr_in
)(void *, uint8_t),
124 picc_param_init(common
, max_IFSD
);
126 common
->slot_changed_notify
= picc_intr_in
;
128 common
->private_data
= pri_data
;
130 *ops
= &ccid_picc_ops
;
133 void ccid_picc_uninit(void)
135 picc_param_init(common
, 256);
137 common
->slot_changed_notify
= NULL
;
139 common
->private_data
= NULL
;