summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakimisu <[email protected]>2023-06-21 19:39:22 +0800
committersakimisu <[email protected]>2023-06-21 19:39:22 +0800
commit2d1b4b8b828c0fae600b21584feee977bf487414 (patch)
tree4626b5ab0864bb4bbce68d61bfe0dd97ede71b4c
parent9bac9537db4182c9ce94d9f0345fec1881f5d83a (diff)
export cdc/msc/rndis/mtp mps, configured by user
-rw-r--r--class/cdc/usb_cdc.h146
-rw-r--r--class/msc/usb_msc.h32
-rw-r--r--class/mtp/usb_mtp.h40
-rw-r--r--demo/cdc_acm_hid_msc_template.c16
-rw-r--r--demo/cdc_acm_msc_template.c16
-rw-r--r--demo/cdc_acm_multi_template.c14
-rw-r--r--demo/cdc_acm_template.c8
-rw-r--r--demo/cdc_rndis_template.c8
-rw-r--r--demo/cmsis-dap_v2.1_tempate.c2
-rw-r--r--demo/midi_template.c20
-rw-r--r--demo/msc_ram_template.c8
-rw-r--r--demo/mtp_template.c8
12 files changed, 98 insertions, 220 deletions
diff --git a/class/cdc/usb_cdc.h b/class/cdc/usb_cdc.h
index ed8184eb..027e08d6 100644
--- a/class/cdc/usb_cdc.h
+++ b/class/cdc/usb_cdc.h
@@ -302,8 +302,7 @@ struct cdc_ecm_descriptor {
/*Length of template descriptor: 66 bytes*/
#define CDC_ACM_DESCRIPTOR_LEN (8 + 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7)
// 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 */ \
0x08, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, /* bDescriptorType */ \
@@ -359,152 +358,20 @@ struct cdc_ecm_descriptor {
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
out_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x40, 0x00, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
0x00, /* bInterval */ \
0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
in_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x40, 0x00, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
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
/*Length of template descriptor: 66 bytes*/
#define CDC_RNDIS_DESCRIPTOR_LEN (8 + 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7)
// 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 */ \
0x08, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, /* bDescriptorType */ \
@@ -560,15 +427,14 @@ struct cdc_ecm_descriptor {
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
out_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x00, 0x02, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
0x00, /* bInterval */ \
0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
in_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x00, 0x02, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
0x00 /* bInterval */
-#endif
// clang-format on
#endif /* USB_CDC_H */
diff --git a/class/msc/usb_msc.h b/class/msc/usb_msc.h
index 1e7634a0..75187f5e 100644
--- a/class/msc/usb_msc.h
+++ b/class/msc/usb_msc.h
@@ -61,8 +61,7 @@ struct CSW {
/*Length of template descriptor: 23 bytes*/
#define MSC_DESCRIPTOR_LEN (9 + 7 + 7)
// 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 */ \
0x09, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
@@ -77,39 +76,14 @@ struct CSW {
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
out_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x40, 0x00, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
0x00, /* bInterval */ \
0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
in_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x40, 0x00, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
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
#endif /* USB_MSC_H */
diff --git a/class/mtp/usb_mtp.h b/class/mtp/usb_mtp.h
index 968c4d0e..dc19db5f 100644
--- a/class/mtp/usb_mtp.h
+++ b/class/mtp/usb_mtp.h
@@ -437,9 +437,8 @@ struct mtp_container_response {
#define MTP_DESCRIPTOR_LEN (9 + 7 + 7 + 7)
// 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 */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
bFirstInterface, /* bInterfaceNumber */ \
@@ -453,13 +452,13 @@ struct mtp_container_response {
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
out_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x40, 0x00, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
0x00, /* bInterval */ \
0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
in_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \
- 0x40, 0x00, /* wMaxPacketSize */ \
+ WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
0x00, /* bInterval */ \
0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
@@ -467,37 +466,6 @@ struct mtp_container_response {
0x03, /* bmAttributes */ \
0x1c, 0x00, /* wMaxPacketSize */ \
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
#endif /* USB_MTP_H */
diff --git a/demo/cdc_acm_hid_msc_template.c b/demo/cdc_acm_hid_msc_template.c
index 58afd7e9..a93f64e2 100644
--- a/demo/cdc_acm_hid_msc_template.c
+++ b/demo/cdc_acm_hid_msc_template.c
@@ -26,11 +26,23 @@
#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[] = {
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),
- 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 ****************/
/* 09 */
0x09, /* bLength: Interface Descriptor size */
diff --git a/demo/cdc_acm_msc_template.c b/demo/cdc_acm_msc_template.c
index f322c925..e66e5dff 100644
--- a/demo/cdc_acm_msc_template.c
+++ b/demo/cdc_acm_msc_template.c
@@ -18,12 +18,24 @@
/*!< config descriptor size */
#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 */
static const uint8_t cdc_msc_descriptor[] = {
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),
- 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
///////////////////////////////////////
diff --git a/demo/cdc_acm_multi_template.c b/demo/cdc_acm_multi_template.c
index 68eb4e41..5ab43353 100644
--- a/demo/cdc_acm_multi_template.c
+++ b/demo/cdc_acm_multi_template.c
@@ -26,14 +26,20 @@
/*!< config descriptor size */
#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 */
static const uint8_t cdc_descriptor[] = {
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),
- 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
///////////////////////////////////////
diff --git a/demo/cdc_acm_template.c b/demo/cdc_acm_template.c
index 754845ef..3cd1fea0 100644
--- a/demo/cdc_acm_template.c
+++ b/demo/cdc_acm_template.c
@@ -14,11 +14,17 @@
/*!< config descriptor size */
#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 */
static const uint8_t cdc_descriptor[] = {
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),
- 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
///////////////////////////////////////
diff --git a/demo/cdc_rndis_template.c b/demo/cdc_rndis_template.c
index f9e974a4..4b9b6d10 100644
--- a/demo/cdc_rndis_template.c
+++ b/demo/cdc_rndis_template.c
@@ -14,11 +14,17 @@
/*!< config descriptor size */
#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 */
static const uint8_t cdc_descriptor[] = {
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),
- 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
///////////////////////////////////////
diff --git a/demo/cmsis-dap_v2.1_tempate.c b/demo/cmsis-dap_v2.1_tempate.c
index 4e7c9ea7..c82a005e 100644
--- a/demo/cmsis-dap_v2.1_tempate.c
+++ b/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),
/* Endpoint IN 2 */
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) */
USB_LANGID_INIT(USBD_LANGID_STRING),
/* String 1 (Manufacturer) */
diff --git a/demo/midi_template.c b/demo/midi_template.c
index c58b3b28..a9596a11 100644
--- a/demo/midi_template.c
+++ b/demo/midi_template.c
@@ -1,6 +1,22 @@
#include "usbd_core.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[] = {
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),
@@ -48,11 +64,11 @@ const uint8_t midi_descriptor[] = {
// MIDI_OUT_JACK_DESCRIPTOR_INIT(MIDI_JACK_TYPE_EXTERNAL, 0x04, 0x01),
MIDI_JACK_DESCRIPTOR_INIT(0x01),
// 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,
// 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,
///////////////////////////////////////
diff --git a/demo/msc_ram_template.c b/demo/msc_ram_template.c
index ebd34fce..d755a817 100644
--- a/demo/msc_ram_template.c
+++ b/demo/msc_ram_template.c
@@ -11,10 +11,16 @@
#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[] = {
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),
- 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
///////////////////////////////////////
diff --git a/demo/mtp_template.c b/demo/mtp_template.c
index 20d3fb6d..33e4f506 100644
--- a/demo/mtp_template.c
+++ b/demo/mtp_template.c
@@ -61,10 +61,16 @@ struct usb_msosv1_descriptor msosv1_desc = {
/*!< config descriptor size */
#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[] = {
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),
- 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
///////////////////////////////////////