]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/appmain.c
fix warning: implicit declaration of function ‘exit’
[proxmark3-svn] / armsrc / appmain.c
index 237159c94b4691eab97bc662af5fb6efdfb5ecad..b231cae1e27b1623eb734b886aed489efe5986e7 100644 (file)
@@ -26,7 +26,7 @@ int kvsprintf(char const *fmt, void *arg, int radix, va_list ap);
 // is the order in which they go out on the wire.\r
 //=============================================================================\r
 \r
-BYTE ToSend[256];\r
+BYTE ToSend[512];\r
 int ToSendMax;\r
 static int ToSendBit;\r
 struct common_area common_area __attribute__((section(".commonarea")));\r
@@ -34,7 +34,7 @@ struct common_area common_area __attribute__((section(".commonarea")));
 void BufferClear(void)\r
 {\r
        memset(BigBuf,0,sizeof(BigBuf));\r
-       DbpString("Buffer cleared");\r
+       Dbprintf("Buffer cleared (%i bytes)",sizeof(BigBuf));\r
 }\r
 \r
 void ToSendReset(void)\r
@@ -76,6 +76,9 @@ void DbpString(char *str)
        UsbCommand c;\r
        c.cmd = CMD_DEBUG_PRINT_STRING;\r
        c.arg[0] = strlen(str);\r
+       if(c.arg[0] > sizeof(c.d.asBytes)) {\r
+               c.arg[0] = sizeof(c.d.asBytes);\r
+       }\r
        memcpy(c.d.asBytes, str, c.arg[0]);\r
 \r
        UsbSendPacket((BYTE *)&c, sizeof(c));\r
@@ -202,6 +205,27 @@ void MeasureAntennaTuning(void)
        UsbSendPacket((BYTE *)&c, sizeof(c));\r
 }\r
 \r
+void MeasureAntennaTuningHf(void)\r
+{\r
+       int vHf = 0;    // in mV\r
+\r
+       DbpString("Measuring HF antenna, press button to exit");\r
+\r
+       for (;;) {\r
+               // Let the FPGA drive the high-frequency antenna around 13.56 MHz.\r
+               FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);\r
+               SpinDelay(20);\r
+               // Vref = 3300mV, and an 10:1 voltage divider on the input\r
+               // can measure voltages up to 33000 mV\r
+               vHf = (33000 * AvgAdc(ADC_CHAN_HF)) >> 10;\r
+       \r
+               Dbprintf("%d mV",vHf);\r
+               if (BUTTON_PRESS()) break;\r
+       }\r
+       DbpString("cancelled");\r
+}\r
+\r
+\r
 void SimulateTagHfListen(void)\r
 {\r
        BYTE *dest = (BYTE *)BigBuf;\r
@@ -250,7 +274,7 @@ void SimulateTagHfListen(void)
 \r
 void ReadMem(int addr)\r
 {\r
-       const DWORD *data = ((DWORD *)addr);\r
+       const BYTE *data = ((BYTE *)addr);\r
 \r
        Dbprintf("%x: %02x %02x %02x %02x %02x %02x %02x %02x",\r
                addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);\r
@@ -544,11 +568,14 @@ void ListenReaderField(int limit)
 void UsbPacketReceived(BYTE *packet, int len)\r
 {\r
        UsbCommand *c = (UsbCommand *)packet;\r
+       UsbCommand ack;\r
+       ack.cmd = CMD_ACK;\r
 \r
        switch(c->cmd) {\r
 #ifdef WITH_LF\r
                case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K:\r
                        AcquireRawAdcSamples125k(c->arg[0]);\r
+                       UsbSendPacket((BYTE*)&ack, sizeof(ack));\r
                        break;\r
 #endif\r
 \r
@@ -575,8 +602,8 @@ void UsbPacketReceived(BYTE *packet, int len)
 #endif\r
 \r
                case CMD_READER_LEGIC_RF:\r
-                       LegicRfReader();\r
-                       break;\r
+                       LegicRfReader(c->arg[0], c->arg[1]);\r
+                       break;
 \r
 #ifdef WITH_ISO15693\r
                case CMD_SIMTAG_ISO_15693:\r
@@ -643,6 +670,10 @@ void UsbPacketReceived(BYTE *packet, int len)
                        MeasureAntennaTuning();\r
                        break;\r
 \r
+               case CMD_MEASURE_ANTENNA_TUNING_HF:\r
+                       MeasureAntennaTuningHf();\r
+                       break;\r
+\r
                case CMD_LISTEN_READER_FIELD:\r
                        ListenReaderField(c->arg[0]);\r
                        break;\r
@@ -693,13 +724,15 @@ void UsbPacketReceived(BYTE *packet, int len)
                case CMD_DOWNLOADED_SIM_SAMPLES_125K: {\r
                        BYTE *b = (BYTE *)BigBuf;\r
                        memcpy(b+c->arg[0], c->d.asBytes, 48);\r
+                       //Dbprintf("copied 48 bytes to %i",b+c->arg[0]);\r
+                       UsbSendPacket((BYTE*)&ack, sizeof(ack));\r
                        break;\r
                }\r
 \r
 #ifdef WITH_LF\r
                case CMD_SIMULATE_TAG_125K:\r
                        LED_A_ON();\r
-                       SimulateTagLowFrequency(c->arg[0], 1);\r
+                       SimulateTagLowFrequency(c->arg[0], c->arg[1], 1);\r
                        LED_A_OFF();\r
                        break;\r
 #endif\r
@@ -769,7 +802,7 @@ void UsbPacketReceived(BYTE *packet, int len)
                }\r
                        break;\r
                default:\r
-                       DbpString("unknown command");\r
+                       Dbprintf("%s: 0x%04x","unknown command:",c->cmd);\r
                        break;\r
        }\r
 }\r
Impressum, Datenschutz