mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge branch 'xxxajk' of github.com:felis/USB_Host_Shield_2.0 into xxxajk
This commit is contained in:
commit
272180cf60
2 changed files with 14 additions and 10 deletions
7
BTD.cpp
7
BTD.cpp
|
@ -110,6 +110,7 @@ FailGetDevDescr:
|
|||
#ifdef DEBUG_USB_HOST
|
||||
NotifyFailGetDevDescr(rcode);
|
||||
#endif
|
||||
if (rcode != hrJERR)
|
||||
rcode = USB_ERROR_FailGetDevDescr;
|
||||
Release();
|
||||
return rcode;
|
||||
|
@ -300,7 +301,7 @@ void BTD::clearAllVariables() {
|
|||
}
|
||||
|
||||
connectToWii = false;
|
||||
pairWithWii = false;
|
||||
incomingWii = false;
|
||||
bAddress = 0; // Clear device address
|
||||
bNumEP = 1; // Must have to be reset to 1
|
||||
qNextPollTime = 0; // Reset next poll time
|
||||
|
@ -413,7 +414,7 @@ void BTD::HCI_event_task() {
|
|||
break;
|
||||
|
||||
case EV_INQUIRY_COMPLETE:
|
||||
if (inquiry_counter >= 5) {
|
||||
if (inquiry_counter >= 5 && pairWithWii) {
|
||||
inquiry_counter = 0;
|
||||
#ifdef DEBUG_USB_HOST
|
||||
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_event_flag |= HCI_FLAG_CONN_COMPLETE; // set connection complete flag
|
||||
}
|
||||
#ifdef EXTRADEBUG
|
||||
#ifdef DEBUG_USB_HOST
|
||||
else {
|
||||
Notify(PSTR("\r\nConnection Failed"), 0x80);
|
||||
hci_state = HCI_CHECK_WII_SERVICE;
|
||||
|
|
15
Usb.cpp
15
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.
|
||||
|
@ -579,12 +579,16 @@ uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lo
|
|||
// reset parent 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);
|
||||
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
|
||||
|
@ -596,7 +600,6 @@ uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lo
|
|||
// reset parent port
|
||||
devConfig[parent]->ResetHubPort(port);
|
||||
}
|
||||
|
||||
}
|
||||
return rcode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue