From c86e258916297b98fc7106841df714c6ede2a1d8 Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Thu, 1 Mar 2012 19:54:13 -0700 Subject: [PATCH] regression --- Usb.h | 10 +++++++++- adk.cpp | 26 +++++++++++++++++++++----- adk.h | 6 +++++- avrpins.h | 5 +++++ confdescparser.h | 2 +- usbhost.h | 5 +++++ 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Usb.h b/Usb.h index 341c1368..c0953f3b 100644 --- a/Usb.h +++ b/Usb.h @@ -47,8 +47,16 @@ 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 typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560 #endif @@ -272,4 +280,4 @@ inline uint8_t USB::setConf( uint8_t addr, uint8_t ep, uint8_t conf_value ) #endif // defined(USB_METHODS_INLINE) -#endif //_usb_h_ \ No newline at end of file +#endif //_usb_h_ diff --git a/adk.cpp b/adk.cpp index e846d611..f18531c8 100644 --- a/adk.cpp +++ b/adk.cpp @@ -48,12 +48,10 @@ ADK::ADK(USB *p, const char* manufacturer, for(uint8_t i=0; iRegisterDeviceClass(this); //set devConfig[] entry @@ -157,7 +155,16 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) 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; } @@ -204,7 +211,16 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) //probe device - get accessory protocol revision { uint16_t adkproto = -1; + delay(1); rcode = getProto((uint8_t*)&adkproto ); +#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 } diff --git a/adk.h b/adk.h index 024b013b..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 @@ -105,7 +109,7 @@ public: const char* uri, const char* serial); - // Methods for recieving and sending data + // Methods for receiving and sending data uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr); uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); diff --git a/avrpins.h b/avrpins.h index 99e10776..a6ea90c2 100644 --- a/avrpins.h +++ b/avrpins.h @@ -20,6 +20,10 @@ e-mail : support@circuitsathome.com #ifndef _avrpins_h_ #define _avrpins_h_ +/* Uncomment the following if you have Arduino Mega ADK board with MAX3421e built-in */ +//#define BOARD_MEGA_ADK + + #include #ifdef PORTA @@ -465,6 +469,7 @@ template #define P51 Pb2 #define P52 Pb1 #define P53 Pb0 +#define P54 Pj2 #endif //"Mega" pin numbers diff --git a/confdescparser.h b/confdescparser.h index 0c215227..3d82f349 100644 --- a/confdescparser.h +++ b/confdescparser.h @@ -110,7 +110,7 @@ bool ConfigDescParser::ParseDescriptor dscrType = *((uint8_t*)theBuffer.pValue + 1); stateParseDescr = 2; case 2: - // This is a sort of hack. Assuming that two bytes are allready in the buffer + // This is a sort of hack. Assuming that two bytes are already in the buffer // the pointer is positioned two bytes ahead in order for the rest of descriptor // to be read right after the size and the type fields. // This should be used carefuly. varBuffer should be used directly to handle data diff --git a/usbhost.h b/usbhost.h index 264b317a..f68d78de 100644 --- a/usbhost.h +++ b/usbhost.h @@ -86,6 +86,11 @@ MAX3421e< SS, INTR >::MAX3421e() SS::Set(); spi::init(); INTR::SetDirRead(); +#ifdef BOARD_MEGA_ADK + /* For Mega ADK, which has Max3421e on-board, set MAX_RESET to Output mode, and pull Reset to HIGH */ + DDRJ |= 0x04; + PORTJ |= 0x04; +#endif /* MAX3421E - full-duplex SPI, level interrupt */ regWr( rPINCTL,( bmFDUPSPI + bmINTLEVEL ));