mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
streamline failure path in code
This commit is contained in:
parent
6993e811c6
commit
af4302f360
1 changed files with 11 additions and 8 deletions
19
BTD.cpp
19
BTD.cpp
|
@ -110,14 +110,15 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
p->lowspeed = false;
|
//p->lowspeed = false;
|
||||||
addrPool.FreeAddress(bAddress);
|
//addrPool.FreeAddress(bAddress);
|
||||||
bAddress = 0;
|
//bAddress = 0;
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
D_PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
#endif
|
#endif
|
||||||
return rcode;
|
goto Fail;
|
||||||
|
//return rcode;
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nAddr: "), 0x80);
|
Notify(PSTR("\r\nAddr: "), 0x80);
|
||||||
|
@ -176,10 +177,12 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 0); // Reset configuration value
|
//rcode =
|
||||||
pUsb->setAddr(bAddress, 0, 0); // Reset address
|
pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 0); // Reset configuration value
|
||||||
Release(); // Release device
|
goto FailUnknownDevice;
|
||||||
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; // Return
|
//pUsb->setAddr(bAddress, 0, 0); // Reset address
|
||||||
|
//Release(); // Release device
|
||||||
|
//return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; // Return
|
||||||
} else {
|
} else {
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue