From 7d7c1d55483b4d1252651925b6a111c49f5a8e73 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 2 Jun 2014 10:39:24 -0400 Subject: [PATCH 1/8] Update heads --- examples/testusbhostFAT/RTClib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index 7fd6a306..31e9226c 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b +Subproject commit 31e9226c2098f9d516c4fe05befe07f542ee5740 From 26cb553f54ad451d88a6b51aba6c9ddcba2e0c48 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 06:12:11 -0400 Subject: [PATCH 2/8] Merge in RTClib changes --- examples/testusbhostFAT/RTClib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index 31e9226c..7fd6a306 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit 31e9226c2098f9d516c4fe05befe07f542ee5740 +Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b From b53c809eaadcfef9504fcc4df86c0a1704e41b27 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 06:13:07 -0400 Subject: [PATCH 3/8] Move ftdi to new early enumeration --- cdcftdi.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cdcftdi.h b/cdcftdi.h index 866e2d7d..692ec6b0 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -128,6 +128,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__ From 900af96c9c710bb4561a7913f840697eaef5d503 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 06:15:19 -0400 Subject: [PATCH 4/8] Merge master --- examples/testusbhostFAT/Arduino_Makefile_master | 2 +- examples/testusbhostFAT/RTClib | 2 +- examples/testusbhostFAT/generic_storage | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 From a58c6db5806f5938f739b3d01b0ea82c68da8bbc Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 08:46:40 -0400 Subject: [PATCH 5/8] Check subclasses during enumeration --- Usb.cpp | 11 +++++++---- UsbCore.h | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Usb.cpp b/Usb.cpp index ca81cf99..15047946 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; 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 */ From f2bfe0671e530dca358adc51dad0bd3173bc0731 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 08:47:03 -0400 Subject: [PATCH 6/8] Check subclasses during enumeration --- hidboot.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 2224dd96cbf64f1184b3d74649e0a5679f398c59 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 08:47:15 -0400 Subject: [PATCH 7/8] Check subclasses during enumeration --- cdcftdi.cpp | 2 +- cdcftdi.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 692ec6b0..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; }; From 69fa08d141931f9d91737a86551b0d1b47e8e182 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Wed, 10 Sep 2014 00:21:01 -0700 Subject: [PATCH 8/8] Check DEVSUBCLASSOK as well when blindly attempt to configure --- Usb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Usb.cpp b/Usb.cpp index 15047946..37914046 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -727,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);