From: iceman1001 Date: Wed, 1 Feb 2017 13:11:11 +0000 (+0100) Subject: CHG: 'lf cotag read' - it now follows "lf config" settings when collecting signaldata. X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/507afbf3e6f2f0d27d1e8ad60066d945c27ee721 CHG: 'lf cotag read' - it now follows "lf config" settings when collecting signaldata. --- diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 0dc5bcf9..1c11ad09 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -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 diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index d726ba20..0fcaf3ce 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -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) { diff --git a/client/cmdlf.c b/client/cmdlf.c index 07f3ac98..31e747d3 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -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; diff --git a/client/cmdlf.h b/client/cmdlf.h index 80297532..8764c7fc 100644 --- a/client/cmdlf.h +++ b/client/cmdlf.h @@ -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); diff --git a/client/cmdlfcotag.c b/client/cmdlfcotag.c index 1a2b2eca..5e3f28b6 100644 --- a/client/cmdlfcotag.c +++ b/client/cmdlfcotag.c @@ -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; } diff --git a/client/cmdlfcotag.h b/client/cmdlfcotag.h index 106d2eb9..37009a0b 100644 --- a/client/cmdlfcotag.h +++ b/client/cmdlfcotag.h @@ -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);