]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/iso15693.c
client/cmdparser.c: Cosmetic changes.
[proxmark3-svn] / armsrc / iso15693.c
index a80e6c6a06cb8d7ef0d17cfafbc9c6bcb8a472ac..4c9a7d607f28c2ca2d8bb6a254d0c21ae2eb5796 100644 (file)
@@ -478,12 +478,12 @@ static void TransmitTo15693Tag(const BYTE *cmd, int len, int *samples, int *wait
        if(*wait < 10) { *wait = 10; }\r
 \r
 //    for(c = 0; c < *wait;) {\r
-//        if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-//            SSC_TRANSMIT_HOLDING = 0x00;             // For exact timing!\r
+//        if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+//            AT91C_BASE_SSC->SSC_THR = 0x00;          // For exact timing!\r
 //            c++;\r
 //        }\r
-//        if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
-//            volatile DWORD r = SSC_RECEIVE_HOLDING;\r
+//        if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
+//            volatile DWORD r = AT91C_BASE_SSC->SSC_RHR;\r
 //            (void)r;\r
 //        }\r
 //        WDT_HIT();\r
@@ -491,15 +491,15 @@ static void TransmitTo15693Tag(const BYTE *cmd, int len, int *samples, int *wait
 \r
     c = 0;\r
     for(;;) {\r
-        if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-            SSC_TRANSMIT_HOLDING = cmd[c];\r
+        if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+            AT91C_BASE_SSC->SSC_THR = cmd[c];\r
             c++;\r
             if(c >= len) {\r
                 break;\r
             }\r
         }\r
-        if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
-            volatile DWORD r = SSC_RECEIVE_HOLDING;\r
+        if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
+            volatile DWORD r = AT91C_BASE_SSC->SSC_RHR;\r
             (void)r;\r
         }\r
         WDT_HIT();\r
@@ -520,15 +520,15 @@ static void TransmitTo15693Reader(const BYTE *cmd, int len, int *samples, int *w
 \r
     c = 0;\r
     for(;;) {\r
-        if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-            SSC_TRANSMIT_HOLDING = cmd[c];\r
+        if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+            AT91C_BASE_SSC->SSC_THR = cmd[c];\r
             c++;\r
             if(c >= len) {\r
                 break;\r
             }\r
         }\r
-        if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
-            volatile DWORD r = SSC_RECEIVE_HOLDING;\r
+        if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
+            volatile DWORD r = AT91C_BASE_SSC->SSC_RHR;\r
             (void)r;\r
         }\r
         WDT_HIT();\r
@@ -550,12 +550,12 @@ static int GetIso15693AnswerFromTag(BYTE *receivedResponse, int maxLen, int *sam
        c = 0;\r
        getNext = FALSE;\r
        for(;;) {\r
-               if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-                       SSC_TRANSMIT_HOLDING = 0x43;\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+                       AT91C_BASE_SSC->SSC_THR = 0x43;\r
                }\r
-               if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
                        SBYTE b;\r
-                       b = (SBYTE)SSC_RECEIVE_HOLDING;\r
+                       b = (SBYTE)AT91C_BASE_SSC->SSC_RHR;\r
 \r
                        // The samples are correlations against I and Q versions of the\r
                        // tone that the tag AM-modulates, so every other sample is I,\r
@@ -697,12 +697,12 @@ static int GetIso15693AnswerFromSniff(BYTE *receivedResponse, int maxLen, int *s
        c = 0;\r
        getNext = FALSE;\r
        for(;;) {\r
-               if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-                       SSC_TRANSMIT_HOLDING = 0x43;\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+                       AT91C_BASE_SSC->SSC_THR = 0x43;\r
                }\r
-               if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
                        SBYTE b;\r
-                       b = (SBYTE)SSC_RECEIVE_HOLDING;\r
+                       b = (SBYTE)AT91C_BASE_SSC->SSC_RHR;\r
 \r
                        // The samples are correlations against I and Q versions of the\r
                        // tone that the tag AM-modulates, so every other sample is I,\r
@@ -855,15 +855,15 @@ void AcquireRawAdcSamplesIso15693(void)
 \r
        c = 0;\r
        for(;;) {\r
-               if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-                       SSC_TRANSMIT_HOLDING = ToSend[c];\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+                       AT91C_BASE_SSC->SSC_THR = ToSend[c];\r
                        c++;\r
                        if(c == ToSendMax+3) {\r
                                break;\r
                        }\r
                }\r
-               if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
-                       volatile DWORD r = SSC_RECEIVE_HOLDING;\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
+                       volatile DWORD r = AT91C_BASE_SSC->SSC_RHR;\r
                        (void)r;\r
                }\r
                WDT_HIT();\r
@@ -874,12 +874,12 @@ void AcquireRawAdcSamplesIso15693(void)
        c = 0;\r
        getNext = FALSE;\r
        for(;;) {\r
-               if(SSC_STATUS & (SSC_STATUS_TX_READY)) {\r
-                       SSC_TRANSMIT_HOLDING = 0x43;\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {\r
+                       AT91C_BASE_SSC->SSC_THR = 0x43;\r
                }\r
-               if(SSC_STATUS & (SSC_STATUS_RX_READY)) {\r
+               if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {\r
                        SBYTE b;\r
-                       b = (SBYTE)SSC_RECEIVE_HOLDING;\r
+                       b = (SBYTE)AT91C_BASE_SSC->SSC_RHR;\r
 \r
                        // The samples are correlations against I and Q versions of the\r
                        // tone that the tag AM-modulates, so every other sample is I,\r
@@ -926,24 +926,18 @@ void ReaderIso15693(DWORD parameter)
 \r
 //DbpString(parameter);\r
 \r
-       BYTE *receivedAnswer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)\r
-       BYTE *receivedAnswer1 = (((BYTE *)BigBuf) + 3660); //\r
-       BYTE *receivedAnswer2 = (((BYTE *)BigBuf) + 3760);\r
-       BYTE *receivedAnswer3 = (((BYTE *)BigBuf) + 3860);\r
+       //BYTE *answer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)\r
+       BYTE *answer1 = (((BYTE *)BigBuf) + 3660); //\r
+       BYTE *answer2 = (((BYTE *)BigBuf) + 3760);\r
+       BYTE *answer3 = (((BYTE *)BigBuf) + 3860);\r
        //BYTE *TagUID= (((BYTE *)BigBuf) + 3960);              // where we hold the uid for hi15reader\r
-//     int responseLen0 = 0;\r
-       int responseLen1 = 0;\r
-       int responseLen2 = 0;\r
-       int responseLen3 = 0;\r
+//     int answerLen0 = 0;\r
+       int answerLen1 = 0;\r
+       int answerLen2 = 0;\r
+       int answerLen3 = 0;\r
 \r
        // Blank arrays\r
-       int j;\r
-       for(j = 0; j < 100; j++) {\r
-               receivedAnswer3[j] = 0;\r
-               receivedAnswer2[j] =0;\r
-               receivedAnswer1[j] = 0;\r
-               receivedAnswer0[j] = 0;\r
-       }\r
+       memset(BigBuf + 3660, 0, 300);\r
 \r
        // Setup SSC\r
        FpgaSetupSsc();\r
@@ -997,24 +991,24 @@ void ReaderIso15693(DWORD parameter)
        //TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);\r
        TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);  // No longer ToSendMax+3\r
        // Now wait for a response\r
-       responseLen1 = GetIso15693AnswerFromTag(receivedAnswer1, 100, &samples, &elapsed) ;\r
+       answerLen1 = GetIso15693AnswerFromTag(answer1, 100, &samples, &elapsed) ;\r
 \r
-       if (responseLen1 >=12) // we should do a better check than this\r
+       if (answerLen1 >=12) // we should do a better check than this\r
        {\r
 \r
-               TagUID[0] = receivedAnswer1[2];\r
-               TagUID[1] = receivedAnswer1[3];\r
-               TagUID[2] = receivedAnswer1[4];\r
-               TagUID[3] = receivedAnswer1[5];\r
-               TagUID[4] = receivedAnswer1[6];\r
-               TagUID[5] = receivedAnswer1[7];\r
-               TagUID[6] = receivedAnswer1[8]; // IC Manufacturer code\r
+               TagUID[0] = answer1[2];\r
+               TagUID[1] = answer1[3];\r
+               TagUID[2] = answer1[4];\r
+               TagUID[3] = answer1[5];\r
+               TagUID[4] = answer1[6];\r
+               TagUID[5] = answer1[7];\r
+               TagUID[6] = answer1[8]; // IC Manufacturer code\r
 \r
                // Now send the SELECT command\r
                BuildSelectRequest(TagUID);\r
                TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);  // No longer ToSendMax+3\r
                // Now wait for a response\r
-               responseLen2 = GetIso15693AnswerFromTag(receivedAnswer2, 100, &samples, &elapsed);\r
+               answerLen2 = GetIso15693AnswerFromTag(answer2, 100, &samples, &elapsed);\r
 \r
                // Now send the MULTI READ command\r
 //             BuildArbitraryRequest(*TagUID,parameter);\r
@@ -1024,34 +1018,25 @@ void ReaderIso15693(DWORD parameter)
                //TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);\r
                TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);  // No longer ToSendMax+3\r
                // Now wait for a response\r
-               responseLen3 = GetIso15693AnswerFromTag(receivedAnswer3, 100, &samples, &elapsed) ;\r
+               answerLen3 = GetIso15693AnswerFromTag(answer3, 100, &samples, &elapsed) ;\r
 \r
        }\r
 \r
-       char str1 [4];\r
-       //char str2 [200];\r
-       int i;\r
+       Dbprintf("%d octets read from IDENTIFY request: %x %x %x %x %x %x %x %x %x", answerLen1,\r
+               answer1[0], answer1[1], answer1[2],\r
+               answer1[3], answer1[4], answer1[5],\r
+               answer1[6], answer1[7], answer1[8]);\r
 \r
-       itoa(responseLen1,str1);\r
-       strcat(str1," octets read from IDENTIFY request");\r
-       DbpString(str1);\r
-       for(i = 0; i < responseLen1; i+=3) {\r
-               DbpIntegers(receivedAnswer1[i],receivedAnswer1[i+1],receivedAnswer1[i+2]);\r
-       }\r
+       Dbprintf("%d octets read from SELECT request: %x %x %x %x %x %x %x %x %x", answerLen2,\r
+               answer2[0], answer2[1], answer2[2],\r
+               answer2[3], answer2[4], answer2[5],\r
+               answer2[6], answer2[7], answer2[8]);\r
 \r
-       itoa(responseLen2,str1);\r
-       strcat(str1," octets read from SELECT request");\r
-       DbpString(str1);\r
-       for(i = 0; i < responseLen2; i+=3) {\r
-               DbpIntegers(receivedAnswer2[i],receivedAnswer2[i+1],receivedAnswer2[i+2]);\r
-       }\r
+       Dbprintf("%d octets read from XXX request: %x %x %x %x %x %x %x %x %x", answerLen3,\r
+               answer3[0], answer3[1], answer3[2],\r
+               answer3[3], answer3[4], answer3[5],\r
+               answer3[6], answer3[7], answer3[8]);\r
 \r
-       itoa(responseLen3,str1);\r
-       strcat(str1," octets read from XXX request");\r
-       DbpString(str1);\r
-       for(i = 0; i < responseLen3; i+=3) {\r
-               DbpIntegers(receivedAnswer3[i],receivedAnswer3[i+1],receivedAnswer3[i+2]);\r
-       }\r
 \r
 //     str2[0]=0;\r
 //     for(i = 0; i < responseLen3; i++) {\r
@@ -1077,26 +1062,11 @@ void SimTagIso15693(DWORD parameter)
        LED_C_OFF();\r
        LED_D_OFF();\r
 \r
-//DbpString(parameter);\r
-\r
-       BYTE *receivedAnswer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)\r
-       BYTE *receivedAnswer1 = (((BYTE *)BigBuf) + 3660); //\r
-       BYTE *receivedAnswer2 = (((BYTE *)BigBuf) + 3760);\r
-       BYTE *receivedAnswer3 = (((BYTE *)BigBuf) + 3860);\r
-       //BYTE *TagUID= (((BYTE *)BigBuf) + 3960);              // where we hold the uid for hi15reader\r
-//     int responseLen0 = 0;\r
-       int responseLen1 = 0;\r
-//     int responseLen2 = 0;\r
-//     int responseLen3 = 0;\r
+       BYTE *answer1 = (((BYTE *)BigBuf) + 3660); //\r
+       int answerLen1 = 0;\r
 \r
        // Blank arrays\r
-       int j;\r
-       for(j = 0; j < 100; j++) {\r
-               receivedAnswer3[j] = 0;\r
-               receivedAnswer2[j] =0;\r
-               receivedAnswer1[j] = 0;\r
-               receivedAnswer0[j] = 0;\r
-       }\r
+       memset(answer1, 0, 100);\r
 \r
        // Setup SSC\r
        FpgaSetupSsc();\r
@@ -1122,66 +1092,19 @@ void SimTagIso15693(DWORD parameter)
        int wait = 0;\r
        int elapsed = 0;\r
 \r
-       // FIRST WE RUN AN INVENTORY TO GET THE TAG UID\r
-       // THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME\r
-       // BYTE TagUID[7];              // where we hold the uid for hi15reader\r
+       answerLen1 = GetIso15693AnswerFromSniff(answer1, 100, &samples, &elapsed) ;\r
 \r
-       // Now send the IDENTIFY command\r
-       //      BuildIdentifyRequest();\r
-       //      TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);  // No longer ToSendMax+3\r
-\r
-       // Now wait for a command from the reader\r
-       responseLen1=0;\r
-       //      while(responseLen1=0) {\r
-       //              if(BUTTON_PRESS()) break;\r
-               responseLen1 = GetIso15693AnswerFromSniff(receivedAnswer1, 100, &samples, &elapsed) ;\r
-       //              }\r
-\r
-       if (responseLen1 >=1) // we should do a better check than this\r
+       if (answerLen1 >=1) // we should do a better check than this\r
        {\r
                // Build a suitable reponse to the reader INVENTORY cocmmand\r
                BuildInventoryResponse();\r
-               TransmitTo15693Reader(ToSend,ToSendMax,&tsamples, &wait);\r
-\r
-               // Now wait for a command from the reader\r
-//             responseLen2 = GetIso15693AnswerFromTag(receivedAnswer2, 100, &samples, &elapsed);\r
-\r
-               // Now wait for a command from the reader\r
-//             responseLen3 = GetIso15693AnswerFromTag(receivedAnswer3, 100, &samples, &elapsed) ;\r
-\r
+               TransmitTo15693Reader(ToSend,ToSendMax, &tsamples, &wait);\r
        }\r
 \r
-       char str1 [4];\r
-       //char str2 [200];\r
-       int i;\r
-\r
-       itoa(responseLen1,str1);\r
-       strcat(str1," octets read from reader command");\r
-       DbpString(str1);\r
-       for(i = 0; i < responseLen1; i+=3) {\r
-               DbpIntegers(receivedAnswer1[i],receivedAnswer1[i+1],receivedAnswer1[i+2]);\r
-       }\r
-\r
-//     itoa(responseLen2,str1);\r
-//     strcat(str1," octets read from SELECT request");\r
-//     DbpString(str1);\r
-//     for(i = 0; i < responseLen2; i+=3) {\r
-//             DbpIntegers(receivedAnswer2[i],receivedAnswer2[i+1],receivedAnswer2[i+2]);\r
-//     }\r
-//\r
-//     itoa(responseLen3,str1);\r
-//     strcat(str1," octets read from XXX request");\r
-//     DbpString(str1);\r
-//     for(i = 0; i < responseLen3; i+=3) {\r
-//             DbpIntegers(receivedAnswer3[i],receivedAnswer3[i+1],receivedAnswer3[i+2]);\r
-//     }\r
-\r
-//     str2[0]=0;\r
-//     for(i = 0; i < responseLen3; i++) {\r
-//             itoa(str1,receivedAnswer3[i]);\r
-//             strcat(str2,str1);\r
-//     }\r
-//     DbpString(str2);\r
+       Dbprintf("%d octets read from reader command: %x %x %x %x %x %x %x %x %x", answerLen1,\r
+               answer1[0], answer1[1], answer1[2],\r
+               answer1[3], answer1[4], answer1[5],\r
+               answer1[6], answer1[7], answer1[8]);\r
 \r
        LED_A_OFF();\r
        LED_B_OFF();\r
Impressum, Datenschutz