From cf0fad4045a395fb7128e4be9a63cc7560684951 Mon Sep 17 00:00:00 2001 From: Yuuichi Akagawa Date: Mon, 23 Nov 2020 20:08:07 +0900 Subject: [PATCH] Change to Windows style enumeration process. Some devices return only 8 bytes of Device Descriptor by default address. (e.g. Novation Circuit) --- usbh_midi.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usbh_midi.cpp b/usbh_midi.cpp index 71aece3b..df2672cc 100644 --- a/usbh_midi.cpp +++ b/usbh_midi.cpp @@ -147,10 +147,9 @@ uint8_t USBH_MIDI::Init(uint8_t parent, uint8_t port, bool lowspeed) p->epinfo = epInfo; p->lowspeed = lowspeed; - // Get device descriptor - rcode = pUsb->getDevDescr( 0, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf ); - vid = udd->idVendor; - pid = udd->idProduct; + // First Device Descriptor Request (Initially first 8 bytes) + rcode = pUsb->getDevDescr( 0, 0, 8, (uint8_t*)buf ); + // Restore p->epinfo p->epinfo = oldep_ptr; @@ -186,6 +185,13 @@ uint8_t USBH_MIDI::Init(uint8_t parent, uint8_t port, bool lowspeed) } p->lowspeed = lowspeed; + // Second Device Descriptor Request (Full) + rcode = pUsb->getDevDescr( bAddress, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf ); + if( rcode ){ + goto FailGetDevDescr; + } + vid = udd->idVendor; + pid = udd->idProduct; num_of_conf = udd->bNumConfigurations; // Assign epInfo to epinfo pointer