From 3b733fc962fd7412bc7b2e2bbd986f2993e8e9e8 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 8 Oct 2013 18:27:51 +0200 Subject: [PATCH] Better way to retry when hrJERR is returned --- Usb.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Usb.cpp b/Usb.cpp index d7fd44ce..f1e6bc49 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -566,10 +566,10 @@ uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) { }; uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t rcode = 0; //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port); - rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed); +again: + uint8_t rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed); if (rcode == USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET) { if (parent == 0) { // Send a bus reset on the root interface. @@ -585,8 +585,7 @@ uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lo 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); + goto again; } if (rcode) { // Issue a bus reset, because the device may be in a limbo state