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);
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
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
#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() {
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.
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();
}
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) {
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:
//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;
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);
// 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);
PrintAndLog("command execution time out");
return 1;
}
- getSamples("20000", true);
+ getSamples("", true);
return 0;
}
#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);