From af4302f3602d07ca5311a4c4fa809e191231116e Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Thu, 5 Sep 2013 18:22:00 -0400 Subject: [PATCH 1/2] streamline failure path in code --- BTD.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/BTD.cpp b/BTD.cpp index b283ced4..abaf7344 100755 --- a/BTD.cpp +++ b/BTD.cpp @@ -110,14 +110,15 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { // Assign new address to the device rcode = pUsb->setAddr(0, 0, bAddress); if (rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; + //p->lowspeed = false; + //addrPool.FreeAddress(bAddress); + //bAddress = 0; #ifdef DEBUG_USB_HOST Notify(PSTR("\r\nsetAddr: "), 0x80); D_PrintHex (rcode, 0x80); #endif - return rcode; + goto Fail; + //return rcode; } #ifdef EXTRADEBUG Notify(PSTR("\r\nAddr: "), 0x80); @@ -176,10 +177,12 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif } - rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 0); // Reset configuration value - pUsb->setAddr(bAddress, 0, 0); // Reset address - Release(); // Release device - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; // Return + //rcode = + pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 0); // Reset configuration value + goto FailUnknownDevice; + //pUsb->setAddr(bAddress, 0, 0); // Reset address + //Release(); // Release device + //return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; // Return } else { num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; From 52445a97d713d64ac9978d683dba8a5795871d51 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Sun, 8 Sep 2013 13:11:22 -0400 Subject: [PATCH 2/2] remove unused defines, refactor vbus power enum --- max3421e.h | 3 --- usbhost.h | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/max3421e.h b/max3421e.h index 9fdff593..21138be4 100644 --- a/max3421e.h +++ b/max3421e.h @@ -27,9 +27,6 @@ e-mail : support@circuitsathome.com //#define MAX_GPX 8 -#define ON true -#define OFF false - #define SE0 0 #define SE1 1 #define FSHOST 2 diff --git a/usbhost.h b/usbhost.h index efadcabf..fe0cdda6 100644 --- a/usbhost.h +++ b/usbhost.h @@ -60,8 +60,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; #endif typedef enum VBUS_t { - on = 0, - off = GPX_VBDET + vbus_on = 0, + vbus_off = GPX_VBDET }; template< typename SS, typename INTR > class MAX3421e /* : public spi */ {