+ // Set up the synchronous serial port
+ FpgaSetupSsc();
+ /////////////
+
+ uint16_t len, cmdsReceived = 0;
+ int cardSTATE = SIM_NOFIELD;
+ int vHf = 0; // in mV
+ // uint32_t time_0 = 0;
+ // uint32_t t2r_time = 0;
+ // uint32_t r2t_time = 0;
+ uint8_t *receivedCmd = BigBuf_malloc(MAX_FRAME_SIZE);
+
+ // the only commands we understand is WUPB, AFI=0, Select All, N=1:
+// static const uint8_t cmdWUPB[] = { ISO14443B_REQB, 0x00, 0x08, 0x39, 0x73 }; // WUPB
+ // ... and REQB, AFI=0, Normal Request, N=1:
+// static const uint8_t cmdREQB[] = { ISO14443B_REQB, 0x00, 0x00, 0x71, 0xFF }; // REQB
+ // ... and ATTRIB
+// static const uint8_t cmdATTRIB[] = { ISO14443B_ATTRIB, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // ATTRIB
+
+ // ... if not PUPI/UID is supplied we always respond with ATQB, PUPI = 820de174, Application Data = 0x20381922,
+ // supports only 106kBit/s in both directions, max frame size = 32Bytes,
+ // supports ISO14443-4, FWI=8 (77ms), NAD supported, CID not supported:
+ uint8_t respATQB[] = { 0x50, 0x82, 0x0d, 0xe1, 0x74, 0x20, 0x38, 0x19,
+ 0x22, 0x00, 0x21, 0x85, 0x5e, 0xd7 };
+
+ // response to HLTB and ATTRIB
+ static const uint8_t respOK[] = {0x00, 0x78, 0xF0};
+
+ // ...PUPI/UID supplied from user. Adjust ATQB response accordingly
+ if ( pupi > 0 ) {
+ num_to_bytes(pupi, 4, respATQB+1);
+ ComputeCrc14443(CRC_14443_B, respATQB, 12, respATQB+13, respATQB+14);
+ }