diff --git a/Usb.cpp b/Usb.cpp index ca81cf99..37914046 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -698,17 +698,20 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { // Allocate new address according to device class //bAddress = addrPool.AllocAddress(parent, false, port); - //if (!bAddress) - // return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; uint16_t vid = udd->idVendor; uint16_t pid = udd->idProduct; uint8_t klass = udd->bDeviceClass; - + uint8_t subklass = udd->bDeviceSubClass; // Attempt to configure if VID/PID or device class matches with a driver + // Qualify with subclass too. + // + // VID/PID & class tests default to false for drivers not yet ported + // subclass defaults to true, so you don't have to define it if you don't have to. + // for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { if(!devConfig[devConfigIndex]) continue; // no driver if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) { + if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) { rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED) break; @@ -724,7 +727,7 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { if(!devConfig[devConfigIndex]) continue; if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above + if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); //printf("ERROR ENUMERATING %2.2x\r\n", rcode); diff --git a/UsbCore.h b/UsbCore.h index 76d9d5ee..f514195c 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -150,6 +150,11 @@ public: virtual boolean DEVCLASSOK(uint8_t klass) { return false; } + + virtual boolean DEVSUBCLASSOK(uint8_t subklass) { + return true; + } + }; /* USB Setup Packet Structure */ diff --git a/cdcftdi.cpp b/cdcftdi.cpp index 13ca683f..8f07b358 100644 --- a/cdcftdi.cpp +++ b/cdcftdi.cpp @@ -246,7 +246,7 @@ uint8_t FTDI::Release() { bNumEP = 1; qNextPollTime = 0; bPollEnable = false; - return 0; + return pAsync->OnRelease(this); } uint8_t FTDI::Poll() { diff --git a/cdcftdi.h b/cdcftdi.h index 866e2d7d..fbb7396d 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -79,6 +79,7 @@ class FTDI; class FTDIAsyncOper { public: virtual uint8_t OnInit(FTDI *pftdi) = 0; + virtual uint8_t OnRelease(FTDI *pftdi) = 0; }; @@ -128,6 +129,11 @@ public: // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + + virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + return (vid == FTDI_VID && pid == FTDI_PID); + } + }; #endif // __CDCFTDI_H__ diff --git a/examples/testusbhostFAT/Arduino_Makefile_master b/examples/testusbhostFAT/Arduino_Makefile_master index 7ada91a9..d35bb955 160000 --- a/examples/testusbhostFAT/Arduino_Makefile_master +++ b/examples/testusbhostFAT/Arduino_Makefile_master @@ -1 +1 @@ -Subproject commit 7ada91a90027ccb7558b74087fb68d3940ecf64d +Subproject commit d35bb955e3818f0c14e47c8a1998003da8dc1b5a diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index b119b97e..7fd6a306 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit b119b97e1484a08aebcf24e070113d78c82fb023 +Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b diff --git a/examples/testusbhostFAT/generic_storage b/examples/testusbhostFAT/generic_storage index 72b5bf46..0b8e3076 160000 --- a/examples/testusbhostFAT/generic_storage +++ b/examples/testusbhostFAT/generic_storage @@ -1 +1 @@ -Subproject commit 72b5bf467a1c2479ba7354ee4d864e382c167425 +Subproject commit 0b8e3076b5a072251e01cfc6e6333b364d4e71e7 diff --git a/hidboot.h b/hidboot.h index 0326bf25..b35df7cb 100644 --- a/hidboot.h +++ b/hidboot.h @@ -214,6 +214,14 @@ public: // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + + virtual boolean DEVCLASSOK(uint8_t klass) { + return (klass == USB_CLASS_HID); + } + + virtual boolean DEVSUBCLASSOK(uint8_t subklass) { + return (subklass == BOOT_PROTOCOL); + } }; template