From 0a3264ba9636f0414078fa0c498178eae2994118 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 18 Apr 2023 14:21:11 +0200 Subject: [PATCH] shared/tinyusb: Support HS endpoint sizes. Set buffer and endpoint sizes to 512 if the device is configured as a High Speed device. Signed-off-by: iabdalkader --- shared/tinyusb/mp_usbd_descriptor.c | 2 +- shared/tinyusb/tusb_config.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/shared/tinyusb/mp_usbd_descriptor.c b/shared/tinyusb/mp_usbd_descriptor.c index 8fab599b67..72a2652179 100644 --- a/shared/tinyusb/mp_usbd_descriptor.c +++ b/shared/tinyusb/mp_usbd_descriptor.c @@ -34,7 +34,7 @@ #include "mp_usbd_internal.h" #define USBD_CDC_CMD_MAX_SIZE (8) -#define USBD_CDC_IN_OUT_MAX_SIZE (64) +#define USBD_CDC_IN_OUT_MAX_SIZE ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 64) const tusb_desc_device_t mp_usbd_desc_device_static = { .bLength = sizeof(tusb_desc_device_t), diff --git a/shared/tinyusb/tusb_config.h b/shared/tinyusb/tusb_config.h index 28bee09a59..96e883fc88 100644 --- a/shared/tinyusb/tusb_config.h +++ b/shared/tinyusb/tusb_config.h @@ -43,7 +43,9 @@ #define MICROPY_HW_USB_CDC_INTERFACE_STRING "Board CDC" #endif +#ifndef CFG_TUSB_RHPORT0_MODE #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) +#endif #if MICROPY_HW_USB_CDC #define CFG_TUD_CDC (1) @@ -59,8 +61,8 @@ // CDC Configuration #if CFG_TUD_CDC -#define CFG_TUD_CDC_RX_BUFSIZE (256) -#define CFG_TUD_CDC_TX_BUFSIZE (256) +#define CFG_TUD_CDC_RX_BUFSIZE ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 256) +#define CFG_TUD_CDC_TX_BUFSIZE ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 256) #endif // MSC Configuration