]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/iso15693.c
Minor bug fixes with help from Holiman.
[proxmark3-svn] / armsrc / iso15693.c
index b73ee0147ffc83cd8c3cefa68edd5169584553a7..d8bec898dece7872be78157a3ea009cf6310be7b 100644 (file)
 // *) document all the functions
 
 
 // *) document all the functions
 
 
-#include "proxmark3.h"
+#include "../include/proxmark3.h"
 #include "util.h"
 #include "apps.h"
 #include "string.h"
 #include "util.h"
 #include "apps.h"
 #include "string.h"
-#include "iso15693tools.h"
-
+#include "../common/iso15693tools.h"
+#include "../common/cmd.h"
+#include "crapto1.h"
+#include "mifareutil.h"
 
 #define arraylen(x) (sizeof(x)/sizeof((x)[0]))
 
 
 #define arraylen(x) (sizeof(x)/sizeof((x)[0]))
 
@@ -600,12 +602,13 @@ static void BuildIdentifyRequest(void);
 //-----------------------------------------------------------------------------
 void AcquireRawAdcSamplesIso15693(void)
 {
 //-----------------------------------------------------------------------------
 void AcquireRawAdcSamplesIso15693(void)
 {
+       uint8_t *dest =  mifare_get_bigbufptr();
+
        int c = 0;
        int c = 0;
-       uint8_t *dest = (uint8_t *)BigBuf;
        int getNext = 0;
        int getNext = 0;
-
        int8_t prev = 0;
 
        int8_t prev = 0;
 
+       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        BuildIdentifyRequest();
 
        SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
        BuildIdentifyRequest();
 
        SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
@@ -681,18 +684,19 @@ void AcquireRawAdcSamplesIso15693(void)
 
 void RecordRawAdcSamplesIso15693(void)
 {
 
 void RecordRawAdcSamplesIso15693(void)
 {
+       uint8_t *dest =  mifare_get_bigbufptr();
+
        int c = 0;
        int c = 0;
-       uint8_t *dest = (uint8_t *)BigBuf;
        int getNext = 0;
        int getNext = 0;
-
        int8_t prev = 0;
 
        int8_t prev = 0;
 
+       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        // Setup SSC
        FpgaSetupSsc();
 
        // Start from off (no field generated)
        // Setup SSC
        FpgaSetupSsc();
 
        // Start from off (no field generated)
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-       SpinDelay(200);
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+       SpinDelay(200);
 
        SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
 
 
        SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
 
@@ -753,6 +757,7 @@ void Iso15693InitReader() {
        LED_C_OFF();
        LED_D_OFF();
        
        LED_C_OFF();
        LED_D_OFF();
        
+       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        // Setup SSC
        // FpgaSetupSsc();
 
        // Setup SSC
        // FpgaSetupSsc();
 
@@ -1015,6 +1020,7 @@ void ReaderIso15693(uint32_t parameter)
        // Blank arrays
        memset(BigBuf + 3660, 0, 300);
 
        // Blank arrays
        memset(BigBuf + 3660, 0, 300);
 
+       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        // Setup SSC
        FpgaSetupSsc();
 
        // Setup SSC
        FpgaSetupSsc();
 
@@ -1041,7 +1047,7 @@ void ReaderIso15693(uint32_t parameter)
 
        // 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
-        uint8_t TagUID[8];             // where we hold the uid for hi15reader
+        uint8_t TagUID[8] = {0, 0, 0, 0, 0, 0, 0, 0};          // where we hold the uid for hi15reader
 
 //     BuildIdentifyRequest();
 //     //TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
 
 //     BuildIdentifyRequest();
 //     //TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
@@ -1165,6 +1171,7 @@ void SimTagIso15693(uint32_t parameter)
        // Blank arrays
        memset(answer1, 0, 100);
 
        // Blank arrays
        memset(answer1, 0, 100);
 
+       FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        // Setup SSC
        FpgaSetupSsc();
 
        // Setup SSC
        FpgaSetupSsc();
 
@@ -1260,7 +1267,7 @@ void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8
 
        int recvlen=0;
        uint8_t *recvbuf=(uint8_t *)BigBuf;
 
        int recvlen=0;
        uint8_t *recvbuf=(uint8_t *)BigBuf;
-       UsbCommand n;
+//     UsbCommand n;
        
        if (DEBUG) {
                Dbprintf("SEND");
        
        if (DEBUG) {
                Dbprintf("SEND");
@@ -1270,11 +1277,8 @@ void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8
        recvlen=SendDataTag(data,datalen,1,speed,(recv?&recvbuf:NULL));
 
        if (recv) { 
        recvlen=SendDataTag(data,datalen,1,speed,(recv?&recvbuf:NULL));
 
        if (recv) { 
-               n.cmd=/* CMD_ISO_15693_COMMAND_DONE */ CMD_ACK;
-               n.arg[0]=recvlen>48?48:recvlen;
-               memcpy(n.d.asBytes, recvbuf, 48);
                LED_B_ON();
                LED_B_ON();
-               UsbSendPacket((uint8_t *)&n, sizeof(n));
+    cmd_send(CMD_ACK,recvlen>48?48:recvlen,0,0,recvbuf,48);
                LED_B_OFF();    
                
                if (DEBUG) {
                LED_B_OFF();    
                
                if (DEBUG) {
Impressum, Datenschutz