From 389c6115e3cba8dbfee96292e93e5dfbc3f8ff8e Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Mon, 6 Feb 2012 07:49:01 -0700 Subject: [PATCH] Xoom compatibility --- Usb.h | 6 ++++++ adk.cpp | 30 +++++++++++++++++++++++------- adk.h | 4 ++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Usb.h b/Usb.h index 9432b4b0..c0953f3b 100644 --- a/Usb.h +++ b/Usb.h @@ -47,8 +47,14 @@ e-mail : support@circuitsathome.com /* shield pins. First parameter - SS pin, second parameter - INT pin */ +#if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) +#define BOARD_TEENSY_PLUS_PLUS +#endif + #ifdef BOARD_BLACK_WIDDOW typedef MAX3421e MAX3421E; // Black Widow +#elif defined(BOARD_TEENSY_PLUS_PLUS) +typedef MAX3421e MAX3421E; // Teensy++ 2.0 & 1.0 #elif defined(BOARD_MEGA_ADK) typedef MAX3421e MAX3421E; // Arduino Mega ADK #else diff --git a/adk.cpp b/adk.cpp index d85fc56c..1304992a 100644 --- a/adk.cpp +++ b/adk.cpp @@ -49,8 +49,8 @@ ADK::ADK(USB *p, const char* manufacturer, epInfo[i].epAddr = 0; epInfo[i].maxPktSize = (i) ? 0 : 8; epInfo[i].epAttribs = 0; - //epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - epInfo[i].bmNakPower = USB_NAK_MAX_POWER; + epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; + //epInfo[i].bmNakPower = USB_NAK_MAX_POWER; }//for(uint8_t i=0; i confDescrParser(this); + delay(1); rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); +#if defined(XOOM) + //added by Jaylen Scott Vanorden + if( rcode ) { + USBTRACE2("\r\nGot 1st bad code for config: ", rcode); + // Try once more + rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); + } +#endif if( rcode ) { goto FailGetConfDescr; } @@ -172,9 +181,7 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) goto FailSetDevTblEntry; } } - - - + // Set Configuration Value rcode = pUsb->setConf(bAddress, 0, bConfNum); if( rcode ){ @@ -200,13 +207,22 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) return 0; //successful configuration }//if( buf->idVendor == ADK_VID... - delay(20); //testing compatibility w/Motorola Xoom + //delay(20); //testing compatibility w/Motorola Xoom //probe device - get accessory protocol revision { uint16_t adkproto = -1; + delay(1); rcode = getProto((uint8_t*)&adkproto ); - if( rcode ){ +#if defined(XOOM) + //added by Jaylen Scott Vanorden + if( rcode ) { + USBTRACE2("\r\nGot 1st bad code for proto: ", rcode); + // Try once more + rcode = getProto((uint8_t*)&adkproto ); + } +#endif + if( rcode ){ goto FailGetProto; //init fails } USBTRACE2("\r\nADK protocol rev. ", adkproto ); diff --git a/adk.h b/adk.h index 06d0ae2e..8084decb 100644 --- a/adk.h +++ b/adk.h @@ -44,6 +44,10 @@ e-mail : support@circuitsathome.com #define ADK_PID 0x2D00 #define ADB_PID 0x2D01 +#define XOOM //enables repeating getProto() and getConf() attempts + //necessary for slow devices such as Motorola XOOM + //defined by default, can be commented out to save memory + /* requests */ #define ADK_GETPROTO 51 //check USB accessory protocol version