diff --git a/pkg/tinyusb/Kconfig b/pkg/tinyusb/Kconfig index b5cd92bc49..b1c0fcdb2f 100644 --- a/pkg/tinyusb/Kconfig +++ b/pkg/tinyusb/Kconfig @@ -208,7 +208,7 @@ config TUSBD_FS_EP_SIZE default 64 config TUSBD_HS_EP_SIZE - int "Device endpoint Size in High-Speed mode [byte]" + int "Device endpoint size in High-Speed mode [byte]" default 512 config TUSBD_USE_CUSTOM_DESC diff --git a/pkg/tinyusb/Kconfig.cdc b/pkg/tinyusb/Kconfig.cdc index 1b019c8b55..8472aa34dd 100644 --- a/pkg/tinyusb/Kconfig.cdc +++ b/pkg/tinyusb/Kconfig.cdc @@ -19,6 +19,14 @@ config TUSBD_CDC_NOTIF_EP_SIZE int "CDC notification endpoint size [byte]" default 8 +config TUSBD_CDC_FS_EP_SIZE + int "CDC Full-Speed endpoint size [byte]" + default 64 + +config TUSBD_CDC_HS_EP_SIZE + int "CDC High-Speed endpoint size [byte]" + default 512 + config TUSBD_CDC_0_STRING string "CDC0 descriptor string" depends on TUSBD_CDC_NUMOF > 0 diff --git a/pkg/tinyusb/Kconfig.msc b/pkg/tinyusb/Kconfig.msc index abe6857d80..d5f8522103 100644 --- a/pkg/tinyusb/Kconfig.msc +++ b/pkg/tinyusb/Kconfig.msc @@ -14,8 +14,12 @@ config TUSBD_MSC_NUMOF int default 1 -config TUSBD_MSC_EP_SIZE - int "MSC endpoint size [byte]" +config TUSBD_MSC_FS_EP_SIZE + int "MSC Full-Speed endpoint size [byte]" + default 64 + +config TUSBD_MSC_HS_EP_SIZE + int "MSC High-Speed endpoint size [byte]" default 512 config TUSBD_MSC_STRING diff --git a/pkg/tinyusb/contrib/include/tinyusb_descriptors.h b/pkg/tinyusb/contrib/include/tinyusb_descriptors.h index cae43630ae..82e1d57d9f 100644 --- a/pkg/tinyusb/contrib/include/tinyusb_descriptors.h +++ b/pkg/tinyusb/contrib/include/tinyusb_descriptors.h @@ -118,20 +118,11 @@ enum { #endif /* !defined(HAVE_TUSBD_STR_IDX_TYPE) */ #if !defined(TUSBD_DESC_TOTAL_LEN) -#define TUSBD_DESC_CDC_0_LEN ((CONFIG_TUSBD_CDC_NUMOF > 0) ? TUD_CDC_DESC_LEN : 0) -#define TUSBD_DESC_CDC_1_LEN ((CONFIG_TUSBD_CDC_NUMOF > 1) ? TUD_CDC_DESC_LEN : 0) -#define TUSBD_DESC_HID_0_LEN ((CONFIG_TUSBD_HID_NUMOF > 0) ? TUD_HID_INOUT_DESC_LEN : 0) -#define TUSBD_DESC_HID_1_LEN ((CONFIG_TUSBD_HID_NUMOF > 1) ? TUD_HID_INOUT_DESC_LEN : 0) -#define TUSBD_DESC_MSC_LEN ((CONFIG_TUSBD_MSC_NUMOF > 0) ? TUD_MSC_DESC_LEN : 0) -#define TUSBD_DESC_VENDOR_LEN ((CONFIG_TUSBD_VENDOR_NUMOF > 0) ? TUD_VENDOR_DESC_LEN : 0) - #define TUSBD_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + \ - TUSBD_DESC_CDC_0_LEN + \ - TUSBD_DESC_CDC_1_LEN + \ - TUSBD_DESC_HID_0_LEN + \ - TUSBD_DESC_HID_1_LEN + \ - TUSBD_DESC_MSC_LEN + \ - TUSBD_DESC_VENDOR_LEN) + (CONFIG_TUSBD_CDC_NUMOF * TUD_CDC_DESC_LEN) + \ + (CONFIG_TUSBD_HID_NUMOF * TUD_HID_INOUT_DESC_LEN) + \ + (CONFIG_TUSBD_MSC_NUMOF * TUD_MSC_DESC_LEN) + \ + (CONFIG_TUSBD_VENDOR_NUMOF * TUD_VENDOR_DESC_LEN)) #endif /* !defined(TUSBD_DESC_TOTAL_LEN) */ #endif /* !defined(CONFIG_TUSBD_USE_CUSTOM_DESC) */ diff --git a/pkg/tinyusb/contrib/include/tusb_config.h b/pkg/tinyusb/contrib/include/tusb_config.h index f090b43113..df5b44dd5c 100644 --- a/pkg/tinyusb/contrib/include/tusb_config.h +++ b/pkg/tinyusb/contrib/include/tusb_config.h @@ -186,28 +186,68 @@ #endif #endif -#ifndef CONFIG_TUSBD_EP0_SIZE -#define CONFIG_TUSBD_EP0_SIZE 64 +#ifndef CONFIG_TUSBD_CDC_NOTIF_EP_SIZE +#define CONFIG_TUSBD_CDC_NOTIF_EP_SIZE 8 #endif -#ifndef CONFIG_TUSBD_MSC_EP_SIZE -#define CONFIG_TUSBD_MSC_EP_SIZE 512 +#ifndef CONFIG_TUSBD_EP0_SIZE +#define CONFIG_TUSBD_EP0_SIZE 64 +#endif + +#ifndef CONFIG_TUSBD_FS_EP_SIZE +#define CONFIG_TUSBD_FS_EP_SIZE 64 +#endif + +#ifndef CONFIG_TUSBD_HS_EP_SIZE +#define CONFIG_TUSBD_HS_EP_SIZE 512 +#endif + +#ifndef CONFIG_TUSBD_CDC_FS_EP_SIZE +#define CONFIG_TUSBD_CDC_FS_EP_SIZE CONFIG_TUSBD_FS_EP_SIZE +#endif + +#ifndef CONFIG_TUSBD_CDC_HS_EP_SIZE +#define CONFIG_TUSBD_CDC_HS_EP_SIZE CONFIG_TUSBD_HS_EP_SIZE #endif #ifndef CONFIG_TUSBD_HID_EP_SIZE -#define CONFIG_TUSBD_HID_EP_SIZE 64 +#define CONFIG_TUSBD_HID_EP_SIZE CONFIG_TUSBD_FS_EP_SIZE +#endif + +#ifndef CONFIG_TUSBD_HID_0_POLL_INTERVALL +#define CONFIG_TUSBD_HID_0_POLL_INTERVALL 10 +#endif + +#ifndef CONFIG_TUSBD_HID_1_POLL_INTERVALL +#define CONFIG_TUSBD_HID_1_POLL_INTERVALL 10 +#endif + +#ifndef CONFIG_TUSBD_MSC_FS_EP_SIZE +#define CONFIG_TUSBD_MSC_FS_EP_SIZE CONFIG_TUSBD_FS_EP_SIZE +#endif + +#ifndef CONFIG_TUSBD_MSC_HS_EP_SIZE +#define CONFIG_TUSBD_MSC_HS_EP_SIZE CONFIG_TUSBD_HS_EP_SIZE +#endif + +#ifndef CONFIG_TUSBD_VENDOR_FS_EP_SIZE +#define CONFIG_TUSBD_VENDOR_FS_EP_SIZE CONFIG_TUSBD_FS_EP_SIZE +#endif + +#ifndef CONFIG_TUSBD_VENDOR_HS_EP_SIZE +#define CONFIG_TUSBD_VENDOR_HS_EP_SIZE CONFIG_TUSBD_HS_EP_SIZE #endif #ifndef CONFIG_TUSBH_ENUM_SIZE -#define CONFIG_TUSBH_ENUM_SIZE 256 +#define CONFIG_TUSBH_ENUM_SIZE 256 #endif #ifndef CONFIG_TUSBH_HID_EPIN_SIZE -#define CONFIG_TUSBH_HID_EPIN_SIZE 64 +#define CONFIG_TUSBH_HID_EPIN_SIZE CONFIG_TUSBD_HID_EP_SIZE #endif #ifndef CONFIG_TUSBH_HID_EPOUT_SIZE -#define CONFIG_TUSBH_HID_EPOUT_SIZE 64 +#define CONFIG_TUSBH_HID_EPOUT_SIZE CONFIG_TUSBD_HID_EP_SIZE #endif /** @@ -223,9 +263,7 @@ #define CFG_TUSB_OS OPT_OS_CUSTOM /** Debug log level */ -#ifndef CFG_TUSB_DEBUG #define CFG_TUSB_DEBUG 0 -#endif /** * @brief DMA memory section and alignment @@ -235,13 +273,8 @@ * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) */ -#ifndef CFG_TUSB_MEM_SECTION #define CFG_TUSB_MEM_SECTION -#endif - -#ifndef CFG_TUSB_MEM_ALIGN #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) -#endif /** @} */ @@ -251,61 +284,20 @@ */ #define CFG_TUD_ENABLED MODULE_TINYUSB_DEVICE -#ifndef CFG_TUD_ENDPOINT0_SIZE #define CFG_TUD_ENDPOINT0_SIZE CONFIG_TUSBD_EP0_SIZE -#endif -#ifndef CFG_TUD_AUDIO #define CFG_TUD_AUDIO CONFIG_TUSBD_AUDIO_NUMOF -#endif - -#ifndef CFG_TUD_BTH #define CFG_TUD_BTH CONFIG_TUSBD_BTH_NUMOF -#endif - -#ifndef CFG_TUD_CDC #define CFG_TUD_CDC CONFIG_TUSBD_CDC_NUMOF -#endif - -#ifndef CFG_TUD_DFU #define CFG_TUD_DFU CONFIG_TUSBD_DFU_NUMOF -#endif - -#ifndef CFG_TUD_DFU_RUNTIME #define CFG_TUD_DFU_RUNTIME CONFIG_TUSBD_DFU_RT_NUMOF -#endif - -#ifndef CFG_TUD_HID #define CFG_TUD_HID CONFIG_TUSBD_HID_NUMOF -#endif - -#ifndef CFG_TUD_MIDI #define CFG_TUD_MIDI CONFIG_TUSBD_MIDI_NUMOF -#endif - -#ifndef CFG_TUD_MSC #define CFG_TUD_MSC CONFIG_TUSBD_MSC_NUMOF -#endif - -#ifndef CFG_TUD_ECM_RNDIS -#define CFG_TUD_ECM_RNDIS CONFIG_TUSBD_ECM_NUMOF -#endif - -#ifndef CFG_TUD_NCM -#define CFG_TUD_NCM CONFIG_TUSBD_NCM_NUMOF -#endif - -#ifndef CFG_TUD_USBTMC +#define CFG_TUD_NCM CONFIG_TUSBD_NET_CDC_NCM #define CFG_TUD_USBTMC CONFIG_TUSBD_USBTMC_NUMOF -#endif - -#ifndef CFG_TUD_VENDOR #define CFG_TUD_VENDOR CONFIG_TUSBD_VENDOR_NUMOF -#endif - -#ifndef CFG_TUD_VIDEO #define CFG_TUD_VIDEO CONFIG_TUSBD_VIDEO_NUMOF -#endif /** @} */ @@ -315,38 +307,18 @@ */ #define CFG_TUH_ENABLED MODULE_TINYUSB_HOST -#ifndef CFG_TUH_MAX_SPEED #define CFG_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED -#endif -#ifndef CFG_TUH_ENUMERATION_BUFSIZE #define CFG_TUH_ENUMERATION_BUFSIZE CONFIG_TUSBH_ENUM_SIZE -#endif /** Hub typically has 4 ports */ -#ifndef CFG_TUH_DEVICE_MAX #define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) -#endif -#ifndef CFG_TUH_CDC #define CFG_TUH_CDC CONFIG_TUSBH_CDC_NUMOF -#endif - -#ifndef CFG_TUH_HID #define CFG_TUH_HID CONFIG_TUSBH_HID_NUMOF -#endif - -#ifndef CFG_TUH_HUB #define CFG_TUH_HUB CONFIG_TUSBH_HUB_NUMOF -#endif - -#ifndef CFG_TUH_MSC #define CFG_TUH_MSC CONFIG_TUSBH_MSC_NUMOF -#endif - -#ifndef CFG_TUD_VENDOR #define CFG_TUH_VENDOR CONFIG_TUSBH_VENDOR_NUMOF -#endif /** @} */ @@ -354,15 +326,10 @@ * @name Typical required CDC device class configurations * @{ */ -/** CDC RX FIFO size */ -#ifndef CFG_TUD_CDC_RX_BUFSIZE +#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? CONFIG_TUSBD_CDC_HS_EP_SIZE \ + : CONFIG_TUSBD_CDC_FS_EP_SIZE) #define CFG_TUD_CDC_RX_BUFSIZE CFG_TUD_CDC_EP_BUFSIZE -#endif - -/** CDC RX FIFO size */ -#ifndef CFG_TUD_CDC_TX_BUFSIZE #define CFG_TUD_CDC_TX_BUFSIZE CFG_TUD_CDC_EP_BUFSIZE -#endif /** @} */ @@ -370,53 +337,39 @@ * @name Typical required DFU device class configurations * @{ */ -#ifndef CFG_TUD_DFU_XFER_BUFSIZE -#define CFG_TUD_DFU_XFER_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) -#endif +#define CFG_TUD_DFU_XFER_BUFSIZE (TUD_OPT_HIGH_SPEED ? CONFIG_TUSBD_HS_EP_SIZE \ + : CONFIG_TUSBD_FS_EP_SIZE) /** @} */ /** * @name Typical required HID device class configurations * @{ */ -#ifndef CFG_TUD_HID_EP_BUFSIZE #define CFG_TUD_HID_EP_BUFSIZE CONFIG_TUSBD_HID_EP_SIZE -#endif /** @} */ /** * @name Typical required MIDI device class configurations * @{ */ -#ifndef CFG_TUD_MIDI_RX_BUFSIZE #define CFG_TUD_MIDI_RX_BUFSIZE CFG_TUD_MIDI_EP_BUFSIZE -#endif - -#ifndef CFG_TUD_MIDI_TX_BUFSIZE #define CFG_TUD_MIDI_TX_BUFSIZE CFG_TUD_MIDI_EP_BUFSIZE -#endif /** @} */ /** * @name Typical required MSC device class configurations * @{ */ -#ifndef CFG_TUD_MSC_EP_BUFSIZE -#define CFG_TUD_MSC_EP_BUFSIZE CONFIG_TUSBD_MSC_EP_SIZE -#endif +#define CFG_TUD_MSC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? CONFIG_TUSBD_MSC_HS_EP_SIZE \ + : CONFIG_TUSBD_MSC_FS_EP_SIZE) /** @} */ /** * @name Typical required HID host class configurations * @{ */ -#ifndef CFG_TUH_HID_EPIN_BUFSIZE #define CFG_TUH_HID_EPIN_BUFSIZE CONFIG_TUSBH_HID_EPIN_SIZE -#endif - -#ifndef CFG_TUH_HID_EPOUT_BUFSIZE #define CFG_TUH_HID_EPOUT_BUFSIZE CONFIG_TUSBH_HID_EPOUT_SIZE -#endif /** @} */ #ifdef __cplusplus diff --git a/pkg/tinyusb/contrib/tinyusb_descriptors.c b/pkg/tinyusb/contrib/tinyusb_descriptors.c index 3fc157c9c4..23759aa0eb 100644 --- a/pkg/tinyusb/contrib/tinyusb_descriptors.c +++ b/pkg/tinyusb/contrib/tinyusb_descriptors.c @@ -30,6 +30,9 @@ #include "tinyusb_descriptors.h" +#define ENABLE_DEBUG 0 +#include "debug.h" + /* don't compile this part if CONFIG_TUSBD_USE_CUSTOM_DESC is set */ #if !defined(CONFIG_TUSBD_USE_CUSTOM_DESC) @@ -184,26 +187,6 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, *--------------------------------------------------------------------+ */ -#ifndef CONFIG_TUSBD_FS_EP_SIZE -#define CONFIG_TUSBD_FS_EP_SIZE 64 -#endif - -#ifndef CONFIG_TUSBD_HS_EP_SIZE -#define CONFIG_TUSBD_HS_EP_SIZE 512 -#endif - -#ifndef CONFIG_TUSBD_CDC_NOTIF_EP_SIZE -#define CONFIG_TUSBD_CDC_NOTIF_EP_SIZE 8 -#endif - -#ifndef CONFIG_TUSBD_HID_0_POLL_INTERVALL -#define CONFIG_TUSBD_HID_0_POLL_INTERVALL 10 -#endif - -#ifndef CONFIG_TUSBD_HID_1_POLL_INTERVALL -#define CONFIG_TUSBD_HID_1_POLL_INTERVALL 10 -#endif - #if CONFIG_USB_SELF_POWERED && CONFIG_USB_REM_WAKEUP #define DESC_DEV_ATTR (USB_CONF_ATTR_SELF_POWERED || USB_CONF_ATTR_REM_WAKEUP) #elif CONFIG_USB_SELF_POWERED @@ -223,35 +206,38 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, TUD_CONFIG_DESCRIPTOR(id, TUSBD_ITF_NUMOF, 0, TUSBD_DESC_TOTAL_LEN, \ DESC_DEV_ATTR, CONFIG_USB_MAX_POWER) -#define _TUD_CDC_DESC(s, n) \ +#define _TUD_CDC_DESC(speed, n) \ /* Interface number, string index, EP notification address and size, * EP Data Out & In, EP size. */ \ TUD_CDC_DESCRIPTOR(TUSBD_ITF_CDC_##n, TUSBD_STR_IDX_CDC_##n, \ TUSBD_EP_CDC_##n##_NOTIF, CONFIG_TUSBD_CDC_NOTIF_EP_SIZE, \ TUSBD_EP_CDC_##n##_OUT, TUSBD_EP_CDC_##n##_IN, \ - s ? CONFIG_TUSBD_HS_EP_SIZE : CONFIG_TUSBD_FS_EP_SIZE) + speed ? CONFIG_TUSBD_CDC_HS_EP_SIZE \ + : CONFIG_TUSBD_CDC_FS_EP_SIZE) -#define _TUD_HID_INOUT_DESC(s, n) \ +#define _TUD_HID_INOUT_DESC(speed, n) \ /* Interface number, string index, protocol, report descriptor len, * EP Out & EP In address, EP size, polling interval */ \ TUD_HID_INOUT_DESCRIPTOR(TUSBD_ITF_HID_##n, TUSBD_STR_IDX_HID_##n, \ HID_ITF_PROTOCOL_NONE, \ sizeof(tusb_desc_hid_##n##_report), \ TUSBD_EP_HID_##n##_OUT, TUSBD_EP_HID_##n##_IN, \ - s ? CONFIG_TUSBD_HS_EP_SIZE : CONFIG_TUSBD_FS_EP_SIZE, \ + CONFIG_TUSBD_HID_EP_SIZE, \ CONFIG_TUSBD_HID_##n##_POLL_INTERVALL) -#define _TUD_MSC_DESC(s) \ +#define _TUD_MSC_DESC(speed) \ /* Interface number, string index, EP Out & In address, EP size */ \ TUD_MSC_DESCRIPTOR(TUSBD_ITF_MSC, TUSBD_STR_IDX_MSC, \ TUSBD_EP_MSC_OUT, TUSBD_EP_MSC_IN, \ - s ? CONFIG_TUSBD_HS_EP_SIZE : CONFIG_TUSBD_FS_EP_SIZE) + speed ? CONFIG_TUSBD_MSC_HS_EP_SIZE \ + : CONFIG_TUSBD_MSC_FS_EP_SIZE) -#define _TUD_VENDOR_DESC(s) \ +#define _TUD_VENDOR_DESC(speed) \ /* Interface number, string index, EP Out & In address, EP size */ \ TUD_VENDOR_DESCRIPTOR(TUSBD_ITF_VENDOR, TUSBD_STR_IDX_VENDOR, \ TUSBD_EP_VENDOR_OUT, TUSBD_EP_VENDOR_IN, \ - s ? CONFIG_TUSBD_HS_EP_SIZE : CONFIG_TUSBD_FS_EP_SIZE) + speed ? CONFIG_TUSBD_VENDOR_HS_EP_SIZE \ + : CONFIG_TUSBD_VENDOR_FS_EP_SIZE) /* FS configuration */ __attribute__((weak)) @@ -356,7 +342,7 @@ uint8_t const *tud_descriptor_device_qualifier_cb(void) __attribute__((weak)) uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) { - (void)index; /* for multiple configurations */ + DEBUG("[tinyusb] %s: %u\n", __func__, index); /* If the link speed is HS, return the FS config, and vice versa. * Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG */ @@ -380,7 +366,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) __attribute__((weak)) uint8_t const *tud_descriptor_configuration_cb(uint8_t index) { - (void)index; /* for multiple configurations */ + DEBUG("[tinyusb] %s: %u\n", __func__, index); #if TUD_OPT_HIGH_SPEED /* Although we are HS, host may be FS. */ @@ -435,22 +421,22 @@ char const* tusb_string_desc_array[] = { NULL, /* 3: Serial number generated during runtime */ #endif #if CONFIG_TUSBD_CDC_NUMOF > 0 - CONFIG_TUSBD_CDC_0_STRING, /* CDC Interface 0 */ + CONFIG_TUSBD_CDC_0_STRING, /* CDC Interface 0 */ #endif #if CONFIG_TUSBD_CDC_NUMOF > 1 - CONFIG_TUSBD_CDC_1_STRING, /* CDC Interface 1 */ + CONFIG_TUSBD_CDC_1_STRING, /* CDC Interface 1 */ #endif #if CONFIG_TUSBD_HID_NUMOF > 0 - CONFIG_TUSBD_HID_0_STRING, /* HID Interface 0 */ + CONFIG_TUSBD_HID_0_STRING, /* HID Interface 0 */ #endif #if CONFIG_TUSBD_HID_NUMOF > 1 - CONFIG_TUSBD_HID_1_STRING, /* HID Interface 1 */ + CONFIG_TUSBD_HID_1_STRING, /* HID Interface 1 */ #endif #if CONFIG_TUSBD_MSC_NUMOF - CONFIG_TUSBD_MSC_STRING, /* MSC Interface */ + CONFIG_TUSBD_MSC_STRING, /* MSC Interface */ #endif #if CONFIG_TUSBD_VENDOR_NUMOF - CONFIG_TUSBD_VENDOR_STRING, /* Vendor Interface */ + CONFIG_TUSBD_VENDOR_STRING, /* Vendor Interface */ #endif };