CHG: 'lf cotag read' - it now follows "lf config" settings when collecting signaldata.

This commit is contained in:
iceman1001 2017-02-01 14:11:11 +01:00
commit 507afbf3e6
6 changed files with 41 additions and 32 deletions

View file

@ -43,7 +43,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t periods, uint3
uint16_t period_0 = periods >> 16; uint16_t period_0 = periods >> 16;
uint16_t period_1 = periods & 0xFFFF; 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; int divisor_used = (useHighFreq) ? 88 : 95;
sample_config sc = { 0,0,1, divisor_used, 0}; sample_config sc = { 0,0,1, divisor_used, 0};
setSamplingConfig(&sc); setSamplingConfig(&sc);
@ -1742,8 +1742,9 @@ void EM4xWriteWord(uint32_t Data, uint8_t Address, uint32_t Pwd, uint8_t PwdMode
void Cotag() { void Cotag() {
//#define WAIT2200 { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2035); } #define OFF { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2035); }
#define WAIT2200 { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); WaitUS(2200); } //#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(); LED_A_ON();
//clear buffer now so it does not interfere with timing later //clear buffer now so it does not interfere with timing later
@ -1764,26 +1765,23 @@ void Cotag() {
StartTicks(); StartTicks();
//send start pulse //send start pulse
TurnReadLFOn(800); WAIT2200 ON(740) OFF
TurnReadLFOn(3600); WAIT2200 ON(3330) OFF
TurnReadLFOn(800); WAIT2200 ON(740) OFF
TurnReadLFOn(3600); ON(1000)
/* /*
TurnReadLFOn(740); WAIT2200 ON(800) OFF
TurnReadLFOn(3330); WAIT2200 ON(3600) OFF
TurnReadLFOn(740); WAIT2200 ON(800) OFF
TurnReadLFOn(3330); ON(1000)
burst 800 us, gap 2.2 msecs burst 800 us, gap 2.2 msecs
burst 3.6 msecs gap 2.2 msecs burst 3.6 msecs gap 2.2 msecs
burst 800 us gap 2.2 msecs burst 800 us gap 2.2 msecs
pulse 3.6 msecs pulse 3.6 msecs
*/ */
DoAcquisition_config(FALSE);
// Acquisition
DoAcquisition_default(-1, true);
// Turn the field off // Turn the field off
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off

View file

@ -8,6 +8,14 @@
#include "lfsampling.h" #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 } ; sample_config config = { 1, 8, 1, 95, 0 } ;
void printConfig() { void printConfig() {
@ -15,11 +23,10 @@ void printConfig() {
Dbprintf(" [q] divisor: %d ", config.divisor); Dbprintf(" [q] divisor: %d ", config.divisor);
Dbprintf(" [b] bps: %d ", config.bits_per_sample); Dbprintf(" [b] bps: %d ", config.bits_per_sample);
Dbprintf(" [d] decimation: %d ", config.decimation); 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); Dbprintf(" [t] trigger threshold: %d ", config.trigger_threshold);
} }
/** /**
* Called from the USB-handler to set the sampling configuration * Called from the USB-handler to set the sampling configuration
* The sampling config is used for std reading and snooping. * The sampling config is used for std reading and snooping.
@ -34,12 +41,11 @@ void printConfig() {
void setSamplingConfig(sample_config *sc) { void setSamplingConfig(sample_config *sc) {
if(sc->divisor != 0) config.divisor = sc->divisor; if(sc->divisor != 0) config.divisor = sc->divisor;
if(sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample; 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; if(sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
config.decimation = (sc->decimation != 0) ? sc->decimation : 1;
config.averaging = sc->averaging; config.averaging = sc->averaging;
if(config.bits_per_sample > 8) config.bits_per_sample = 8; if(config.bits_per_sample > 8) config.bits_per_sample = 8;
if(config.decimation < 1) config.decimation = 1;
printConfig(); 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() ) { while(!BUTTON_PRESS() && !usb_poll_validate_length() ) {
WDT_HIT(); WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) { 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(); LED_D_ON();
} }
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) { if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {

View file

@ -531,13 +531,12 @@ int CmdLFSetConfig(const char *Cmd) {
//Validations //Validations
if (errors) return usage_lf_config(); 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; if (bps >> 4) bps = 8;
sample_config config = { decimation, bps, averaging, divisor, trigger_threshold }; 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, {0,0,0} };
UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG};
memcpy(c.d.asBytes, &config, sizeof(sample_config)); memcpy(c.d.asBytes, &config, sizeof(sample_config));
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);

View file

@ -46,6 +46,8 @@
int CmdLF(const char *Cmd); int CmdLF(const char *Cmd);
int CmdLFSetConfig(const char *Cmd);
int CmdLFCommandRead(const char *Cmd); int CmdLFCommandRead(const char *Cmd);
int CmdFlexdemod(const char *Cmd); int CmdFlexdemod(const char *Cmd);
int CmdIndalaDemod(const char *Cmd); int CmdIndalaDemod(const char *Cmd);

View file

@ -15,6 +15,8 @@ int CmdCOTAGRead(const char *Cmd) {
// if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_cotag_read(); // if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_cotag_read();
CmdLFSetConfig("q 89");
UsbCommand c = {CMD_COTAG, {0, 0, 0}}; UsbCommand c = {CMD_COTAG, {0, 0, 0}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
@ -22,7 +24,7 @@ int CmdCOTAGRead(const char *Cmd) {
PrintAndLog("command execution time out"); PrintAndLog("command execution time out");
return 1; return 1;
} }
getSamples("20000", true); getSamples("", true);
return 0; return 0;
} }

View file

@ -16,6 +16,8 @@
#include "cmddata.h" // getSamples #include "cmddata.h" // getSamples
#include "cmdparser.h" // CmdsParse, CmdsHelp #include "cmdparser.h" // CmdsParse, CmdsHelp
#include "cmdmain.h" #include "cmdmain.h"
#include "ui.h" // PrintAndLog
#include "cmdlf.h" // Setconfig
int CmdLFCOTAG(const char *Cmd); int CmdLFCOTAG(const char *Cmd);
int CmdCOTAGRead(const char *Cmd); int CmdCOTAGRead(const char *Cmd);