19 bool USBHub::bResetInitiated =
false;
42 uint8_t
USBHub::Init(uint8_t parent, uint8_t port,
bool lowspeed) {
86 len = (buf[0] > 32) ? 32 : buf[0];
109 rcode = pUsb->
setAddr(0, 0, bAddress);
125 rcode = pUsb->
getDevDescr(bAddress, 0, len, (uint8_t*)buf);
128 goto FailGetDevDescr;
134 goto FailSetDevTblEntry;
143 goto FailGetHubDescr;
156 rcode = pUsb->
getConfDescr(bAddress, 0, cd_len, 0, buf);
159 goto FailGetConfDescr;
166 rcode = pUsb->
getConfDescr(bAddress, 0, buf[0], 0, buf2);
169 goto FailGetConfDescr;
173 rcode = pUsb->
setConf(bAddress, 0, buf[5]);
176 goto FailSetConfDescr;
182 for(uint8_t j = 1; j <= bNbrPorts; j++)
233 if(((
long)(millis() - qNextPollTime) >= 0
L)) {
234 rcode = CheckHubStatus();
235 qNextPollTime = millis() + 100;
240 uint8_t USBHub::CheckHubStatus() {
245 rcode = pUsb->
inTransfer(bAddress, 1, &read, buf);
261 for(uint8_t port = 1, mask = 0x02; port < 8; mask <<= 1, port++) {
271 rcode = PortStatusChange(port, evt);
281 for(uint8_t port = 1; port <= bNbrPorts; port++) {
296 rcode = PortStatusChange(port, evt);
317 for(
int i = 0; i < 3; i++) {
330 uint8_t USBHub::PortStatusChange(uint8_t port,
HubEvent &evt) {
341 bResetInitiated =
true;
348 bResetInitiated =
false;
369 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