mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 23:36:31 +08:00
CHG: 'lf cotag read' - it now follows "lf config" settings when collecting signaldata.
This commit is contained in:
parent
d760c7b3d9
commit
507afbf3e6
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue