]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/lfops.c
CHG: Updated the CHANGELOG.md
[proxmark3-svn] / armsrc / lfops.c
index e939259519b7a9a3588ad447facc899cd6463e30..7f61c78dcce1d951b5ae3eaa3a843e6a5e9de8f0 100644 (file)
@@ -17,7 +17,7 @@
 #include "lfdemod.h"
 #include "lfsampling.h"
 #include "protocols.h"
-#include "usb_cdc.h" //test
+#include "usb_cdc.h" // for usb_poll_validate_length
 
 /**
  * Function to do a modulation and then get samples.
@@ -37,6 +37,8 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint
 
        sample_config sc = { 0,0,1, divisor_used, 0};
        setSamplingConfig(&sc);
+       //clear read buffer
+       BigBuf_Clear_keep_EM();
 
        /* Make sure the tag is reset */
        FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
@@ -400,7 +402,7 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
        for(;;) {
                //wait until SSC_CLK goes HIGH
                while(!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) {
-                       if(BUTTON_PRESS() || (usb_poll_validate_length() )) {
+                       if(BUTTON_PRESS() || usb_poll_validate_length() ) {
                                DbpString("Stopped");
                                return;
                        }
@@ -417,7 +419,7 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
                
                //wait until SSC_CLK goes LOW
                while(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK) {
-                       if(BUTTON_PRESS()) {
+                       if( BUTTON_PRESS() || usb_poll_validate_length() ) {
                                DbpString("Stopped");
                                return;
                        }
@@ -594,20 +596,10 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
                }
        }
        Dbprintf("Simulating with fcHigh: %d, fcLow: %d, clk: %d, invert: %d, n: %d",fcHigh, fcLow, clk, invert, n);
-       /*Dbprintf("DEBUG: First 32:");
-       uint8_t *dest = BigBuf_get_addr();
-       i=0;
-       Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
-       i+=16;
-       Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
-       */
-       if (ledcontrol)
-               LED_A_ON();
 
+       if (ledcontrol) LED_A_ON();
        SimulateTagLowFrequency(n, 0, ledcontrol);
-
-       if (ledcontrol)
-               LED_A_OFF();
+       if (ledcontrol) LED_A_OFF();
 }
 
 // compose ask waveform for one bit(ASK)
@@ -735,6 +727,9 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
        // Configure to go in 125Khz listen mode
        LFSetupFPGAForADC(95, true);
 
+       //clear read buffer
+       BigBuf_Clear_keep_EM();
+
        while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
 
                WDT_HIT();
@@ -754,7 +749,7 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
                                  (unsigned int) lo,
                                  (unsigned int) (lo>>1) & 0xFFFF
                                  );
-                       }else {  //standard HID tags 44/96 bits
+                       } else {  //standard HID tags 44/96 bits
                                uint8_t bitlen = 0;
                                uint32_t fc = 0;
                                uint32_t cardnum = 0;
@@ -825,6 +820,8 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
        uint8_t *dest = BigBuf_get_addr();
        size_t size; 
        int idx=0;
+       //clear read buffer
+       BigBuf_Clear_keep_EM();
        // Configure to go in 125Khz listen mode
        LFSetupFPGAForADC(95, true);
 
@@ -915,6 +912,8 @@ void CmdEM410xdemod(int findone, int *high, int *low, int ledcontrol)
        int clk=0, invert=0, errCnt=0, maxErr=20;
        uint32_t hi=0;
        uint64_t lo=0;
+       //clear read buffer
+       BigBuf_Clear_keep_EM();
        // Configure to go in 125Khz listen mode
        LFSetupFPGAForADC(95, true);
 
@@ -976,7 +975,11 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
        uint16_t number=0;
        uint8_t crc = 0;
        uint16_t calccrc = 0;
-       // Configure to go in 125Khz listen mode
+
+       //clear read buffer
+       BigBuf_Clear_keep_EM();
+       
+// Configure to go in 125Khz listen mode
        LFSetupFPGAForADC(95, true);
 
        while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
@@ -1105,7 +1108,7 @@ void T55xxWriteBit(int bit) {
 void T55xxResetRead(void) {
        LED_A_ON();
        //clear buffer now so it does not interfere with timing later
-       BigBuf_Clear_ext(false);
+       BigBuf_Clear_keep_EM();
 
        // Set up FPGA, 125kHz
        LFSetupFPGAForADC(95, true);
@@ -1256,7 +1259,6 @@ void T55xxWakeUp(uint32_t Pwd){
 }
 
 /*-------------- Cloning routines -----------*/
-
 void WriteT55xx(uint32_t *blockdata, uint8_t startblock, uint8_t numblocks) {
        // write last block first and config block last (if included)
        for (uint8_t i = numblocks+startblock; i > startblock; i--)
@@ -1270,7 +1272,7 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
 
        if (longFMT){
                // Ensure no more than 84 bits supplied
-               if (hi2>0xFFFFF) {
+               if (hi2 > 0xFFFFF) {
                        DbpString("Tags can only have 84 bits.");
                        return;
                }
@@ -1286,7 +1288,7 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
                data[6] = manchesterEncode2Bytes(lo & 0xFFFF);
        }       else {
                // Ensure no more than 44 bits supplied
-               if (hi>0xFFF) {
+               if (hi > 0xFFF) {
                        DbpString("Tags can only have 44 bits.");
                        return;
                }
@@ -1612,7 +1614,7 @@ void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode) {
        uint16_t bufsize = BigBuf_max_traceLen();
        uint32_t i = 0;
 
-       //clear buffer now so it does not interfere with timing later
+       // Clear destination buffer before sending the command
        BigBuf_Clear_ext(false);
        
        //If password mode do login
Impressum, Datenschutz