summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-11-03 00:17:17 +0700
committerhathach <[email protected]>2019-11-03 00:17:17 +0700
commit1b51b78eafb1a078aa7fc8caf57d01d92b84ca0f (patch)
tree78df3295de79ebb92aae14c0b55320a1f0a3b6e7 /src
parenta0cffdc843ca21cf4fa02c2eccdf6a708708a8f6 (diff)
hack the request length for the first get device descriptor if EP0 size =8 or 16
to prevent usbd control send out ZLP
Diffstat (limited to 'src')
-rw-r--r--src/device/usbd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 8661717f5..360881f34 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -771,9 +771,13 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
uint16_t len = sizeof(tusb_desc_device_t);
// Only send up to EP0 Packet Size if not addressed
+ // This only happens with the very first get device descriptor and EP0 size = 8 or 16.
if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed)
{
len = CFG_TUD_ENDPOINT0_SIZE;
+
+ // Hack here: we modify the request length to prevent usbd_control response with zlp
+ ((tusb_control_request_t*) p_request)->wLength = CFG_TUD_ENDPOINT0_SIZE;
}
return tud_control_xfer(rhport, p_request, (void*) tud_descriptor_device_cb(), len);