From da248d159428194d55753439cb2dc5398df0501c Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Tue, 18 May 2021 17:02:16 +0200 Subject: [PATCH 1/2] spresense: Fix USB CDC and MSC --- ports/cxd56/mpconfigport.h | 2 +- shared-module/storage/__init__.c | 8 ++++++++ shared-module/usb_cdc/__init__.c | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ports/cxd56/mpconfigport.h b/ports/cxd56/mpconfigport.h index 4c332577e6eed..3560e72855cf9 100644 --- a/ports/cxd56/mpconfigport.h +++ b/ports/cxd56/mpconfigport.h @@ -37,7 +37,7 @@ // so define these before #include'ing that file. #define USB_CDC_EP_NUM_NOTIFICATION (3) #define USB_CDC_EP_NUM_DATA_OUT (2) -#define USB_CDC_EP_NUM_DATA_IN (2) +#define USB_CDC_EP_NUM_DATA_IN (1) #define USB_MSC_EP_NUM_OUT (5) #define USB_MSC_EP_NUM_IN (4) diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index cbe72c6f161a2..da90a403558e1 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -63,7 +63,11 @@ static const uint8_t usb_msc_descriptor_template[] = { 0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] #define MSC_IN_ENDPOINT_INDEX (11) 0x02, // 12 bmAttributes (Bulk) +#if USB_HIGHSPEED + 0x00, 0x02, // 13,14 wMaxPacketSize 512 +#else 0x40, 0x00, // 13,14 wMaxPacketSize 64 +#endif 0x00, // 15 bInterval 0 (unit depends on device speed) // MSC Endpoint OUT Descriptor @@ -72,7 +76,11 @@ static const uint8_t usb_msc_descriptor_template[] = { 0xFF, // 18 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] #define MSC_OUT_ENDPOINT_INDEX (18) 0x02, // 19 bmAttributes (Bulk) +#if USB_HIGHSPEED + 0x00, 0x02, // 20,21 wMaxPacketSize 512 +#else 0x40, 0x00, // 20,21 wMaxPacketSize 64 +#endif 0x00, // 22 bInterval 0 (unit depends on device speed) }; diff --git a/shared-module/usb_cdc/__init__.c b/shared-module/usb_cdc/__init__.c index c5da1f41e0379..5b2275280e010 100644 --- a/shared-module/usb_cdc/__init__.c +++ b/shared-module/usb_cdc/__init__.c @@ -121,7 +121,11 @@ static const uint8_t usb_cdc_descriptor_template[] = { 0xFF, // 54 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] #define CDC_DATA_OUT_ENDPOINT_INDEX 54 0x02, // 55 bmAttributes (Bulk) +#if USB_HIGHSPEED + 0x00, 0x02, // 56,57 wMaxPacketSize 512 +#else 0x40, 0x00, // 56,57 wMaxPacketSize 64 +#endif 0x00, // 58 bInterval 0 (unit depends on device speed) // CDC Data IN Endpoint Descriptor @@ -130,7 +134,11 @@ static const uint8_t usb_cdc_descriptor_template[] = { 0xFF, // 61 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] #define CDC_DATA_IN_ENDPOINT_INDEX 61 0x02, // 62 bmAttributes (Bulk) +#if USB_HIGHSPEED + 0x00, 0x02, // 63,64 wMaxPacketSize 512 +#else 0x40, 0x00, // 63,64 wMaxPacketSize 64 +#endif 0x00, // 65 bInterval 0 (unit depends on device speed) }; From aebee2de7309be36bbaca7ad690c680dc804d728 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 19 May 2021 07:35:17 -0400 Subject: [PATCH 2/2] Handle USB_HIGHSPEED for MIDI also --- shared-module/storage/__init__.c | 12 ++++++------ shared-module/usb_cdc/__init__.c | 12 ++++++------ shared-module/usb_midi/__init__.c | 10 +++++++++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index da90a403558e1..5857432a52bba 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -63,11 +63,11 @@ static const uint8_t usb_msc_descriptor_template[] = { 0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] #define MSC_IN_ENDPOINT_INDEX (11) 0x02, // 12 bmAttributes (Bulk) -#if USB_HIGHSPEED + #if USB_HIGHSPEED 0x00, 0x02, // 13,14 wMaxPacketSize 512 -#else + #else 0x40, 0x00, // 13,14 wMaxPacketSize 64 -#endif + #endif 0x00, // 15 bInterval 0 (unit depends on device speed) // MSC Endpoint OUT Descriptor @@ -76,11 +76,11 @@ static const uint8_t usb_msc_descriptor_template[] = { 0xFF, // 18 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] #define MSC_OUT_ENDPOINT_INDEX (18) 0x02, // 19 bmAttributes (Bulk) -#if USB_HIGHSPEED + #if USB_HIGHSPEED 0x00, 0x02, // 20,21 wMaxPacketSize 512 -#else + #else 0x40, 0x00, // 20,21 wMaxPacketSize 64 -#endif + #endif 0x00, // 22 bInterval 0 (unit depends on device speed) }; diff --git a/shared-module/usb_cdc/__init__.c b/shared-module/usb_cdc/__init__.c index 5b2275280e010..769a2ce87fc3d 100644 --- a/shared-module/usb_cdc/__init__.c +++ b/shared-module/usb_cdc/__init__.c @@ -121,11 +121,11 @@ static const uint8_t usb_cdc_descriptor_template[] = { 0xFF, // 54 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] #define CDC_DATA_OUT_ENDPOINT_INDEX 54 0x02, // 55 bmAttributes (Bulk) -#if USB_HIGHSPEED + #if USB_HIGHSPEED 0x00, 0x02, // 56,57 wMaxPacketSize 512 -#else + #else 0x40, 0x00, // 56,57 wMaxPacketSize 64 -#endif + #endif 0x00, // 58 bInterval 0 (unit depends on device speed) // CDC Data IN Endpoint Descriptor @@ -134,11 +134,11 @@ static const uint8_t usb_cdc_descriptor_template[] = { 0xFF, // 61 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] #define CDC_DATA_IN_ENDPOINT_INDEX 61 0x02, // 62 bmAttributes (Bulk) -#if USB_HIGHSPEED + #if USB_HIGHSPEED 0x00, 0x02, // 63,64 wMaxPacketSize 512 -#else + #else 0x40, 0x00, // 63,64 wMaxPacketSize 64 -#endif + #endif 0x00, // 65 bInterval 0 (unit depends on device speed) }; diff --git a/shared-module/usb_midi/__init__.c b/shared-module/usb_midi/__init__.c index ac2e05adcb849..8cac2ba8af312 100644 --- a/shared-module/usb_midi/__init__.c +++ b/shared-module/usb_midi/__init__.c @@ -127,7 +127,11 @@ static const uint8_t usb_midi_descriptor_template[] = { 0xFF, // 66 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] #define MIDI_STREAMING_OUT_ENDPOINT_INDEX (66) 0x02, // 67 bmAttributes (Bulk) + #if USB_HIGHSPEED + 0x00, 0x02, // 68,69 wMaxPacketSize (512) + #else 0x40, 0x00, // 68,69 wMaxPacketSize (64) + #endif 0x00, // 70 bInterval 0 (unit depends on device speed) // MIDI Data Endpoint Descriptor @@ -143,7 +147,11 @@ static const uint8_t usb_midi_descriptor_template[] = { 0xFF, // 78 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] #define MIDI_STREAMING_IN_ENDPOINT_INDEX (78) 0x02, // 79 bmAttributes (Bulk) - 0x40, 0x00, // 8081 wMaxPacketSize 64 + #if USB_HIGHSPEED + 0x00, 0x02, // 80, 81 wMaxPacketSize (512) + #else + 0x40, 0x00, // 80, 81 wMaxPacketSize (64) + #endif 0x00, // 82 bInterval 0 (unit depends on device speed) // MIDI Data Endpoint Descriptor