RESPONSECODE IFDHPowerICC ( DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength ) { /* This function controls the power and reset signals of the smartcard reader at the particular reader/slot specified by Lun. Action - Action to be taken on the card. IFD_POWER_UP - Power and reset the card if not done so (store the ATR and return it and it's length). IFD_POWER_DOWN - Power down the card if not done already (Atr/AtrLength should be zero'd) IFD_RESET - Perform a quick reset on the card. If the card is not powered power up the card. (Store and return the Atr/Length) Atr - Answer to Reset of the card. The driver is responsible for caching this value in case IFDHGetCapabilities is called requesting the ATR and it's length. This should not exceed MAX_ATR_SIZE. AtrLength - Length of the Atr. This should not exceed MAX_ATR_SIZE. Notes: Memory cards without an ATR should return IFD_SUCCESS on reset but the Atr should be zero'd and the length should be zero Reset errors should return zero for the AtrLength and return IFD_ERROR_POWER_ACTION. returns: IFD_SUCCESS IFD_ERROR_POWER_ACTION IFD_COMMUNICATION_ERROR IFD_NOT_SUPPORTED */ Log1(PCSC_LOG_DEBUG, "IFDHPowerICC"); RESPONSECODE rv; switch (Action) { case IFD_RESET: case IFD_POWER_UP: readUID(AtrLength, Atr); rv = IFD_SUCCESS; break; default: *AtrLength = 0; Atr = 0; rv = IFD_NOT_SUPPORTED; break; } return rv; }
int main(void) { char uid[25]={0}; //All system related settings SystemCoreClockUpdate(); //Set System MAIN Clock to 48Mhz while(1) { readUID(uid); } }
RESPONSECODE IFDHGetCapabilities ( DWORD Lun, DWORD Tag, PDWORD Length, PUCHAR Value ) { /* This function should get the slot/card capabilities for a particular slot/card specified by Lun. Again, if you have only 1 card slot and don't mind loading a new driver for each reader then ignore Lun. Tag - the tag for the information requested example: TAG_IFD_ATR - return the Atr and it's size (required). these tags are defined in ifdhandler.h Length - the length of the returned data Value - the value of the data returns: IFD_SUCCESS IFD_ERROR_TAG */ Log1(PCSC_LOG_DEBUG, "IFDHGetCapabilities"); RESPONSECODE rv; switch (Tag) { case TAG_IFD_ATR: readUID(Length, Value); rv = IFD_SUCCESS; break; case TAG_IFD_SLOTS_NUMBER: (*Length) = 1; (*Value) = IFDH_MAX_SLOTS; rv = IFD_SUCCESS; break; case TAG_IFD_SIMULTANEOUS_ACCESS: (*Length) = 1; (*Value) = IFDH_MAX_READERS; rv = IFD_SUCCESS; break; default: (*Length) = 0; rv = IFD_ERROR_TAG; } return rv; }