+void T55xxReadBlockExt_1of4 (uint16_t arg0, uint8_t Block, uint32_t Pwd) {
+ LED_A_ON();
+ bool PwdMode = arg0 & 0x1;
+ uint8_t Page = (arg0 & 0x2) >> 1;
+ //uint32_t i = 0;
+ bool RegReadMode = (Block == 0xFF);//regular read mode
+ uint8_t bits;
+ int bitpos;
+
+ //clear buffer now so it does not interfere with timing later
+ BigBuf_Clear_ext(false);
+
+ //make sure block is at max 7
+ Block &= 0x7;
+
+ // Set up FPGA, 125kHz to power up the tag
+ LFSetupFPGAForADC(95, true);
+ StartTicks();
+ // make sure tag is fully powered up...
+ WaitMS(5);
+ // Trigger T55x7 Direct Access Mode with start gap
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+ WaitUS(START_GAP1of4);
+
+ T55xxWriteBit_1of4 (0); // 2 Bit 00 leading reference
+
+ // Opcode 1[page]
+ bits = 2 + Page;
+ T55xxWriteBit_1of4 (bits);
+
+ if (PwdMode) {
+ // 1 of 4 00 - insert two fixed 00 between opcode and password
+ T55xxWriteBit_1of4 (0); // 00
+
+ // Send Pwd
+ for (bitpos = 31; bitpos >= 1; bitpos -= 2) { // 2 bits at a time
+ bits = (((Pwd >> bitpos) & 1) << 1) + ((Pwd >> (bitpos-1)) & 1);
+ T55xxWriteBit_1of4 (bits);
+ }
+ }
+
+ // Send Lock bit
+ bits = 0; // Add lock bit (Not Set) to the next 2 bits
+
+ // Send Block number (if direct access mode)
+ if (!RegReadMode){
+ // Send Block number
+ bits += ((Block >> 2) & 1);
+ T55xxWriteBit_1of4 (bits);
+ bits = (Block & 3); // + (Block & 1);
+ T55xxWriteBit_1of4 (bits);
+ }
+
+ // Turn field on to read the response
+ // 137*8 seems to get to the start of data pretty well...
+ // but we want to go past the start and let the repeating data settle in...
+ TurnReadLFOn(210*8);
+
+ // Acquisition
+ // Now do the acquisition
+ DoPartialAcquisition(0, true, 12000, 0);
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
+// cmd_send(CMD_ACK,0,0,0,0,0);
+ LED_A_OFF();
+}
+
+void T55xxReadBlock (uint16_t arg0, uint8_t Block, uint32_t Pwd) {
+// arg0 16 bit 00000000
+// 0000000x Password
+// 000000x0 Page
+// 00000x00
+// 000xx000 (0x18) where xx : 00 - Normal Write, 01 - Long Leading Reference
+// 10 - Leading 0, 11 - 1 of 4
+ uint8_t downlink_mode;
+
+ downlink_mode = (arg0 >> 3) & 0x03;
+
+ // downlink mode id set to match the 2 bit as per Tech Sheet
+ switch (downlink_mode)
+ {
+ case 0 : T55xxReadBlockExt (arg0, Block, Pwd); break;
+ case 1 : T55xxWrite_LLR ();
+ T55xxReadBlockExt (arg0, Block, Pwd);
+ break;
+ case 2 : T55xxReadBlockExt_Leading0 (arg0, Block, Pwd); break;
+ case 3 : T55xxReadBlockExt_1of4 (arg0, Block, Pwd); break;
+ default:
+ T55xxReadBlockExt (arg0, Block, Pwd) ;
+ }
+
+// T55xxReadBlockExt (arg0, Block, Pwd) ;
+ cmd_send(CMD_ACK,0,0,0,0,0);
+}
+