]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
CHG: 'lf cotag read' - it now follows "lf config" settings when collecting signaldata.
authoriceman1001 <iceman@iuse.se>
Wed, 1 Feb 2017 13:11:11 +0000 (14:11 +0100)
committericeman1001 <iceman@iuse.se>
Wed, 1 Feb 2017 13:11:11 +0000 (14:11 +0100)
armsrc/lfops.c
armsrc/lfsampling.c
client/cmdlf.c
client/cmdlf.h
client/cmdlfcotag.c
client/cmdlfcotag.h

index 0dc5bcf9cee1f95e34ece58662971fbca7b02942..1c11ad09cd0b08a0ed31d7403e6e72129723cf57 100644 (file)
@@ -43,7 +43,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t periods, uint3
        uint16_t period_0 =  periods >> 16;
        uint16_t period_1 =  periods & 0xFFFF;
        
-       // 95 == 125 KHz  88 == 124.8 KHz
+       // 95 == 125 KHz  88 == 134.8 KHz
        int divisor_used = (useHighFreq) ? 88 : 95;
        sample_config sc = { 0,0,1, divisor_used, 0};
        setSamplingConfig(&sc);
@@ -1742,8 +1742,9 @@ void EM4xWriteWord(uint32_t Data, uint8_t Address, uint32_t Pwd, uint8_t PwdMode
 
 void Cotag() {
 
-//#define WAIT2200     { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2035); }
-#define WAIT2200       { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2200); }
+#define OFF    { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2035); }
+//#define WAIT2200     { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2200); }
+#define ON(x)      { FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 89); FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD); WaitUS((x)); }
        LED_A_ON();
        
        //clear buffer now so it does not interfere with timing later
@@ -1764,26 +1765,23 @@ void Cotag() {
        StartTicks();
        
        //send start pulse
-       TurnReadLFOn(800);      WAIT2200
-       TurnReadLFOn(3600);     WAIT2200
-       TurnReadLFOn(800);      WAIT2200
-       TurnReadLFOn(3600);     
-       
+       ON(740)  OFF
+       ON(3330) OFF
+       ON(740)  OFF
+       ON(1000)
+
 /*
-       TurnReadLFOn(740);      WAIT2200
-       TurnReadLFOn(3330);     WAIT2200
-       TurnReadLFOn(740);      WAIT2200
-       TurnReadLFOn(3330);     
-       
+       ON(800)  OFF
+       ON(3600) OFF
+       ON(800)  OFF
+       ON(1000)
 
 burst 800 us,    gap   2.2 msecs
 burst 3.6 msecs  gap   2.2 msecs
 burst 800 us     gap   2.2 msecs
 pulse 3.6 msecs
 */
-       
-       // Acquisition
-       DoAcquisition_default(-1, true);
+       DoAcquisition_config(FALSE);    
        
        // Turn the field off
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
index d726ba20c7c823fce1d25beb883cec7262cd308c..0fcaf3ce5a529d61b648c73c16a491af1bd6d9a0 100644 (file)
@@ -8,6 +8,14 @@
 
 #include "lfsampling.h"
 
+/*
+Default LF config is set to:
+       decimation = 1  (we keep 1 out of 1 samples)
+       bits_per_sample = 8
+       averaging = YES
+       divisor = 95 (125khz)
+       trigger_threshold = 0
+       */
 sample_config config = { 1, 8, 1, 95, 0 } ;
 
 void printConfig() {
@@ -15,11 +23,10 @@ void printConfig() {
        Dbprintf("  [q] divisor:           %d ", config.divisor);
        Dbprintf("  [b] bps:               %d ", config.bits_per_sample);
        Dbprintf("  [d] decimation:        %d ", config.decimation);
-       Dbprintf("  [a] averaging:         %d ", config.averaging);
+       Dbprintf("  [a] averaging:         %s ", (config.averaging) ? "Yes" : "No");
        Dbprintf("  [t] trigger threshold: %d ", config.trigger_threshold);
 }
 
-
 /**
  * Called from the USB-handler to set the sampling configuration
  * The sampling config is used for std reading and snooping.
@@ -34,12 +41,11 @@ void printConfig() {
 void setSamplingConfig(sample_config *sc) {
        if(sc->divisor != 0) config.divisor = sc->divisor;
        if(sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample;
-       if(sc->decimation != 0) config.decimation = sc->decimation;
        if(sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
-
+       
+       config.decimation = (sc->decimation != 0) ? sc->decimation : 1;
        config.averaging = sc->averaging;
        if(config.bits_per_sample > 8)  config.bits_per_sample = 8;
-       if(config.decimation < 1)       config.decimation = 1;
 
        printConfig();
 }
@@ -134,7 +140,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
        while(!BUTTON_PRESS() && !usb_poll_validate_length() ) {
                WDT_HIT();
                if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
-                       AT91C_BASE_SSC->SSC_THR = 0x43;
+                       AT91C_BASE_SSC->SSC_THR = 0x00; //0x43;
                        LED_D_ON();
                }
                if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
index 07f3ac98bbdf617fb93271f67e6780b1cd154742..31e747d332aba32b6d3cfb1bdd5100db36010434 100644 (file)
@@ -497,24 +497,24 @@ int CmdLFSetConfig(const char *Cmd) {
                        cmdp++;
                        break;
                case 'q':
-                       errors |= param_getdec(Cmd,cmdp+1,&divisor);
+                       errors |= param_getdec(Cmd, cmdp+1, &divisor);
                        cmdp+=2;
                        break;
                case 't':
-                       errors |= param_getdec(Cmd,cmdp+1,&unsigned_trigg);
+                       errors |= param_getdec(Cmd, cmdp+1, &unsigned_trigg);
                        cmdp+=2;
                        if(!errors) trigger_threshold = unsigned_trigg;
                        break;
                case 'b':
-                       errors |= param_getdec(Cmd,cmdp+1,&bps);
+                       errors |= param_getdec(Cmd, cmdp+1, &bps);
                        cmdp+=2;
                        break;
                case 'd':
-                       errors |= param_getdec(Cmd,cmdp+1,&decimation);
+                       errors |= param_getdec(Cmd, cmdp+1, &decimation);
                        cmdp+=2;
                        break;
                case 'a':
-                       averaging = param_getchar(Cmd,cmdp+1) == '1';
+                       averaging = param_getchar(Cmd, cmdp+1) == '1';
                        cmdp+=2;
                        break;
                default:
@@ -531,14 +531,13 @@ int CmdLFSetConfig(const char *Cmd) {
        //Validations
        if (errors) return usage_lf_config();
        
-       //Bps is limited to 8, so fits in lower half of arg1
+       //Bps is limited to 8
        if (bps >> 4) bps = 8;
 
        sample_config config = { decimation, bps, averaging, divisor, trigger_threshold };
 
-       //Averaging is a flag on high-bit of arg[1]
-       UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG};
-       memcpy(c.d.asBytes,&config,sizeof(sample_config));
+       UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG, {0,0,0} };
+       memcpy(c.d.asBytes, &config, sizeof(sample_config));
        clearCommandBuffer();
        SendCommand(&c);
        return 0;
index 802975328bf65e07b829555c6de26931c6ad99ea..8764c7fc29b0b63d61d9ac167f64dec94a2dd72b 100644 (file)
@@ -46,6 +46,8 @@
 
 int CmdLF(const char *Cmd);
 
+int CmdLFSetConfig(const char *Cmd);
+
 int CmdLFCommandRead(const char *Cmd);
 int CmdFlexdemod(const char *Cmd);
 int CmdIndalaDemod(const char *Cmd);
index 1a2b2eca699cee338d4f7aa746421c0a4bda3099..5e3f28b66cda5f0e88c1bebae6d32d5d5116f46b 100644 (file)
@@ -15,6 +15,8 @@ int CmdCOTAGRead(const char *Cmd) {
 
 //     if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_cotag_read();
 
+       CmdLFSetConfig("q 89");
        UsbCommand c = {CMD_COTAG, {0, 0, 0}};
        clearCommandBuffer();
        SendCommand(&c);
@@ -22,7 +24,7 @@ int CmdCOTAGRead(const char *Cmd) {
                PrintAndLog("command execution time out");
                return 1;
        }
-       getSamples("20000", true);
+       getSamples("", true);
        return 0;
 }
 
index 106d2eb93aaf65755c9e3ba025cdbf00710063ae..37009a0b308fd033c07ee18d73c677cd08d0eee9 100644 (file)
@@ -16,6 +16,8 @@
 #include "cmddata.h"   // getSamples
 #include "cmdparser.h"  // CmdsParse, CmdsHelp
 #include "cmdmain.h"
+#include "ui.h"                        // PrintAndLog
+#include "cmdlf.h"             // Setconfig 
 
 int CmdLFCOTAG(const char *Cmd);
 int CmdCOTAGRead(const char *Cmd);
Impressum, Datenschutz