Просмотр исходного кода

add USB_DEVICE_QUALIFIER_DESCRIPTOR_INIT and USB_OTHER_SPEED_CONFIG_DESCRIPTOR_INIT macros

Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
Zhihong Chen 1 год назад
Родитель
Сommit
9cb992bed7
2 измененных файлов с 26 добавлено и 1 удалено
  1. 25 0
      common/usb_def.h
  2. 1 1
      core/usbd_core.c

+ 25 - 0
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 */                                                       \

+ 1 - 1
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;