diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 9c109b978..e6b86b25f 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -229,7 +229,8 @@ void MeasureAntennaTuning(void) { FpgaDownloadAndGo(FPGA_BITSTREAM_LF); FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD); - + SpinDelay(50); + for (i = 255; i >= 19; i--) { WDT_HIT(); FpgaSendCommand(FPGA_CMD_SET_DIVISOR, i); diff --git a/armsrc/hfsnoop.c b/armsrc/hfsnoop.c index 5126d1886..fcf8e6090 100644 --- a/armsrc/hfsnoop.c +++ b/armsrc/hfsnoop.c @@ -41,7 +41,7 @@ void HfSnoop(int samplesToSkip, int triggersToSkip) // connect Demodulated Signal to ADC: SetAdcMuxFor(GPIO_MUXSEL_HIPKD); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SNOOP); - SpinDelay(100); + SpinDelay(50); AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16); // Setting Frame Mode For better performance on high speed data transfer. diff --git a/armsrc/hitag2.c b/armsrc/hitag2.c index eb5fed8d7..4b5efdcd3 100644 --- a/armsrc/hitag2.c +++ b/armsrc/hitag2.c @@ -1000,6 +1000,7 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) { // Set up simulator mode, frequency divisor which will drive the FPGA // and analog mux selection. FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT); + SpinDelay(50); FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz SetAdcMuxFor(GPIO_MUXSEL_LOPKD); RELAY_OFF(); @@ -1230,7 +1231,8 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) { // Set fpga in edge detect with reader field, we can modulate as reader now FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_READER_FIELD); - + SpinDelay(20); + // Set Frequency divisor which will drive the FPGA and analog mux selection FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz SetAdcMuxFor(GPIO_MUXSEL_LOPKD); diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c index b3d7604ce..ee4dc7d61 100644 --- a/armsrc/hitagS.c +++ b/armsrc/hitagS.c @@ -1026,6 +1026,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, byte_t* data) { // and analog mux selection. FpgaDownloadAndGo(FPGA_BITSTREAM_LF); FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT); + SpinDelay(20); FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz SetAdcMuxFor(GPIO_MUXSEL_LOPKD); RELAY_OFF(); @@ -1863,7 +1864,8 @@ void check_challenges(bool file_given, byte_t* data) { // Set fpga in edge detect with reader field, we can modulate as reader now FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_READER_FIELD); - + SpinDelay(50); + // Set Frequency divisor which will drive the FPGA and analog mux selection FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz SetAdcMuxFor(GPIO_MUXSEL_LOPKD); diff --git a/armsrc/iclass.c b/armsrc/iclass.c index f460f7da5..8a47ff2d1 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -690,6 +690,7 @@ void RAMFUNC SnoopIClass(void) // Signal field is off with the appropriate LED LED_D_OFF(); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_SNIFFER); + SpinDelay(20); SetAdcMuxFor(GPIO_MUXSEL_HIPKD); uint32_t time_0 = GetCountSspClk(); @@ -833,7 +834,7 @@ static int GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen) // Signal field is off with the appropriate LED LED_D_OFF(); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_TAGSIM_LISTEN); - + // Now run a `software UART' on the stream of incoming samples. Uart.output = received; Uart.byteCntMax = maxLen; @@ -1154,7 +1155,7 @@ int doIClassSimulation( int simulationMode, uint8_t *reader_mac_buf) //FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); //SpinDelay(200); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_TAGSIM_LISTEN); - SpinDelay(100); + SpinDelay(20); StartCountSspClk(); // We need to listen to the high-frequency, peak-detected path. SetAdcMuxFor(GPIO_MUXSEL_HIPKD); @@ -1348,7 +1349,7 @@ static int SendIClassAnswer(uint8_t *resp, int respLen, int delay) //FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR|FPGA_HF_SIMULATOR_MODULATE_424K); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR|FPGA_HF_SIMULATOR_MODULATE_424K_8BIT); - + AT91C_BASE_SSC->SSC_THR = 0x00; FpgaSetupSsc(); while(!BUTTON_PRESS()) { diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 5437a615a..f9882694a 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1994,7 +1994,8 @@ void iso14443a_setup(uint8_t fpga_minor_mode) { LED_D_ON(); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | fpga_minor_mode); - + SpinDelay(50); + // Start the timer StartCountSspClk(); diff --git a/armsrc/lfops.c b/armsrc/lfops.c index e2397a028..e0536236e 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -400,9 +400,9 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol) int i = 0; uint8_t *buf = BigBuf_get_addr(); - //FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT); FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_TOGGLE_MODE ); - + SpinDelay(20); + // set frequency, get values from 'lf config' command sample_config *sc = getSamplingConfig(); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 12271fda9..ac274f56c 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -985,7 +985,7 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) { set_tracing(true); - for (i = 0; i < keyCount; ++i) { + for (i = 0; i < keyCount; i++) { //mifare_classic_halt(pcs, cuid); @@ -993,7 +993,7 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) { if (!have_uid) { // need a full select cycle to get the uid first iso14a_card_select_t card_info; if(!iso14443a_select_card(uid, &card_info, &cuid, true, 0)) { - if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card (ALL)"); + //if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card (ALL)"); --i; // try same key once again continue; } @@ -1006,7 +1006,7 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) { have_uid = true; } else { // no need for anticollision. We can directly select the card if(!iso14443a_select_card(uid, NULL, NULL, false, cascade_levels)) { - if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card (UID)"); + //if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card (UID)"); --i; // try same key once again continue; } diff --git a/armsrc/pcf7931.c b/armsrc/pcf7931.c index df8b1a96a..c9ce432c9 100644 --- a/armsrc/pcf7931.c +++ b/armsrc/pcf7931.c @@ -390,7 +390,7 @@ void SendCmdPCF7931(uint32_t * tab){ FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_PASSTHRU ); - + LED_A_ON(); // steal this pin from the SSP and use it to control the modulation