Merge branch 'xxxajk' of github.com:felis/USB_Host_Shield_2.0 into xxxajk

This commit is contained in:
Andrew J. Kroll 2013-10-08 14:25:32 -04:00
commit 272180cf60
2 changed files with 14 additions and 10 deletions

View file

@ -110,6 +110,7 @@ FailGetDevDescr:
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
NotifyFailGetDevDescr(rcode); NotifyFailGetDevDescr(rcode);
#endif #endif
if (rcode != hrJERR)
rcode = USB_ERROR_FailGetDevDescr; rcode = USB_ERROR_FailGetDevDescr;
Release(); Release();
return rcode; return rcode;
@ -300,7 +301,7 @@ void BTD::clearAllVariables() {
} }
connectToWii = false; connectToWii = false;
pairWithWii = false; incomingWii = false;
bAddress = 0; // Clear device address bAddress = 0; // Clear device address
bNumEP = 1; // Must have to be reset to 1 bNumEP = 1; // Must have to be reset to 1
qNextPollTime = 0; // Reset next poll time qNextPollTime = 0; // Reset next poll time
@ -413,7 +414,7 @@ void BTD::HCI_event_task() {
break; break;
case EV_INQUIRY_COMPLETE: case EV_INQUIRY_COMPLETE:
if (inquiry_counter >= 5) { if (inquiry_counter >= 5 && pairWithWii) {
inquiry_counter = 0; inquiry_counter = 0;
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80); Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80);
@ -466,7 +467,7 @@ void BTD::HCI_event_task() {
hci_handle = hcibuf[3] | ((hcibuf[4] & 0x0F) << 8); // store the handle for the ACL connection hci_handle = hcibuf[3] | ((hcibuf[4] & 0x0F) << 8); // store the handle for the ACL connection
hci_event_flag |= HCI_FLAG_CONN_COMPLETE; // set connection complete flag hci_event_flag |= HCI_FLAG_CONN_COMPLETE; // set connection complete flag
} }
#ifdef EXTRADEBUG #ifdef DEBUG_USB_HOST
else { else {
Notify(PSTR("\r\nConnection Failed"), 0x80); Notify(PSTR("\r\nConnection Failed"), 0x80);
hci_state = HCI_CHECK_WII_SERVICE; hci_state = HCI_CHECK_WII_SERVICE;

15
Usb.cpp
View file

@ -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 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); //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 (rcode == USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET) {
if (parent == 0) { if (parent == 0) {
// Send a bus reset on the root interface. // Send a bus reset on the root interface.
@ -579,12 +579,16 @@ uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lo
// reset parent port // reset parent port
devConfig[parent]->ResetHubPort(port); devConfig[parent]->ResetHubPort(port);
} }
} } else if (rcode == hrJERR) { // Some devices returns this when plugged in - trying to initialize the device again usually works
delay(100);
goto again;
} else if (rcode)
return rcode;
rcode = devConfig[driver]->Init(parent, port, lowspeed); 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 if (rcode == hrJERR) { // Some devices returns this when plugged in - trying to initialize the device again usually works
delay(100); delay(100);
devConfig[driver]->ConfigureDevice(parent, port, lowspeed); // Just ignore the returned value goto again;
rcode = devConfig[driver]->Init(parent, port, lowspeed);
} }
if (rcode) { if (rcode) {
// Issue a bus reset, because the device may be in a limbo state // Issue a bus reset, because the device may be in a limbo state
@ -596,7 +600,6 @@ uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lo
// reset parent port // reset parent port
devConfig[parent]->ResetHubPort(port); devConfig[parent]->ResetHubPort(port);
} }
} }
return rcode; return rcode;
} }