hack the request length for the first get device descriptor if EP0 size =8 or 16

to prevent usbd control send out ZLP
This commit is contained in:
hathach 2019-11-03 00:17:17 +07:00
parent a0cffdc843
commit 1b51b78eaf
1 changed files with 4 additions and 0 deletions

View File

@ -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);