Pārlūkot izejas kodu

export cdc/msc/rndis/mtp mps, configured by user

sakimisu 2 gadi atpakaļ
vecāks
revīzija
2d1b4b8b82

+ 6 - 140
class/cdc/usb_cdc.h

@@ -302,8 +302,7 @@ struct cdc_ecm_descriptor {
 /*Length of template descriptor: 66 bytes*/
 /*Length of template descriptor: 66 bytes*/
 #define CDC_ACM_DESCRIPTOR_LEN (8 + 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7)
 #define CDC_ACM_DESCRIPTOR_LEN (8 + 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7)
 // clang-format off
 // clang-format off
-#ifndef CONFIG_USB_HS
-#define CDC_ACM_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, str_idx)               \
+#define CDC_ACM_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, wMaxPacketSize, str_idx) \
     /* Interface Associate */                                                                  \
     /* Interface Associate */                                                                  \
     0x08,                                                  /* bLength */                       \
     0x08,                                                  /* bLength */                       \
     USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,             /* bDescriptorType */               \
     USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,             /* bDescriptorType */               \
@@ -359,152 +358,20 @@ struct cdc_ecm_descriptor {
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     out_ep,                                                /* bEndpointAddress */              \
     out_ep,                                                /* bEndpointAddress */              \
     0x02,                                                  /* bmAttributes */                  \
     0x02,                                                  /* bmAttributes */                  \
-    0x40, 0x00,                                            /* wMaxPacketSize */                \
+    WBVAL(wMaxPacketSize),                                 /* wMaxPacketSize */                \
     0x00,                                                  /* bInterval */                     \
     0x00,                                                  /* bInterval */                     \
     0x07,                                                  /* bLength */                       \
     0x07,                                                  /* bLength */                       \
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     in_ep,                                                 /* bEndpointAddress */              \
     in_ep,                                                 /* bEndpointAddress */              \
     0x02,                                                  /* bmAttributes */                  \
     0x02,                                                  /* bmAttributes */                  \
-    0x40, 0x00,                                            /* wMaxPacketSize */                \
+    WBVAL(wMaxPacketSize),                                 /* wMaxPacketSize */                \
     0x00                                                   /* bInterval */
     0x00                                                   /* bInterval */
-#else
-#define CDC_ACM_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, str_idx)               \
-    /* Interface Associate */                                                                  \
-    0x08,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,             /* bDescriptorType */               \
-    bFirstInterface,                                       /* bFirstInterface */               \
-    0x02,                                                  /* bInterfaceCount */               \
-    USB_DEVICE_CLASS_CDC,                                  /* bFunctionClass */                \
-    CDC_ABSTRACT_CONTROL_MODEL,                            /* bFunctionSubClass */             \
-    CDC_COMMON_PROTOCOL_AT_COMMANDS,                       /* bFunctionProtocol */             \
-    0x00,                                                  /* iFunction */                     \
-    0x09,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_INTERFACE,                         /* bDescriptorType */               \
-    bFirstInterface,                                       /* bInterfaceNumber */              \
-    0x00,                                                  /* bAlternateSetting */             \
-    0x01,                                                  /* bNumEndpoints */                 \
-    USB_DEVICE_CLASS_CDC,                                  /* bInterfaceClass */               \
-    CDC_ABSTRACT_CONTROL_MODEL,                            /* bInterfaceSubClass */            \
-    CDC_COMMON_PROTOCOL_AT_COMMANDS,                       /* bInterfaceProtocol */            \
-    str_idx,                                               /* iInterface */                    \
-    0x05,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_HEADER,                                  /* bDescriptorSubtype */            \
-    WBVAL(CDC_V1_10),                                      /* bcdCDC */                        \
-    0x05,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_CALL_MANAGEMENT,                         /* bDescriptorSubtype */            \
-    0x00,                                                  /* bmCapabilities */                \
-    (uint8_t)(bFirstInterface + 1),                        /* bDataInterface */                \
-    0x04,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT,             /* bDescriptorSubtype */            \
-    0x02,                                                  /* bmCapabilities */                \
-    0x05,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_UNION,                                   /* bDescriptorSubtype */            \
-    bFirstInterface,                                       /* bMasterInterface */              \
-    (uint8_t)(bFirstInterface + 1),                        /* bSlaveInterface0 */              \
-    0x07,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
-    int_ep,                                                /* bEndpointAddress */              \
-    0x03,                                                  /* bmAttributes */                  \
-    0x08, 0x00,                                            /* wMaxPacketSize */                \
-    0x10,                                                  /* bInterval */                     \
-    0x09,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_INTERFACE,                         /* bDescriptorType */               \
-    (uint8_t)(bFirstInterface + 1),                        /* bInterfaceNumber */              \
-    0x00,                                                  /* bAlternateSetting */             \
-    0x02,                                                  /* bNumEndpoints */                 \
-    CDC_DATA_INTERFACE_CLASS,                              /* bInterfaceClass */               \
-    0x00,                                                  /* bInterfaceSubClass */            \
-    0x00,                                                  /* bInterfaceProtocol */            \
-    0x00,                                                  /* iInterface */                    \
-    0x07,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
-    out_ep,                                                /* bEndpointAddress */              \
-    0x02,                                                  /* bmAttributes */                  \
-    0x00, 0x02,                                            /* wMaxPacketSize */                \
-    0x00,                                                  /* bInterval */                     \
-    0x07,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
-    in_ep,                                                 /* bEndpointAddress */              \
-    0x02,                                                  /* bmAttributes */                  \
-    0x00, 0x02,                                            /* wMaxPacketSize */                \
-    0x00                                                   /* bInterval */
-#endif
 // clang-format on
 // clang-format on
 
 
 /*Length of template descriptor: 66 bytes*/
 /*Length of template descriptor: 66 bytes*/
 #define CDC_RNDIS_DESCRIPTOR_LEN (8 + 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7)
 #define CDC_RNDIS_DESCRIPTOR_LEN (8 + 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7)
 // clang-format off
 // clang-format off
-#ifndef CONFIG_USB_HS
-#define CDC_RNDIS_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, str_idx)             \
-    /* Interface Associate */                                                                  \
-    0x08,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,             /* bDescriptorType */               \
-    bFirstInterface,                                       /* bFirstInterface */               \
-    0x02,                                                  /* bInterfaceCount */               \
-    USB_DEVICE_CLASS_WIRELESS,                             /* bFunctionClass */                \
-    CDC_DIRECT_LINE_CONTROL_MODEL,                         /* bFunctionSubClass */             \
-    CDC_COMMON_PROTOCOL_AT_COMMANDS_PCCA_101_AND_ANNEXO,   /* bFunctionProtocol */             \
-    0x00,                                                  /* iFunction */                     \
-    0x09,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_INTERFACE,                         /* bDescriptorType */               \
-    bFirstInterface,                                       /* bInterfaceNumber */              \
-    0x00,                                                  /* bAlternateSetting */             \
-    0x01,                                                  /* bNumEndpoints */                 \
-    USB_DEVICE_CLASS_WIRELESS,                             /* bInterfaceClass */               \
-    CDC_DIRECT_LINE_CONTROL_MODEL,                         /* bInterfaceSubClass */            \
-    CDC_COMMON_PROTOCOL_AT_COMMANDS_PCCA_101_AND_ANNEXO,   /* bInterfaceProtocol */            \
-    str_idx,                                               /* iInterface */                    \
-    0x05,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_HEADER,                                  /* bDescriptorSubtype */            \
-    WBVAL(CDC_V1_10),                                      /* bcdCDC */                        \
-    0x05,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_CALL_MANAGEMENT,                         /* bDescriptorSubtype */            \
-    0x00,                                                  /* bmCapabilities */                \
-    (uint8_t)(bFirstInterface + 1),                        /* bDataInterface */                \
-    0x04,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT,             /* bDescriptorSubtype */            \
-    0x00,                                                  /* bmCapabilities */                \
-    0x05,                                                  /* bLength */                       \
-    CDC_CS_INTERFACE,                                      /* bDescriptorType */               \
-    CDC_FUNC_DESC_UNION,                                   /* bDescriptorSubtype */            \
-    bFirstInterface,                                       /* bMasterInterface */              \
-    (uint8_t)(bFirstInterface + 1),                        /* bSlaveInterface0 */              \
-    0x07,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
-    int_ep,                                                /* bEndpointAddress */              \
-    0x03,                                                  /* bmAttributes */                  \
-    0x08, 0x00,                                            /* wMaxPacketSize */                \
-    0x10,                                                  /* bInterval */                     \
-    0x09,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_INTERFACE,                         /* bDescriptorType */               \
-    (uint8_t)(bFirstInterface + 1),                        /* bInterfaceNumber */              \
-    0x00,                                                  /* bAlternateSetting */             \
-    0x02,                                                  /* bNumEndpoints */                 \
-    CDC_DATA_INTERFACE_CLASS,                              /* bInterfaceClass */               \
-    0x00,                                                  /* bInterfaceSubClass */            \
-    0x00,                                                  /* bInterfaceProtocol */            \
-    0x00,                                                  /* iInterface */                    \
-    0x07,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
-    out_ep,                                                /* bEndpointAddress */              \
-    0x02,                                                  /* bmAttributes */                  \
-    0x40, 0x00,                                            /* wMaxPacketSize */                \
-    0x00,                                                  /* bInterval */                     \
-    0x07,                                                  /* bLength */                       \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
-    in_ep,                                                 /* bEndpointAddress */              \
-    0x02,                                                  /* bmAttributes */                  \
-    0x40, 0x00,                                            /* wMaxPacketSize */                \
-    0x00                                                   /* bInterval */
-#else
-#define CDC_RNDIS_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, str_idx)             \
+#define CDC_RNDIS_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, wMaxPacketSize, str_idx) \
     /* Interface Associate */                                                                  \
     /* Interface Associate */                                                                  \
     0x08,                                                  /* bLength */                       \
     0x08,                                                  /* bLength */                       \
     USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,             /* bDescriptorType */               \
     USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,             /* bDescriptorType */               \
@@ -560,15 +427,14 @@ struct cdc_ecm_descriptor {
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     out_ep,                                                /* bEndpointAddress */              \
     out_ep,                                                /* bEndpointAddress */              \
     0x02,                                                  /* bmAttributes */                  \
     0x02,                                                  /* bmAttributes */                  \
-    0x00, 0x02,                                            /* wMaxPacketSize */                \
+    WBVAL(wMaxPacketSize),                                 /* wMaxPacketSize */                \
     0x00,                                                  /* bInterval */                     \
     0x00,                                                  /* bInterval */                     \
     0x07,                                                  /* bLength */                       \
     0x07,                                                  /* bLength */                       \
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     USB_DESCRIPTOR_TYPE_ENDPOINT,                          /* bDescriptorType */               \
     in_ep,                                                 /* bEndpointAddress */              \
     in_ep,                                                 /* bEndpointAddress */              \
     0x02,                                                  /* bmAttributes */                  \
     0x02,                                                  /* bmAttributes */                  \
-    0x00, 0x02,                                            /* wMaxPacketSize */                \
+    WBVAL(wMaxPacketSize),                                 /* wMaxPacketSize */                \
     0x00                                                   /* bInterval */
     0x00                                                   /* bInterval */
-#endif
 // clang-format on
 // clang-format on
 
 
 #endif /* USB_CDC_H */
 #endif /* USB_CDC_H */

+ 3 - 29
class/msc/usb_msc.h

@@ -61,8 +61,7 @@ struct CSW {
 /*Length of template descriptor: 23 bytes*/
 /*Length of template descriptor: 23 bytes*/
 #define MSC_DESCRIPTOR_LEN (9 + 7 + 7)
 #define MSC_DESCRIPTOR_LEN (9 + 7 + 7)
 // clang-format off
 // clang-format off
-#ifndef CONFIG_USB_HS
-#define MSC_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep,str_idx) \
+#define MSC_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep, wMaxPacketSize, str_idx) \
     /* Interface */                                              \
     /* Interface */                                              \
     0x09,                          /* bLength */                 \
     0x09,                          /* bLength */                 \
     USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */         \
     USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */         \
@@ -77,39 +76,14 @@ struct CSW {
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */         \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */         \
     out_ep,                        /* bEndpointAddress */        \
     out_ep,                        /* bEndpointAddress */        \
     0x02,                          /* bmAttributes */            \
     0x02,                          /* bmAttributes */            \
-    0x40, 0x00,                    /* wMaxPacketSize */          \
+    WBVAL(wMaxPacketSize),         /* wMaxPacketSize */          \
     0x00,                          /* bInterval */               \
     0x00,                          /* bInterval */               \
     0x07,                          /* bLength */                 \
     0x07,                          /* bLength */                 \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */         \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */         \
     in_ep,                         /* bEndpointAddress */        \
     in_ep,                         /* bEndpointAddress */        \
     0x02,                          /* bmAttributes */            \
     0x02,                          /* bmAttributes */            \
-    0x40, 0x00,                    /* wMaxPacketSize */          \
+    WBVAL(wMaxPacketSize),         /* wMaxPacketSize */          \
     0x00                           /* bInterval */
     0x00                           /* bInterval */
-#else
-#define MSC_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep,str_idx) \
-    /* Interface */                                              \
-    0x09,                          /* bLength */                 \
-    USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */         \
-    bFirstInterface,               /* bInterfaceNumber */        \
-    0x00,                          /* bAlternateSetting */       \
-    0x02,                          /* bNumEndpoints */           \
-    USB_DEVICE_CLASS_MASS_STORAGE, /* bInterfaceClass */         \
-    MSC_SUBCLASS_SCSI,             /* bInterfaceSubClass */      \
-    MSC_PROTOCOL_BULK_ONLY,        /* bInterfaceProtocol */      \
-    str_idx,                       /* iInterface */              \
-    0x07,                          /* bLength */                 \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */         \
-    out_ep,                        /* bEndpointAddress */        \
-    0x02,                          /* bmAttributes */            \
-    0x00, 0x02,                    /* wMaxPacketSize */          \
-    0x00,                          /* bInterval */               \
-    0x07,                          /* bLength */                 \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */         \
-    in_ep,                         /* bEndpointAddress */        \
-    0x02,                          /* bmAttributes */            \
-    0x00, 0x02,                    /* wMaxPacketSize */          \
-    0x00                           /* bInterval */
-#endif
 // clang-format on
 // clang-format on
 
 
 #endif /* USB_MSC_H */
 #endif /* USB_MSC_H */

+ 4 - 36
class/mtp/usb_mtp.h

@@ -437,9 +437,8 @@ struct mtp_container_response {
 #define MTP_DESCRIPTOR_LEN (9 + 7 + 7 + 7)
 #define MTP_DESCRIPTOR_LEN (9 + 7 + 7 + 7)
 
 
 // clang-format off
 // clang-format off
-#ifndef CONFIG_USB_HS
-#define MTP_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep, int_ep, str_idx) \
-    /* Interface */                                                          \
+#define MTP_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep, int_ep, wMaxPacketSize, str_idx) \
+    /* Interface */                                                      \
     0x09,                          /* bLength */                         \
     0x09,                          /* bLength */                         \
     USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */                 \
     USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */                 \
     bFirstInterface,               /* bInterfaceNumber */                \
     bFirstInterface,               /* bInterfaceNumber */                \
@@ -453,13 +452,13 @@ struct mtp_container_response {
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
     out_ep,                        /* bEndpointAddress */                \
     out_ep,                        /* bEndpointAddress */                \
     0x02,                          /* bmAttributes */                    \
     0x02,                          /* bmAttributes */                    \
-    0x40, 0x00,                    /* wMaxPacketSize */                  \
+    WBVAL(wMaxPacketSize),         /* wMaxPacketSize */                  \
     0x00,                          /* bInterval */                       \
     0x00,                          /* bInterval */                       \
     0x07,                          /* bLength */                         \
     0x07,                          /* bLength */                         \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
     in_ep,                         /* bEndpointAddress */                \
     in_ep,                         /* bEndpointAddress */                \
     0x02,                          /* bmAttributes */                    \
     0x02,                          /* bmAttributes */                    \
-    0x40, 0x00,                    /* wMaxPacketSize */                  \
+    WBVAL(wMaxPacketSize),         /* wMaxPacketSize */                  \
     0x00,                          /* bInterval */                       \
     0x00,                          /* bInterval */                       \
     0x07,                          /* bLength */                         \
     0x07,                          /* bLength */                         \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
     USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
@@ -467,37 +466,6 @@ struct mtp_container_response {
     0x03,                          /* bmAttributes */                    \
     0x03,                          /* bmAttributes */                    \
     0x1c, 0x00,                    /* wMaxPacketSize */                  \
     0x1c, 0x00,                    /* wMaxPacketSize */                  \
     0x06                           /* bInterval */
     0x06                           /* bInterval */
-#else
-#define MTP_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep, int_ep, str_idx) \
-    /* Interface */                                                          \
-    0x09,                          /* bLength */                         \
-    USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */                 \
-    bFirstInterface,               /* bInterfaceNumber */                \
-    0x00,                          /* bAlternateSetting */               \
-    0x03,                          /* bNumEndpoints */                   \
-    USB_DEVICE_CLASS_MASS_STORAGE, /* bInterfaceClass */                 \
-    USB_MTP_SUB_CLASS,             /* bInterfaceSubClass */              \
-    USB_MTP_PROTOCOL,              /* bInterfaceProtocol */              \
-    str_idx,                       /* iInterface */                      \
-    0x07,                          /* bLength */                         \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
-    out_ep,                        /* bEndpointAddress */                \
-    0x02,                          /* bmAttributes */                    \
-    0x00, 0x02,                    /* wMaxPacketSize */                  \
-    0x00,                          /* bInterval */                       \
-    0x07,                          /* bLength */                         \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
-    in_ep,                         /* bEndpointAddress */                \
-    0x02,                          /* bmAttributes */                    \
-    0x00, 0x02,                    /* wMaxPacketSize */                  \
-    0x00,                          /* bInterval */                       \
-    0x07,                          /* bLength */                         \
-    USB_DESCRIPTOR_TYPE_ENDPOINT,  /* bDescriptorType */                 \
-    int_ep,                        /* bEndpointAddress */                \
-    0x03,                          /* bmAttributes */                    \
-    0x1c, 0x00,                    /* wMaxPacketSize */                  \
-    0x06                           /* bInterval */
-#endif
 // clang-format on
 // clang-format on
 
 
 #endif /* USB_MTP_H */
 #endif /* USB_MTP_H */

+ 14 - 2
demo/cdc_acm_hid_msc_template.c

@@ -26,11 +26,23 @@
 
 
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN + MSC_DESCRIPTOR_LEN + 25)
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN + MSC_DESCRIPTOR_LEN + 25)
 
 
+#ifdef CONFIG_USB_HS
+#define CDC_MAX_MPS 512
+#else
+#define CDC_MAX_MPS 64
+#endif
+
+#ifdef CONFIG_USB_HS
+#define MSC_MAX_MPS 512
+#else
+#define MSC_MAX_MPS 64
+#endif
+
 const uint8_t cdc_acm_hid_msc_descriptor[] = {
 const uint8_t cdc_acm_hid_msc_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x04, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x04, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x02),
-    MSC_DESCRIPTOR_INIT(0x02, MSC_OUT_EP, MSC_IN_EP, 0x02),
+    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, CDC_MAX_MPS, 0x02),
+    MSC_DESCRIPTOR_INIT(0x02, MSC_OUT_EP, MSC_IN_EP, MSC_MAX_MPS, 0x02),
     /************** Descriptor of Joystick Mouse interface ****************/
     /************** Descriptor of Joystick Mouse interface ****************/
     /* 09 */
     /* 09 */
     0x09,                          /* bLength: Interface Descriptor size */
     0x09,                          /* bLength: Interface Descriptor size */

+ 14 - 2
demo/cdc_acm_msc_template.c

@@ -18,12 +18,24 @@
 /*!< config descriptor size */
 /*!< config descriptor size */
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN + MSC_DESCRIPTOR_LEN)
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN + MSC_DESCRIPTOR_LEN)
 
 
+#ifdef CONFIG_USB_HS
+#define CDC_MAX_MPS 512
+#else
+#define CDC_MAX_MPS 64
+#endif
+
+#ifdef CONFIG_USB_HS
+#define MSC_MAX_MPS 512
+#else
+#define MSC_MAX_MPS 64
+#endif
+
 /*!< global descriptor */
 /*!< global descriptor */
 static const uint8_t cdc_msc_descriptor[] = {
 static const uint8_t cdc_msc_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x03, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x03, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x02),
-    MSC_DESCRIPTOR_INIT(0x02, MSC_OUT_EP, MSC_IN_EP, 0x00),
+    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, CDC_MAX_MPS, 0x02),
+    MSC_DESCRIPTOR_INIT(0x02, MSC_OUT_EP, MSC_IN_EP, MSC_MAX_MPS, 0x00),
     ///////////////////////////////////////
     ///////////////////////////////////////
     /// string0 descriptor
     /// string0 descriptor
     ///////////////////////////////////////
     ///////////////////////////////////////

+ 10 - 4
demo/cdc_acm_multi_template.c

@@ -26,14 +26,20 @@
 /*!< config descriptor size */
 /*!< config descriptor size */
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN * 4)
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN * 4)
 
 
+#ifdef CONFIG_USB_HS
+#define CDC_MAX_MPS 512
+#else
+#define CDC_MAX_MPS 64
+#endif
+
 /*!< global descriptor */
 /*!< global descriptor */
 static const uint8_t cdc_descriptor[] = {
 static const uint8_t cdc_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x08, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x08, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x02),
-    CDC_ACM_DESCRIPTOR_INIT(0x02, CDC_INT_EP2, CDC_OUT_EP2, CDC_IN_EP2, 0x02),
-    CDC_ACM_DESCRIPTOR_INIT(0x04, CDC_INT_EP3, CDC_OUT_EP3, CDC_IN_EP3, 0x02),
-    CDC_ACM_DESCRIPTOR_INIT(0x06, CDC_INT_EP4, CDC_OUT_EP4, CDC_IN_EP4, 0x02),
+    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, CDC_MAX_MPS, 0x02),
+    CDC_ACM_DESCRIPTOR_INIT(0x02, CDC_INT_EP2, CDC_OUT_EP2, CDC_IN_EP2, CDC_MAX_MPS, 0x02),
+    CDC_ACM_DESCRIPTOR_INIT(0x04, CDC_INT_EP3, CDC_OUT_EP3, CDC_IN_EP3, CDC_MAX_MPS, 0x02),
+    CDC_ACM_DESCRIPTOR_INIT(0x06, CDC_INT_EP4, CDC_OUT_EP4, CDC_IN_EP4, CDC_MAX_MPS, 0x02),
     ///////////////////////////////////////
     ///////////////////////////////////////
     /// string0 descriptor
     /// string0 descriptor
     ///////////////////////////////////////
     ///////////////////////////////////////

+ 7 - 1
demo/cdc_acm_template.c

@@ -14,11 +14,17 @@
 /*!< config descriptor size */
 /*!< config descriptor size */
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN)
 #define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN)
 
 
+#ifdef CONFIG_USB_HS
+#define CDC_MAX_MPS 512
+#else
+#define CDC_MAX_MPS 64
+#endif
+
 /*!< global descriptor */
 /*!< global descriptor */
 static const uint8_t cdc_descriptor[] = {
 static const uint8_t cdc_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x02),
+    CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, CDC_MAX_MPS, 0x02),
     ///////////////////////////////////////
     ///////////////////////////////////////
     /// string0 descriptor
     /// string0 descriptor
     ///////////////////////////////////////
     ///////////////////////////////////////

+ 7 - 1
demo/cdc_rndis_template.c

@@ -14,11 +14,17 @@
 /*!< config descriptor size */
 /*!< config descriptor size */
 #define USB_CONFIG_SIZE (9 + CDC_RNDIS_DESCRIPTOR_LEN)
 #define USB_CONFIG_SIZE (9 + CDC_RNDIS_DESCRIPTOR_LEN)
 
 
+#ifdef CONFIG_USB_HS
+#define CDC_MAX_MPS 512
+#else
+#define CDC_MAX_MPS 64
+#endif
+
 /*!< global descriptor */
 /*!< global descriptor */
 static const uint8_t cdc_descriptor[] = {
 static const uint8_t cdc_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xEF, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    CDC_RNDIS_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x02),
+    CDC_RNDIS_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, CDC_MAX_MPS, 0x02),
     ///////////////////////////////////////
     ///////////////////////////////////////
     /// string0 descriptor
     /// string0 descriptor
     ///////////////////////////////////////
     ///////////////////////////////////////

+ 1 - 1
demo/cmsis-dap_v2.1_tempate.c

@@ -116,7 +116,7 @@ const uint8_t daplink_descriptor[] = {
     USB_ENDPOINT_DESCRIPTOR_INIT(DAP_IN_EP, USB_ENDPOINT_TYPE_BULK, CDC_MAX_MPS, 0x00),
     USB_ENDPOINT_DESCRIPTOR_INIT(DAP_IN_EP, USB_ENDPOINT_TYPE_BULK, CDC_MAX_MPS, 0x00),
     /* Endpoint IN 2 */
     /* Endpoint IN 2 */
     USB_ENDPOINT_DESCRIPTOR_INIT(DAP_OUT_EP, USB_ENDPOINT_TYPE_BULK, CDC_MAX_MPS, 0x00),
     USB_ENDPOINT_DESCRIPTOR_INIT(DAP_OUT_EP, USB_ENDPOINT_TYPE_BULK, CDC_MAX_MPS, 0x00),
-    CDC_ACM_DESCRIPTOR_INIT(0x01, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x00),
+    CDC_ACM_DESCRIPTOR_INIT(0x01, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, CDC_MAX_MPS, 0x00),
     /* String 0 (LANGID) */
     /* String 0 (LANGID) */
     USB_LANGID_INIT(USBD_LANGID_STRING),
     USB_LANGID_INIT(USBD_LANGID_STRING),
     /* String 1 (Manufacturer) */
     /* String 1 (Manufacturer) */

+ 18 - 2
demo/midi_template.c

@@ -1,6 +1,22 @@
 #include "usbd_core.h"
 #include "usbd_core.h"
 #include "usb_midi.h"
 #include "usb_midi.h"
 
 
+#define MIDI_OUT_EP 0x02
+#define MIDI_IN_EP  0x81
+
+#define USBD_VID           0x0d28
+#define USBD_PID           0x0404
+#define USBD_MAX_POWER     100
+#define USBD_LANGID_STRING 1033
+
+#define USB_CONFIG_SIZE (9 + 9 + 9 + 9 + 7 + MIDI_SIZEOF_JACK_DESC + 7 + 5 + 7 + 5)
+
+#ifdef CONFIG_USB_HS
+#define MIDI_EP_MPS 512
+#else
+#define MIDI_EP_MPS 64
+#endif
+
 const uint8_t midi_descriptor[] = {
 const uint8_t midi_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0100, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
@@ -48,11 +64,11 @@ const uint8_t midi_descriptor[] = {
     // MIDI_OUT_JACK_DESCRIPTOR_INIT(MIDI_JACK_TYPE_EXTERNAL, 0x04, 0x01),
     // MIDI_OUT_JACK_DESCRIPTOR_INIT(MIDI_JACK_TYPE_EXTERNAL, 0x04, 0x01),
     MIDI_JACK_DESCRIPTOR_INIT(0x01),
     MIDI_JACK_DESCRIPTOR_INIT(0x01),
     // OUT endpoint descriptor
     // OUT endpoint descriptor
-    0x09, 0x05, 0x02, 0x02, WBVAL(64), 0x00, 0x00, 0x00,
+    USB_ENDPOINT_DESCRIPTOR_INIT(MIDI_OUT_EP, 0x02, MIDI_EP_MPS, 0x00),
     0x05, 0x25, 0x01, 0x01, 0x01,
     0x05, 0x25, 0x01, 0x01, 0x01,
 
 
     // IN endpoint descriptor
     // IN endpoint descriptor
-    0x09, 0x05, 0x81, 0x02, WBVAL(64), 0x00, 0x00, 0x00,
+    USB_ENDPOINT_DESCRIPTOR_INIT(MIDI_IN_EP, 0x02, MIDI_EP_MPS, 0x00),
     0x05, 0x25, 0x01, 0x01, 0x03,
     0x05, 0x25, 0x01, 0x01, 0x03,
 
 
     ///////////////////////////////////////
     ///////////////////////////////////////

+ 7 - 1
demo/msc_ram_template.c

@@ -11,10 +11,16 @@
 
 
 #define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN)
 #define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN)
 
 
+#ifdef CONFIG_USB_HS
+#define MSC_MAX_MPS 512
+#else
+#define MSC_MAX_MPS 64
+#endif
+
 const uint8_t msc_ram_descriptor[] = {
 const uint8_t msc_ram_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, 0x02),
+    MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, MSC_MAX_MPS, 0x02),
     ///////////////////////////////////////
     ///////////////////////////////////////
     /// string0 descriptor
     /// string0 descriptor
     ///////////////////////////////////////
     ///////////////////////////////////////

+ 7 - 1
demo/mtp_template.c

@@ -61,10 +61,16 @@ struct usb_msosv1_descriptor msosv1_desc = {
 /*!< config descriptor size */
 /*!< config descriptor size */
 #define USB_CONFIG_SIZE (9 + MTP_DESCRIPTOR_LEN)
 #define USB_CONFIG_SIZE (9 + MTP_DESCRIPTOR_LEN)
 
 
+#ifdef CONFIG_USB_HS
+#define MTP_MAX_MPS 512
+#else
+#define MTP_MAX_MPS 64
+#endif
+
 const uint8_t mtp_descriptor[] = {
 const uint8_t mtp_descriptor[] = {
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_1, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0201, 0x01),
     USB_DEVICE_DESCRIPTOR_INIT(USB_2_1, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0201, 0x01),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
     USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
-    MTP_DESCRIPTOR_INIT(0x00, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP, 2),
+    MTP_DESCRIPTOR_INIT(0x00, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP, MTP_MAX_MPS, 0x02),
     ///////////////////////////////////////
     ///////////////////////////////////////
     /// string0 descriptor
     /// string0 descriptor
     ///////////////////////////////////////
     ///////////////////////////////////////