+ LED_A_ON();\r
+\r
+ if (init) {\r
+ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
+ }\r
+ \r
+ if (clearTrace) {\r
+ clear_trace();\r
+ }\r
+ set_tracing(true);\r
+\r
+ // clear debug level. We are expecting lots of authentication failures...\r
+ int OLD_MF_DBGLEVEL = MF_DBGLEVEL;\r
+ MF_DBGLEVEL = MF_DBG_NONE;\r
+\r
+ int res = 0;\r
+ if (multisectorCheck) {\r
+ TKeyIndex keyIndex = {{0}};\r
+ uint8_t sectorCnt = blockNo;\r
+ res = MifareMultisectorChk(datain, keyCount, sectorCnt, keyType, &auth_timeout, OLD_MF_DBGLEVEL, &keyIndex);\r
+ if (res >= 0) {\r
+ cmd_send(CMD_ACK, 1, res, 0, keyIndex, 80);\r
+ } else {\r
+ cmd_send(CMD_ACK, 0, res, 0, NULL, 0);\r
+ }\r
+ } else if (fixed_nonce) {\r
+ res = MifareChkBlockKeysFixedNonce(datain, keyCount, blockNo, keyType, &auth_timeout, OLD_MF_DBGLEVEL);\r
+ if (res > 0) {\r
+ cmd_send(CMD_ACK, 1, res, 0, NULL, 0); // key found\r
+ } else {\r
+ cmd_send(CMD_ACK, 0, res, 0, NULL, 0); // no key found or aborted\r
+ }\r
+ } else {\r
+ res = MifareChkBlockKeys(datain, keyCount, blockNo, keyType, &auth_timeout, OLD_MF_DBGLEVEL);\r
+ if (res > 0) {\r
+ cmd_send(CMD_ACK, 1, res, 0, datain + (res - 1) * 6, 6);\r
+ } else {\r
+ cmd_send(CMD_ACK, 0, res, 0, NULL, 0);\r
+ }\r
+ }\r
+\r
+ if (drop_field || res != 0) {\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+ LED_D_OFF();\r
+ }\r
+\r
+ // restore debug level\r
+ MF_DBGLEVEL = OLD_MF_DBGLEVEL;\r
+\r
+ LED_A_OFF();\r
+}\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// MIFARE Personalize UID. Only for Mifare Classic EV1 7Byte UID\r
+//-----------------------------------------------------------------------------\r
+void MifarePersonalizeUID(uint8_t keyType, uint8_t perso_option, uint8_t *data) {\r
+\r