hack for accessory support

Change-Id: I3938ab854083d65efb31176080d5c859b1154d42
diff --git a/USB_Host_Shield/Max3421e.cpp b/USB_Host_Shield/Max3421e.cpp
index 9531fe7..7b0f603 100644
--- a/USB_Host_Shield/Max3421e.cpp
+++ b/USB_Host_Shield/Max3421e.cpp
@@ -194,6 +194,7 @@
             vbusState = SE1;

             break;

         case( bmSE0 ):              //disconnected state

+		regWr( rMODE, bmDPPULLDN|bmDMPULLDN|bmHOST|bmSEPIRQ);

             vbusState = SE0;

             break;

         }//end switch( bus_sample )

diff --git a/USB_Host_Shield/Usb.cpp b/USB_Host_Shield/Usb.cpp
index 197f8cd..3449113 100644
--- a/USB_Host_Shield/Usb.cpp
+++ b/USB_Host_Shield/Usb.cpp
@@ -159,6 +159,43 @@
         }

   }//while( 1 )

 }

+

+int USB::newInTransfer( byte addr, byte ep, unsigned int nbytes, char* data, unsigned int nak_limit )

+{

+ byte rcode;

+ byte pktsize;

+ byte maxpktsize = devtable[ addr ].epinfo[ ep ].MaxPktSize; 

+ unsigned int xfrlen = 0;

+    regWr( rHCTL, devtable[ addr ].epinfo[ ep ].rcvToggle );    //set toggle value

+    while( 1 ) { // use a 'return' to exit this loop

+        rcode = dispatchPkt( tokIN, ep, nak_limit );           //IN packet to EP-'endpoint'. Function takes care of NAKS.

+        if( rcode ) {

+		return -1;                            //should be 0, indicating ACK. Else return error code.

+        }

+        /* check for RCVDAVIRQ and generate error if not present */ 

+        /* the only case when absense of RCVDAVIRQ makes sense is when toggle error occured. Need to add handling for that */

+        if(( regRd( rHIRQ ) & bmRCVDAVIRQ ) == 0 ) {

+            return -1;                            //receive error

+        }

+        pktsize = regRd( rRCVBC );                      //number of received bytes

+        data = bytesRd( rRCVFIFO, pktsize, data );

+        regWr( rHIRQ, bmRCVDAVIRQ );                    // Clear the IRQ & free the buffer

+        xfrlen += pktsize;                              // add this packet's byte count to total transfer length

+        /* The transfer is complete under two conditions:           */

+        /* 1. The device sent a short packet (L.T. maxPacketSize)   */

+        /* 2. 'nbytes' have been transferred.                       */

+        if (( pktsize < maxpktsize ) || (xfrlen >= nbytes )) {      // have we transferred 'nbytes' bytes?

+            if( regRd( rHRSL ) & bmRCVTOGRD ) {                     //save toggle value

+                devtable[ addr ].epinfo[ ep ].rcvToggle = bmRCVTOG1;

+            }

+            else {

+                devtable[ addr ].epinfo[ ep ].rcvToggle = bmRCVTOG0;

+            }

+            return xfrlen;

+        }

+  }//while( 1 )

+}

+

 /* OUT transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */

 /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer   */

 /* rcode 0 if no errors. rcode 01-0f is relayed from HRSL                       */

diff --git a/USB_Host_Shield/Usb.h b/USB_Host_Shield/Usb.h
index 2d912b8..5b27296 100644
--- a/USB_Host_Shield/Usb.h
+++ b/USB_Host_Shield/Usb.h
@@ -121,6 +121,7 @@
         byte ctrlData( byte addr, byte ep, unsigned int nbytes, char* dataptr, boolean direction, unsigned int nak_limit = USB_NAK_LIMIT );

         byte ctrlStatus( byte ep, boolean direction, unsigned int nak_limit = USB_NAK_LIMIT );

         byte inTransfer( byte addr, byte ep, unsigned int nbytes, char* data, unsigned int nak_limit = USB_NAK_LIMIT );

+		int newInTransfer( byte addr, byte ep, unsigned int nbytes, char* data, unsigned int nak_limit  = USB_NAK_LIMIT);
         byte outTransfer( byte addr, byte ep, unsigned int nbytes, char* data, unsigned int nak_limit = USB_NAK_LIMIT );

         byte dispatchPkt( byte token, byte ep, unsigned int nak_limit = USB_NAK_LIMIT );

         void Task( void );