]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/lfops.c
Add printf, and start transitioning away from DbpInteger
[proxmark3-svn] / armsrc / lfops.c
index c2d908dfebb55cf06b8b14cfec36c4f3496d7741..6c9a36f7e51f42019173256eef92c3001f1251a5 100644 (file)
@@ -9,6 +9,8 @@
 #include "hitag2.h"\r
 #include "../common/crc16.c"\r
 \r
+int sprintf(char *dest, const char *fmt, ...);\r
+\r
 void AcquireRawAdcSamples125k(BOOL at134khz)\r
 {\r
        if(at134khz) {\r
@@ -38,24 +40,25 @@ void DoAcquisition125k(BOOL at134khz)
        BYTE *dest = (BYTE *)BigBuf;\r
        int n = sizeof(BigBuf);\r
        int i;\r
-\r
+       char output_string[64];\r
+       \r
        memset(dest,0,n);\r
        i = 0;\r
        for(;;) {\r
-               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+               if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {\r
                        AT91C_BASE_SSC->SSC_THR = 0x43;\r
                        LED_D_ON();\r
                }\r
-               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
+               if(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {\r
                        dest[i] = (BYTE)AT91C_BASE_SSC->SSC_RHR;\r
                        i++;\r
                        LED_D_OFF();\r
-                       if(i >= n) {\r
-                               break;\r
-                       }\r
+                       if (i >= n) break;\r
                }\r
        }\r
-       DbpIntegers(dest[0], dest[1], at134khz);\r
+       sprintf(output_string, "read samples, dest[0]=%x dest[1]=%x at134khz=%d",\r
+               dest[0], dest[1], at134khz);\r
+       DbpString(output_string);\r
 }\r
 \r
 void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYTE *command)\r
@@ -254,11 +257,13 @@ void ReadTItag()
                crc = update_crc16(crc, (shift1>>16)&0xff);\r
                crc = update_crc16(crc, (shift1>>24)&0xff);\r
 \r
-               DbpString("Info: Tag data_hi, data_lo, crc = ");\r
-               DbpIntegers(shift1, shift0, shift2&0xffff);\r
+               char output_string[64];\r
+               sprintf(output_string, "Info: Tag data_hi=%x, data_lo=%x, crc=%x",\r
+                       (unsigned int)shift1, (unsigned int)shift0, (unsigned int)shift2 & 0xFFFF);\r
+               DbpString(output_string);\r
                if (crc != (shift2&0xffff)) {\r
-                       DbpString("Error: CRC mismatch, expected");\r
-                       DbpIntegers(0, 0, crc);\r
+                       sprintf(output_string, "Error: CRC mismatch, expected %x", (unsigned int)crc);\r
+                       DbpString(output_string);\r
                } else {\r
                        DbpString("Info: CRC is good");\r
                }\r
@@ -381,8 +386,10 @@ void WriteTItag(DWORD idhi, DWORD idlo, WORD crc)
                crc = update_crc16(crc, (idhi>>16)&0xff);\r
                crc = update_crc16(crc, (idhi>>24)&0xff);\r
        }\r
-       DbpString("Writing the following data to tag:");\r
-       DbpIntegers(idhi, idlo, crc);\r
+       char output_string[64];\r
+       sprintf(output_string, "Writing the following data to tag: %x, %x, %x",\r
+               (unsigned int) idhi, (unsigned int) idlo, crc);\r
+       DbpString(output_string);\r
 \r
        // TI tags charge at 134.2Khz\r
        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz\r
@@ -395,7 +402,7 @@ void WriteTItag(DWORD idhi, DWORD idlo, WORD crc)
 \r
        // steal this pin from the SSP and use it to control the modulation\r
        AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT;\r
-       AT91C_BASE_PIOA->PIO_OER        = GPIO_SSC_DOUT;\r
+       AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;\r
 \r
        // writing algorithm:\r
        // a high bit consists of a field off for 1ms and field on for 1ms\r
@@ -926,8 +933,10 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
                                found=1;\r
                                idx+=6;\r
                                if (found && (hi|lo)) {\r
-                                       DbpString("TAG ID");\r
-                                       DbpIntegers(hi, lo, (lo>>1)&0xffff);\r
+                                       char output_string[64];\r
+                                       sprintf(output_string, "TAG ID: %x %x %x", \r
+                                               (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF);\r
+                                       DbpString(output_string);\r
                                        /* if we're only looking for one tag */\r
                                        if (findone)\r
                                        {\r
@@ -959,8 +968,10 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
                                found=1;\r
                                idx+=6;\r
                                if (found && (hi|lo)) {\r
-                                       DbpString("TAG ID");\r
-                                       DbpIntegers(hi, lo, (lo>>1)&0xffff);\r
+                                       char output_string[64];\r
+                                       sprintf(output_string, "TAG ID: %x %x %x", \r
+                                               (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF);\r
+                                       DbpString(output_string);\r
                                        /* if we're only looking for one tag */\r
                                        if (findone)\r
                                        {\r
Impressum, Datenschutz