Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/tinyusb: support for multiple configuration descriptors #18983

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pkg/tinyusb/Kconfig.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions pkg/tinyusb/Kconfig.msc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 10 additions & 13 deletions pkg/tinyusb/contrib/include/tinyusb_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,19 @@ 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) */

#define TUSBD_DESC_ALT_TOTAL_LEN (TUD_CONFIG_DESC_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(CONFIG_TUSBD_USE_CUSTOM_DESC) */

#ifdef __cplusplus
Expand Down
155 changes: 54 additions & 101 deletions pkg/tinyusb/contrib/include/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,68 @@
#endif
#endif

#ifndef CONFIG_TUSBD_CDC_NOTIF_EP_SIZE
#define CONFIG_TUSBD_CDC_NOTIF_EP_SIZE 8
#endif

#ifndef CONFIG_TUSBD_EP0_SIZE
#define CONFIG_TUSBD_EP0_SIZE 64
#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_MSC_EP_SIZE
#define CONFIG_TUSBD_MSC_EP_SIZE 512
#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

/**
Expand All @@ -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
Expand All @@ -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

/** @} */

Expand All @@ -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

/** @} */

Expand All @@ -315,108 +307,69 @@
*/
#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

/** @} */

/**
* @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

/** @} */

/**
* @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
Expand Down
Loading