From 6adc0843d573070c5b68f8a2e530fb5a3639984c Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 8 Oct 2013 18:14:16 +0200 Subject: [PATCH] More elegant way of doing: 7990c32ad63d087a042842fca8b504da633ff920 --- Usb.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Usb.cpp b/Usb.cpp index 3ffbfbe4..d7fd44ce 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -579,24 +579,24 @@ uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lo // reset parent port devConfig[parent]->ResetHubPort(port); } - } - if (!rcode || rcode == USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET) { + } else if (rcode) + return rcode; + + rcode = devConfig[driver]->Init(parent, port, lowspeed); + if (rcode == hrJERR) { // Some devices returns this when plugged in - trying to initialize the device again usually works + delay(100); + devConfig[driver]->ConfigureDevice(parent, port, lowspeed); // Just ignore the returned value rcode = devConfig[driver]->Init(parent, port, lowspeed); - if (rcode == hrJERR) { // Some devices returns this when plugged in - trying to initialize the device again usually works - delay(100); - devConfig[driver]->ConfigureDevice(parent, port, lowspeed); // Just ignore the returned value - rcode = devConfig[driver]->Init(parent, port, lowspeed); - } - if (rcode) { - // Issue a bus reset, because the device may be in a limbo state - if (parent == 0) { - // Send a bus reset on the root interface. - regWr(rHCTL, bmBUSRST); //issue bus reset - delay(102); // delay 102ms, compensate for clock inaccuracy. - } else { - // reset parent port - devConfig[parent]->ResetHubPort(port); - } + } + if (rcode) { + // Issue a bus reset, because the device may be in a limbo state + if (parent == 0) { + // Send a bus reset on the root interface. + regWr(rHCTL, bmBUSRST); //issue bus reset + delay(102); // delay 102ms, compensate for clock inaccuracy. + } else { + // reset parent port + devConfig[parent]->ResetHubPort(port); } } return rcode;