19 bool USBHub::bResetInitiated =
false;
42 uint8_t
USBHub::Init(uint8_t parent, uint8_t port,
bool lowspeed) {
83 len = (buf[0] > 32) ? 32 : buf[0];
106 rcode = pUsb->
setAddr(0, 0, bAddress);
122 rcode = pUsb->
getDevDescr(bAddress, 0, len, (uint8_t*)buf);
125 goto FailGetDevDescr;
131 goto FailSetDevTblEntry;
140 goto FailGetHubDescr;
153 rcode = pUsb->
getConfDescr(bAddress, 0, cd_len, 0, buf);
156 goto FailGetConfDescr;
163 rcode = pUsb->
getConfDescr(bAddress, 0, buf[0], 0, buf2);
166 goto FailGetConfDescr;
170 rcode = pUsb->
setConf(bAddress, 0, buf[5]);
173 goto FailSetConfDescr;
179 for (uint8_t j = 1; j <= bNbrPorts; j++)
214 if (bAddress == 0x41)
230 if (qNextPollTime <= millis()) {
231 rcode = CheckHubStatus();
232 qNextPollTime = millis() + 100;
237 uint8_t USBHub::CheckHubStatus() {
242 rcode = pUsb->
inTransfer(bAddress, 1, &read, buf);
258 for (uint8_t port = 1, mask = 0x02; port < 8; mask <<= 1, port++) {
268 rcode = PortStatusChange(port, evt);
278 for (uint8_t port = 1; port <= bNbrPorts; port++) {
293 rcode = PortStatusChange(port, evt);
314 for (
int i = 0; i < 3; i++) {
327 uint8_t USBHub::PortStatusChange(uint8_t port,
HubEvent &evt) {
338 bResetInitiated =
true;
345 bResetInitiated =
false;
366 bResetInitiated =
false;
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
#define bmHUB_PORT_STATE_CHECK_DISABLED
#define bmHUB_PORT_EVENT_LS_RESET_COMPLETE
#define bmHUB_PORT_STATUS_PORT_CONNECTION
#define bmHUB_PORT_STATUS_C_PORT_SUSPEND
#define USB_ERROR_EPINFO_IS_NULL
#define HUB_ERROR_PORT_HAS_BEEN_RESET
#define HUB_FEATURE_PORT_POWER
#define bmHUB_PORT_STATUS_PORT_LOW_SPEED
#define bmHUB_PORT_STATUS_PORT_SUSPEND
#define HUB_FEATURE_C_PORT_RESET
#define bmHUB_PORT_STATUS_PORT_OVER_CURRENT
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
virtual void ResetHubPort(uint8_t port)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
virtual void FreeAddress(uint8_t addr)=0
#define bmHUB_PORT_STATUS_C_PORT_ENABLE
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define USB_NAK_MAX_POWER
#define bmHUB_PORT_STATE_DISABLED
uint8_t GetHubDescriptor(uint8_t index, uint16_t nbytes, uint8_t *dataptr)
#define bmHUB_PORT_STATUS_PORT_POWER
#define bmHUB_PORT_STATUS_PORT_HIGH_SPEED
uint8_t ClearPortFeature(uint8_t fid, uint8_t port, uint8_t sel=0)
#define bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define bmHUB_PORT_STATUS_C_PORT_RESET
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define HUB_FEATURE_C_PORT_CONNECTION
void PrintHubPortStatus(USBHub *hubptr, uint8_t addr, uint8_t port, bool print_changes)
#define bmHUB_PORT_STATUS_PORT_RESET
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data)
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
uint8_t GetPortStatus(uint8_t port, uint16_t nbytes, uint8_t *dataptr)
#define bmHUB_PORT_EVENT_CONNECT
virtual uint8_t Release()
#define HUB_FEATURE_PORT_RESET
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
#define bmHUB_PORT_STATUS_PORT_ENABLE
AddressPool & GetAddressPool()
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed)
#define bmHUB_PORT_STATUS_PORT_INDICATOR
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
#define bmHUB_PORT_STATUS_PORT_TEST
#define bmHUB_PORT_EVENT_LS_CONNECT
#define bmHUB_PORT_STATUS_C_PORT_CONNECTION
#define bmHUB_PORT_EVENT_RESET_COMPLETE
uint8_t SetPortFeature(uint8_t fid, uint8_t port, uint8_t sel=0)
#define HUB_FEATURE_C_PORT_ENABLE
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
uint8_t ReleaseDevice(uint8_t addr)
#define bmHUB_PORT_EVENT_DISCONNECT