X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/f62b5e1204517129be388dbdbf8041337dea53f0..2d1885f1d15a55d0c6607ec8ad9cceab8f110480:/common/usb_cdc.c

diff --git a/common/usb_cdc.c b/common/usb_cdc.c
index b413523c..9bdaed29 100644
--- a/common/usb_cdc.c
+++ b/common/usb_cdc.c
@@ -46,7 +46,8 @@ const char devDescriptor[] = {
 	/* Device descriptor */
 	0x12,      // bLength
 	0x01,      // bDescriptorType
-	0x10,0x01, // Complies with USB Spec. Release (0110h = release 1.10)
+	//0x10,0x01, // Complies with USB Spec. Release (0110h = release 1.10)
+	0x00,0x02, // Complies with USB Spec. Release (0110h = release 2.00)
 	0x02,      // bDeviceClass:    CDC class code
 	0x00,      // bDeviceSubclass: CDC class sub code
 	0x00,      // bDeviceProtocol: CDC Device protocol
@@ -304,7 +305,6 @@ bool usb_poll()
 **/
 bool usb_poll_validate_length()
 {
-
 	if (!usb_check()) return false;
 	if (!(pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank)) return false;
 	return (pUdp->UDP_CSR[AT91C_EP_OUT] >> 16) >  0;
@@ -315,26 +315,27 @@ bool usb_poll_validate_length()
 //* \brief Read available data from Endpoint OUT
 //*----------------------------------------------------------------------------
 uint32_t usb_read(byte_t* data, size_t len) {
-  byte_t bank = btReceiveBank;
+	byte_t bank = btReceiveBank;
 	uint32_t packetSize, nbBytesRcv = 0;
-  uint32_t time_out = 0;
+	uint32_t time_out = 0;
   
 	while (len)  {
 		if (!usb_check()) break;
 
 		if ( pUdp->UDP_CSR[AT91C_EP_OUT] & bank ) {
 			packetSize = MIN(pUdp->UDP_CSR[AT91C_EP_OUT] >> 16, len);
-      len -= packetSize;
+			len -= packetSize;
 			while(packetSize--)
 				data[nbBytesRcv++] = pUdp->UDP_FDR[AT91C_EP_OUT];
+			
 			pUdp->UDP_CSR[AT91C_EP_OUT] &= ~(bank);
-			if (bank == AT91C_UDP_RX_DATA_BK0) {
+			
+			if (bank == AT91C_UDP_RX_DATA_BK0)
 				bank = AT91C_UDP_RX_DATA_BK1;
-      } else {
-				bank = AT91C_UDP_RX_DATA_BK0;
-      }
+			else
+				bank = AT91C_UDP_RX_DATA_BK0;		
 		}
-    if (time_out++ == 0x1fff) break;
+		if (time_out++ == 0x1fff) break;
 	}
 
 	btReceiveBank = bank;
@@ -346,11 +347,11 @@ uint32_t usb_read(byte_t* data, size_t len) {
 //* \brief Send through endpoint 2
 //*----------------------------------------------------------------------------
 uint32_t usb_write(const byte_t* data, const size_t len) {
-  size_t length = len;
+	size_t length = len;
 	uint32_t cpt = 0;
 
-  if (!length) return 0;
-  if (!usb_check()) return 0;
+	if (!length) return 0;
+	if (!usb_check()) return 0;
   
 	// Send the first packet
 	cpt = MIN(length, AT91C_EP_IN_SIZE-1);
@@ -363,19 +364,21 @@ uint32_t usb_write(const byte_t* data, const size_t len) {
 		cpt = MIN(length, AT91C_EP_IN_SIZE-1);
 		length -= cpt;
 		while (cpt--) pUdp->UDP_FDR[AT91C_EP_IN] = *data++;
-		// Wait for the the first bank to be sent
+		// Wait for the first bank to be sent
 		while (!(pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP)) {
 			if (!usb_check()) return length;
-    }
+		}
 		pUdp->UDP_CSR[AT91C_EP_IN] &= ~(AT91C_UDP_TXCOMP);
+		
 		while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP);
+		
 		pUdp->UDP_CSR[AT91C_EP_IN] |= AT91C_UDP_TXPKTRDY;
 	}
   
 	// Wait for the end of transfer
 	while (!(pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP)) {
 		if (!usb_check()) return length;
-  }
+	}
   
 	pUdp->UDP_CSR[AT91C_EP_IN] &= ~(AT91C_UDP_TXCOMP);
 	while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP);