diff options
| author | sakumisu <[email protected]> | 2025-10-22 20:34:22 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-11-03 22:17:43 +0800 |
| commit | 9730f63b2cae02ccaaed2c754a305ea7ce0355dc (patch) | |
| tree | 7604d59d4432e97484347596a5937104991d93d7 /core | |
| parent | 0365aa0d6380128011609765afe9c5331ea7a8ed (diff) | |
feat: support custom ep0 mps
Signed-off-by: sakumisu <[email protected]>
Diffstat (limited to 'core')
| -rw-r--r-- | core/usbd_core.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/usbd_core.c b/core/usbd_core.c index 66ec4dc6..3dd8c2ba 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -1145,18 +1145,26 @@ void usbd_event_suspend_handler(uint8_t busid) void usbd_event_reset_handler(uint8_t busid) { + struct usb_endpoint_descriptor ep0; + usbd_set_address(busid, 0); g_usbd_core[busid].device_address = 0; g_usbd_core[busid].configuration = 0; g_usbd_core[busid].ep0_next_state = USBD_EP0_STATE_SETUP; #ifdef CONFIG_USBDEV_ADVANCE_DESC g_usbd_core[busid].speed = USB_SPEED_UNKNOWN; + + USB_ASSERT_MSG(g_usbd_core[busid].descriptors->device_descriptor_callback != NULL, + "device_descriptor_callback is NULL\r\n"); + + struct usb_device_descriptor *device_desc = (struct usb_device_descriptor *)g_usbd_core[busid].descriptors->device_descriptor_callback(g_usbd_core[busid].speed); + ep0.wMaxPacketSize = device_desc->bMaxPacketSize0; +#else + ep0.wMaxPacketSize = USB_CTRL_EP_MPS; #endif - struct usb_endpoint_descriptor ep0; ep0.bLength = 7; ep0.bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT; - ep0.wMaxPacketSize = USB_CTRL_EP_MPS; ep0.bmAttributes = USB_ENDPOINT_TYPE_CONTROL; ep0.bEndpointAddress = USB_CONTROL_IN_EP0; ep0.bInterval = 0; |
