]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/lfops.c
FIX: the cmdline parsing was a bit too hard. Thanks to @crayon for pointing out...
[proxmark3-svn] / armsrc / lfops.c
index 69b76d1215ab624ad0baf27575841d4ad6fb11a5..8b7e98fc2e31b7cd27b2d9c23f3f588abf7f899b 100644 (file)
 /**
  * Function to do a modulation and then get samples.
  * @param delay_off
 /**
  * Function to do a modulation and then get samples.
  * @param delay_off
- * @param period_0
- * @param period_1
+ * @param periods  0xFFFF0000 is period_0,  0x0000FFFF is period_1
+ * @param useHighFreg
  * @param command
  */
  * @param command
  */
-void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command)
+void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t periods, uint32_t useHighFreq, uint8_t *command)
 {
 {
+       /* Make sure the tag is reset */
+       FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+       SpinDelay(200);
 
 
-       int divisor_used = 95; // 125 KHz
-       // see if 'h' was specified
-
-       if (command[strlen((char *) command) - 1] == 'h')
-               divisor_used = 88; // 134.8 KHz
-
+       uint16_t period_0 =  periods >> 16;
+       uint16_t period_1 =  periods & 0xFFFF;
+       
+       // 95 == 125 KHz  88 == 124.8 KHz
+       int divisor_used = (useHighFreq) ? 88 : 95;
        sample_config sc = { 0,0,1, divisor_used, 0};
        setSamplingConfig(&sc);
        sample_config sc = { 0,0,1, divisor_used, 0};
        setSamplingConfig(&sc);
+
        //clear read buffer
        BigBuf_Clear_keep_EM();
 
        //clear read buffer
        BigBuf_Clear_keep_EM();
 
-       /* Make sure the tag is reset */
-       FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-       SpinDelay(2500);
-
        LFSetupFPGAForADC(sc.divisor, 1);
 
        // And a little more time for the tag to fully power up
        LFSetupFPGAForADC(sc.divisor, 1);
 
        // And a little more time for the tag to fully power up
-       SpinDelay(2000);
+       SpinDelay(50);
 
        // now modulate the reader field
        while(*command != '\0' && *command != ' ') {
 
        // now modulate the reader field
        while(*command != '\0' && *command != ' ') {
@@ -68,7 +67,6 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint
        LED_D_OFF();
        SpinDelayUs(delay_off);
        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, sc.divisor);
        LED_D_OFF();
        SpinDelayUs(delay_off);
        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, sc.divisor);
-
        FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
 
        // now do the read
        FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
 
        // now do the read
@@ -898,25 +896,25 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
                                        fc = bytebits_to_byte(dest + 9, 8);
                                        cardnum = bytebits_to_byte(dest + 17, 16);
                                        code1 = bytebits_to_byte(dest + 8,fmtLen);
                                        fc = bytebits_to_byte(dest + 9, 8);
                                        cardnum = bytebits_to_byte(dest + 17, 16);
                                        code1 = bytebits_to_byte(dest + 8,fmtLen);
-                                       Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
+                                       Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %u - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
                                        break;
                                case 50:
                                        fc = bytebits_to_byte(dest + 9, 16);
                                        cardnum = bytebits_to_byte(dest + 25, 32);
                                        code1 = bytebits_to_byte(dest + 8, (fmtLen-32) );
                                        code2 = bytebits_to_byte(dest + 8 + (fmtLen-32), 32);
                                        break;
                                case 50:
                                        fc = bytebits_to_byte(dest + 9, 16);
                                        cardnum = bytebits_to_byte(dest + 25, 32);
                                        code1 = bytebits_to_byte(dest + 8, (fmtLen-32) );
                                        code2 = bytebits_to_byte(dest + 8 + (fmtLen-32), 32);
-                                       Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, code2, rawHi2, rawHi, rawLo);
+                                       Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %u - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, code2, rawHi2, rawHi, rawLo);
                                        break;
                                default:
                                        if (fmtLen > 32 ) {
                                                cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
                                                code1 = bytebits_to_byte(dest+8,fmtLen-32);
                                                code2 = bytebits_to_byte(dest+8+(fmtLen-32),32);
                                        break;
                                default:
                                        if (fmtLen > 32 ) {
                                                cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
                                                code1 = bytebits_to_byte(dest+8,fmtLen-32);
                                                code2 = bytebits_to_byte(dest+8+(fmtLen-32),32);
-                                               Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
+                                               Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
                                        } else {
                                                cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
                                                code1 = bytebits_to_byte(dest+8,fmtLen);
                                        } else {
                                                cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
                                                code1 = bytebits_to_byte(dest+8,fmtLen);
-                                               Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
+                                               Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
                                        }
                                        break;          
                        }
                                        }
                                        break;          
                        }
@@ -1006,7 +1004,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
        //clear read buffer
        BigBuf_Clear_keep_EM();
        
        //clear read buffer
        BigBuf_Clear_keep_EM();
        
-// Configure to go in 125Khz listen mode
+       // Configure to go in 125Khz listen mode
        LFSetupFPGAForADC(95, true);
 
        while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
        LFSetupFPGAForADC(95, true);
 
        while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
@@ -1345,15 +1343,14 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
 void CopyIOtoT55x7(uint32_t hi, uint32_t lo) {
        uint32_t data[] = {T55x7_BITRATE_RF_64 | T55x7_MODULATION_FSK2a | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo};
        //TODO add selection of chip for Q5 or T55x7
 void CopyIOtoT55x7(uint32_t hi, uint32_t lo) {
        uint32_t data[] = {T55x7_BITRATE_RF_64 | T55x7_MODULATION_FSK2a | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo};
        //TODO add selection of chip for Q5 or T55x7
-       // data[0] = (((64-2)/2)<<T5555_BITRATE_SHIFT) | T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | 2 << T5555_MAXBLOCK_SHIFT;
+       //t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
+       // data[0] = (64 << T5555_BITRATE_SHIFT) | T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | 2 << T5555_MAXBLOCK_SHIFT;
 
        LED_D_ON();
        // Program the data blocks for supplied ID
        // and the block 0 config
        WriteT55xx(data, 0, 3);
 
        LED_D_ON();
        // Program the data blocks for supplied ID
        // and the block 0 config
        WriteT55xx(data, 0, 3);
-
        LED_D_OFF();
        LED_D_OFF();
-
        DbpString("DONE!");
 }
 
        DbpString("DONE!");
 }
 
@@ -1387,6 +1384,7 @@ void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t
 // clone viking tag to T55xx
 void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) {
        uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), block1, block2};
 // clone viking tag to T55xx
 void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) {
        uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), block1, block2};
+       //t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
        if (Q5) data[0] = (32 << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
        // Program the data blocks for supplied ID and the block 0 config
        WriteT55xx(data, 0, 3);
        if (Q5) data[0] = (32 << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
        // Program the data blocks for supplied ID and the block 0 config
        WriteT55xx(data, 0, 3);
@@ -1474,7 +1472,7 @@ void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo) {
                clock = (clock-2)>>1;  //n = (RF-2)/2
                data[0] = (clock << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | (2 << T5555_MAXBLOCK_SHIFT);
        }
                clock = (clock-2)>>1;  //n = (RF-2)/2
                data[0] = (clock << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | (2 << T5555_MAXBLOCK_SHIFT);
        }
-
        WriteT55xx(data, 0, 3);
 
        LED_D_OFF();
        WriteT55xx(data, 0, 3);
 
        LED_D_OFF();
Impressum, Datenschutz