summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhihong Chen <[email protected]>2024-04-30 19:40:53 +0800
committersakumisu <[email protected]>2024-04-30 20:05:57 +0800
commit9cb992bed7b352b6affde48aeb22f498de54927f (patch)
tree26f4568562b7dc3b3380f40ecb45289c6bec02d8
parent183d49efbda2190f5e21a494260d13f447fe03c1 (diff)
add USB_DEVICE_QUALIFIER_DESCRIPTOR_INIT and USB_OTHER_SPEED_CONFIG_DESCRIPTOR_INIT macros
Signed-off-by: Zhihong Chen <[email protected]>
-rw-r--r--common/usb_def.h25
-rw-r--r--core/usbd_core.c2
2 files changed, 26 insertions, 1 deletions
diff --git a/common/usb_def.h b/common/usb_def.h
index 8fc76d17..b8331a02 100644
--- a/common/usb_def.h
+++ b/common/usb_def.h
@@ -34,6 +34,10 @@
/**< maximum packet size (MPS) for EP 0 */
#define USB_CTRL_EP_MPS 64
+/**< maximum packet size (MPS) for bulk EP */
+#define USB_BULK_EP_MPS_HS 512
+#define USB_BULK_EP_MPS_FS 64
+
/* USB PID Types */
#define USB_PID_OUT (0x01) /* Tokens */
#define USB_PID_IN (0x09)
@@ -660,6 +664,27 @@ struct usb_desc_header {
bmAttributes, /* bmAttributes */ \
USB_CONFIG_POWER_MA(bMaxPower) /* bMaxPower */
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_INIT(bcdUSB, bDeviceClass, bDeviceSubClass, bDeviceProtocol, bNumConfigurations) \
+ 0x0A, /* bLength */ \
+ USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER, /* bDescriptorType */ \
+ WBVAL(bcdUSB), /* bcdUSB */ \
+ bDeviceClass, /* bDeviceClass */ \
+ bDeviceSubClass, /* bDeviceSubClass */ \
+ bDeviceProtocol, /* bDeviceProtocol */ \
+ 0x40, /* bMaxPacketSize */ \
+ bNumConfigurations, /* bNumConfigurations */ \
+ 0x00 /* bReserved */
+
+#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_INIT(wTotalLength, bNumInterfaces, bConfigurationValue, bmAttributes, bMaxPower) \
+ 0x09, /* bLength */ \
+ USB_DESCRIPTOR_TYPE_OTHER_SPEED, /* bDescriptorType */ \
+ WBVAL(wTotalLength), /* wTotalLength */ \
+ bNumInterfaces, /* bNumInterfaces */ \
+ bConfigurationValue, /* bConfigurationValue */ \
+ 0x00, /* iConfiguration */ \
+ bmAttributes, /* bmAttributes */ \
+ USB_CONFIG_POWER_MA(bMaxPower) /* bMaxPower */
+
#define USB_INTERFACE_DESCRIPTOR_INIT(bInterfaceNumber, bAlternateSetting, bNumEndpoints, \
bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol, iInterface) \
0x09, /* bLength */ \
diff --git a/core/usbd_core.c b/core/usbd_core.c
index fb6c7519..54bd9074 100644
--- a/core/usbd_core.c
+++ b/core/usbd_core.c
@@ -158,7 +158,7 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
switch (type) {
case USB_DESCRIPTOR_TYPE_DEVICE:
- g_usbd_core[busid].speed = usbd_get_port_speed(busid, 0); /* before we get device descriptor, we have known steady port speed */
+ g_usbd_core[busid].speed = usbd_get_port_speed(busid); /* before we get device descriptor, we have known steady port speed */
desc = g_usbd_core[busid].descriptors->device_descriptor_callback(g_usbd_core[busid].speed);
if (desc == NULL) {
found = false;