]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/iso15693.c
Fix gcc10 compiler warnings
[proxmark3-svn] / armsrc / iso15693.c
index 351b01846bb20e63d22ac632674ec1d472d42311..f16698bbb901f66120d67a528f6a077fad2118bc 100644 (file)
@@ -58,7 +58,7 @@
 #include "string.h"
 #include "iso15693tools.h"
 #include "protocols.h"
 #include "string.h"
 #include "iso15693tools.h"
 #include "protocols.h"
-#include "cmd.h"
+#include "usb_cdc.h"
 #include "BigBuf.h"
 #include "fpgaloader.h"
 
 #include "BigBuf.h"
 #include "fpgaloader.h"
 
@@ -291,7 +291,6 @@ void TransmitTo15693Tag(const uint8_t *cmd, int len, uint32_t *start_time) {
                        AT91C_BASE_SSC->SSC_THR = send_word;
                        while (!(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))) ;
                        AT91C_BASE_SSC->SSC_THR = send_word;
                        AT91C_BASE_SSC->SSC_THR = send_word;
                        while (!(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))) ;
                        AT91C_BASE_SSC->SSC_THR = send_word;
-
                        data <<= 1;
                }
                WDT_HIT();
                        data <<= 1;
                }
                WDT_HIT();
@@ -299,7 +298,6 @@ void TransmitTo15693Tag(const uint8_t *cmd, int len, uint32_t *start_time) {
        LED_B_OFF();
 
        *start_time = *start_time + DELAY_ARM_TO_TAG;
        LED_B_OFF();
 
        *start_time = *start_time + DELAY_ARM_TO_TAG;
-
 }
 
 
 }
 
 
@@ -370,7 +368,7 @@ void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time,
 //          false if we are still waiting for some more
 //=============================================================================
 
 //          false if we are still waiting for some more
 //=============================================================================
 
-#define NOISE_THRESHOLD          160                   // don't try to correlate noise
+#define NOISE_THRESHOLD          80                   // don't try to correlate noise
 #define MAX_PREVIOUS_AMPLITUDE   (-1 - NOISE_THRESHOLD)
 
 typedef struct DecodeTag {
 #define MAX_PREVIOUS_AMPLITUDE   (-1 - NOISE_THRESHOLD)
 
 typedef struct DecodeTag {
@@ -1357,20 +1355,23 @@ void SnoopIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
 
 
 // Initialize the proxmark as iso15k reader
 
 
 // Initialize the proxmark as iso15k reader
-void Iso15693InitReader() {
+void Iso15693InitReader(void) {
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
-       // Start from off (no field generated)
-       LED_D_OFF();
+       // switch field off and wait until tag resets
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+       LED_D_OFF();
        SpinDelay(10);
 
        SpinDelay(10);
 
-       SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
+       // switch field on
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
+       LED_D_ON();
+       
+       // initialize SSC and select proper AD input
        FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
        FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
+       SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
 
 
-       // Give the tags time to energize
-       LED_D_ON();
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
+       // give tags some time to energize
        SpinDelay(250);
 }
 
        SpinDelay(250);
 }
 
@@ -1573,26 +1574,8 @@ void ReaderIso15693(uint32_t parameter) {
        set_tracing(true);
 
        uint8_t TagUID[8] = {0x00};
        set_tracing(true);
 
        uint8_t TagUID[8] = {0x00};
-
-       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
-
        uint8_t answer[ISO15693_MAX_RESPONSE_LENGTH];
 
        uint8_t answer[ISO15693_MAX_RESPONSE_LENGTH];
 
-       SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
-       // Setup SSC
-       FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
-
-       // Start from off (no field generated)
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-       SpinDelay(200);
-
-       // Give the tags time to energize
-       LED_D_ON();
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
-       SpinDelay(200);
-       StartCountSspClk();
-
-
        // FIRST WE RUN AN INVENTORY TO GET THE TAG UID
        // THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
 
        // FIRST WE RUN AN INVENTORY TO GET THE TAG UID
        // THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
 
@@ -1650,6 +1633,17 @@ void ReaderIso15693(uint32_t parameter) {
 }
 
 
 }
 
 
+// Initialize the proxmark as iso15k tag
+void Iso15693InitTag(void) {
+       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
+       SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_NO_MODULATION);
+       LED_D_OFF();
+       FpgaSetupSsc(FPGA_MAJOR_MODE_HF_SIMULATOR);
+       StartCountSspClk();
+}
+
+
 // Simulate an ISO15693 TAG.
 // For Inventory command: print command and send Inventory Response with given UID
 // TODO: interpret other reader commands and send appropriate response
 // Simulate an ISO15693 TAG.
 // For Inventory command: print command and send Inventory Response with given UID
 // TODO: interpret other reader commands and send appropriate response
@@ -1657,20 +1651,14 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid) {
 
        LED_A_ON();
 
 
        LED_A_ON();
 
-       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
-       SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_NO_MODULATION);
-       FpgaSetupSsc(FPGA_MAJOR_MODE_HF_SIMULATOR);
-
-       StartCountSspClk();
-
-       uint8_t cmd[ISO15693_MAX_COMMAND_LENGTH];
+       Iso15693InitTag();
 
        // Build a suitable response to the reader INVENTORY command
        BuildInventoryResponse(uid);
 
        // Listen to reader
        while (!BUTTON_PRESS()) {
 
        // Build a suitable response to the reader INVENTORY command
        BuildInventoryResponse(uid);
 
        // Listen to reader
        while (!BUTTON_PRESS()) {
+               uint8_t cmd[ISO15693_MAX_COMMAND_LENGTH];
                uint32_t eof_time = 0, start_time = 0;
                int cmd_len = GetIso15693CommandFromReader(cmd, sizeof(cmd), &eof_time);
 
                uint32_t eof_time = 0, start_time = 0;
                int cmd_len = GetIso15693CommandFromReader(cmd, sizeof(cmd), &eof_time);
 
Impressum, Datenschutz