-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix some HUB related issues #414
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,10 @@ class USBDeviceConfig { | |
return 0; | ||
} | ||
|
||
virtual uint8_t GetPortAddress() { | ||
return GetAddress(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix the indentation here. |
||
virtual void ResetHubPort(uint8_t port __attribute__((unused))) { | ||
return; | ||
} // Note used for hubs only! | ||
|
@@ -274,6 +278,7 @@ class USB : public MAX3421E { | |
uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit); | ||
uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data); | ||
uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0); | ||
void ResetHubPort(uint8_t parent, uint8_t port); | ||
uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ bool USBHub::bResetInitiated = false; | |
USBHub::USBHub(USB *p) : | ||
pUsb(p), | ||
bAddress(0), | ||
bPortAddress(0), | ||
bNbrPorts(0), | ||
//bInitState(0), | ||
qNextPollTime(0), | ||
|
@@ -104,6 +105,14 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) { | |
if(!bAddress) | ||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; | ||
|
||
{ | ||
UsbDeviceAddress a; | ||
a.devAddress = bAddress; | ||
a.bmHub = 0; | ||
a.bmAddress = port ? : 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what this does when port is non-zero. Is it the equivalent of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Port numbers start at 1. |
||
bPortAddress = a.devAddress; | ||
} | ||
|
||
// Extract Max Packet Size from the device descriptor | ||
epInfo[0].maxPktSize = udd->bMaxPacketSize0; | ||
|
||
|
@@ -115,6 +124,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) { | |
p->epinfo = oldep_ptr; | ||
addrPool.FreeAddress(bAddress); | ||
bAddress = 0; | ||
bPortAddress = 0; | ||
return rcode; | ||
} | ||
|
||
|
@@ -214,12 +224,22 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) { | |
} | ||
|
||
uint8_t USBHub::Release() { | ||
UsbDeviceAddress a; | ||
a.devAddress = 0; | ||
a.bmHub = 0; | ||
a.bmParent = bAddress; | ||
for (uint8_t j = 1; j <= bNbrPorts; j++) { | ||
a.bmAddress = j; | ||
pUsb->ReleaseDevice(a.devAddress); | ||
} | ||
|
||
pUsb->GetAddressPool().FreeAddress(bAddress); | ||
|
||
if(bAddress == 0x41) | ||
pUsb->SetHubPreMask(); | ||
|
||
bAddress = 0; | ||
bPortAddress = 0; | ||
bNbrPorts = 0; | ||
qNextPollTime = 0; | ||
bPollEnable = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,7 @@ class USBHub : USBDeviceConfig { | |
EpInfo epInfo[2]; // interrupt endpoint info structure | ||
|
||
uint8_t bAddress; // address | ||
uint8_t bPortAddress; // port address | ||
uint8_t bNbrPorts; // number of ports | ||
// uint8_t bInitState; // initialization state variable | ||
uint32_t qNextPollTime; // next poll time | ||
|
@@ -200,7 +201,11 @@ class USBHub : USBDeviceConfig { | |
return bAddress; | ||
}; | ||
|
||
virtual bool DEVCLASSOK(uint8_t klass) { | ||
virtual uint8_t GetPortAddress() { | ||
return bPortAddress; | ||
}; | ||
|
||
virtual bool DEVCLASSOK(uint8_t klass) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also fix indentation here. |
||
return (klass == 0x09); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better to replace this with:
And then get rid of the
if(a.bmHub)
if-statement above.