]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - common/usb.c
added missing files, part2
[proxmark3-svn] / common / usb.c
index 6c5207d622cc55d1b5e6849d92d7d925a4c774a9..e1fc9b25b0dee3aca104dc6c542aafedd6fd275a 100644 (file)
@@ -1,9 +1,14 @@
 //-----------------------------------------------------------------------------
-// My USB driver. This has to be common, because it exists in both the
-// bootrom and the application.
 // Jonathan Westhues, split Aug 14 2005
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
 //-----------------------------------------------------------------------------
-#include <proxmark3.h>
+// The common USB driver used for both the bootloader and the application.
+//-----------------------------------------------------------------------------
+
+#include "proxmark3.h"
 
 #define min(a, b) (((a) > (b)) ? (b) : (a))
 
@@ -90,7 +95,7 @@ static const uint8_t DeviceDescriptor[] = {
        0x01,0x00,              // Device release number (0001)
        0x01,                   // Manufacturer string descriptor index
        0x02,                   // Product string descriptor index
-       0x00,                   // Serial Number string descriptor index (None)
+       0x03,                   // Serial Number string descriptor index
        0x01,                   // Number of possible configurations (1)
 };
 
@@ -196,10 +201,26 @@ static const uint8_t StringDescriptor2[] = {
        't', 0x00,
 };
 
+// Serial Number
+// TODO: Pick yours! Don't forget to modify the length, if needed.
+static const uint8_t StringDescriptor3[] = {
+       18,             // Length
+       0x03,           // Type is string
+       'C', 0x00,
+       'h', 0x00,
+       'a', 0x00,
+       'n', 0x00,
+       'g', 0x00,
+       'e', 0x00,
+       'M', 0x00,
+       'e', 0x00,
+};
+
 static const uint8_t * const StringDescriptors[] = {
        StringDescriptor0,
        StringDescriptor1,
        StringDescriptor2,
+       StringDescriptor3,
 };
 
 
@@ -380,12 +401,15 @@ void UsbSendPacket(uint8_t *packet, int len)
                }
                AT91C_BASE_UDP->UDP_CSR[2] |= AT91C_UDP_TXPKTRDY;
 
-               while(!(AT91C_BASE_UDP->UDP_CSR[2] & AT91C_UDP_TXCOMP))
-                       ;
+               while(!(AT91C_BASE_UDP->UDP_CSR[2] & AT91C_UDP_TXCOMP)) {
+            WDT_HIT();
+        }
+
                AT91C_BASE_UDP->UDP_CSR[2] &= ~AT91C_UDP_TXCOMP;
 
-               while(AT91C_BASE_UDP->UDP_CSR[2] & AT91C_UDP_TXCOMP)
-                       ;
+               while(AT91C_BASE_UDP->UDP_CSR[2] & AT91C_UDP_TXCOMP) {
+            WDT_HIT();
+        }
 
                len -= thisTime;
                packet += thisTime;
@@ -405,8 +429,9 @@ static void HandleRxdData(void)
                }
 
                AT91C_BASE_UDP->UDP_CSR[1] &= ~AT91C_UDP_RX_DATA_BK0;
-               while(AT91C_BASE_UDP->UDP_CSR[1] & AT91C_UDP_RX_DATA_BK0)
-                       ;
+               while(AT91C_BASE_UDP->UDP_CSR[1] & AT91C_UDP_RX_DATA_BK0) {
+            WDT_HIT();
+        }
 
                if(UsbSoFarCount >= 64) {
                        UsbPacketReceived(UsbBuffer, UsbSoFarCount);
@@ -423,14 +448,17 @@ static void HandleRxdData(void)
                }
 
                AT91C_BASE_UDP->UDP_CSR[1] &= ~AT91C_UDP_RX_DATA_BK1;
-               while(AT91C_BASE_UDP->UDP_CSR[1] & AT91C_UDP_RX_DATA_BK1)
-                       ;
-
+               while(AT91C_BASE_UDP->UDP_CSR[1] & AT91C_UDP_RX_DATA_BK1) {
+            WDT_HIT();
+        }
+        
                if(UsbSoFarCount >= 64) {
                        UsbPacketReceived(UsbBuffer, UsbSoFarCount);
                        UsbSoFarCount = 0;
                }
        }
+    
+    WDT_HIT();
 }
 
 void UsbStart(void)
Impressum, Datenschutz