From 028c22083b5284c5be6e6d91b451415b8ccaebb9 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 6 Nov 2022 11:40:22 +0100 Subject: [PATCH] pkg/tinyusb: add Kconfig variables for common tinyUSB descriptors --- pkg/tinyusb/Kconfig | 43 +++++++++++++++++++++++++++++++++-------- pkg/tinyusb/Kconfig.cdc | 32 ++++++++++++++++++++++++++++++ pkg/tinyusb/Kconfig.hid | 42 ++++++++++++++++++++++++++++++++++++++++ pkg/tinyusb/Kconfig.msc | 26 +++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 pkg/tinyusb/Kconfig.cdc create mode 100644 pkg/tinyusb/Kconfig.hid create mode 100644 pkg/tinyusb/Kconfig.msc diff --git a/pkg/tinyusb/Kconfig b/pkg/tinyusb/Kconfig index c1224f5b59..459bea6dc3 100644 --- a/pkg/tinyusb/Kconfig +++ b/pkg/tinyusb/Kconfig @@ -19,6 +19,8 @@ menuconfig PACKAGE_TINYUSB bool "TinyUSB stack package" depends on HAS_ARCH_32BIT depends on HAS_TINYUSB_DEVICE || HAS_TINYUSB_HOST + select MODULE_FMT + select MODULE_LUID select MODULE_PERIPH_USBDEV_CLK select MODULE_SEMA select MODULE_TINYUSB_COMMON @@ -39,8 +41,8 @@ menuconfig PACKAGE_TINYUSB || CPU_COMMON_SAMD5X || CPU_FAM_SAML21 || CPU_FAM_SAMR34 \ || CPU_FAM_SAMR30 select MODULE_TINYUSB_PORTABLE_NRF5X if CPU_FAM_NRF52 - select PACKAGE_NRFX if CPU_FAM_NRF52 select MODULE_ZTIMER_MSEC + select PACKAGE_NRFX if CPU_FAM_NRF52 help tinyUSB is an open-source cross-platform USB Host/Device stack for embedded systems. @@ -74,6 +76,7 @@ config MODULE_TINYUSB_HW config MODULE_TINYUSB_DEVICE bool "Device Stack" depends on HAS_TINYUSB_DEVICE + default y help Select to enable tinyUSB device stack @@ -117,8 +120,7 @@ menu "Device Classes" bool "Bluetooth Host Controller Interface (BTH HCI)" depends on MODULE_TINYUSB_DEVICE - config MODULE_TINYUSB_CLASS_CDC - bool "Communication Device Class (CDC)" + rsource "Kconfig.cdc" config MODULE_TINYUSB_CLASS_DFU bool "Device Firmware Update (DFU) Runtime" @@ -128,11 +130,8 @@ menu "Device Classes" bool "Device Firmware Update (DFU)" depends on MODULE_TINYUSB_DEVICE - config MODULE_TINYUSB_CLASS_HID - bool "Human Interface Device (HID)" - - config MODULE_TINYUSB_CLASS_MSC - bool "Mass Storage Class (MSC)" + rsource "Kconfig.hid" + rsource "Kconfig.msc" config MODULE_TINYUSB_CLASS_MIDI bool "Musical Instrument Digital Interface (MIDI)" @@ -159,4 +158,32 @@ menu "Device Classes" endmenu +if MODULE_TINYUSB_DEVICE + +config TUSBD_EP0_SIZE + int "Device control endpoint (EP0) size [byte]" + default 64 + +config TUSBD_FS_EP_SIZE + int "Device endpoint size in Full-Speed mode [byte]" + default 64 + +config TUSBD_HS_EP_SIZE + int "Device endpoint Size in High-Speed mode [byte]" + default 512 + +config TUSBD_USE_CUSTOM_DESC + bool "Custom device descriptors" + depends on MODULE_TINYUSB_DEVICE + help + Enable this option to define custom descriptors for the selected + device classes. Otherwise, generic descriptors will be generated + according to the selected device classes. + At the moment, the generation of generic descriptors is only supported + for all combinations of up to two CDC interfaces, up to two generic + In/Out HID interfaces, up to one MSC interface and up to one vendor + interface. In all other cases, custom descriptors must be implemented + and handled. + +endif # MODULE_TINYUSB_DEVICE endif # PACKAGE_TINYUSB diff --git a/pkg/tinyusb/Kconfig.cdc b/pkg/tinyusb/Kconfig.cdc new file mode 100644 index 0000000000..1b019c8b55 --- /dev/null +++ b/pkg/tinyusb/Kconfig.cdc @@ -0,0 +1,32 @@ +# Copyright (c) 2022 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig MODULE_TINYUSB_CLASS_CDC + bool "Communication Device Class (CDC)" + +if MODULE_TINYUSB_CLASS_CDC && MODULE_TINYUSB_DEVICE + +config TUSBD_CDC_NUMOF + int "Number of CDC interfaces" + default 1 + range 1 2 + +config TUSBD_CDC_NOTIF_EP_SIZE + int "CDC notification endpoint size [byte]" + default 8 + +config TUSBD_CDC_0_STRING + string "CDC0 descriptor string" + depends on TUSBD_CDC_NUMOF > 0 + default "TinyUSB CDC0" + +config TUSBD_CDC_1_STRING + string "CDC1 descriptor string" + depends on TUSBD_CDC_NUMOF > 1 + default "TinyUSB CDC1" + +endif diff --git a/pkg/tinyusb/Kconfig.hid b/pkg/tinyusb/Kconfig.hid new file mode 100644 index 0000000000..31587cdd45 --- /dev/null +++ b/pkg/tinyusb/Kconfig.hid @@ -0,0 +1,42 @@ +# Copyright (c) 2022 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig MODULE_TINYUSB_CLASS_HID + bool "Human Interface Device (HID)" + +if MODULE_TINYUSB_CLASS_HID && MODULE_TINYUSB_DEVICE + +config TUSBD_HID_NUMOF + int "Number of HID interfaces" + default 1 + range 1 2 + +config TUSBD_HID_EP_SIZE + int "HID endpoint size [byte]" + default 64 + +config TUSBD_HID_0_POLL_INTERVALL + int "HID0 polling interval [ms]" + depends on TUSBD_HID_NUMOF > 0 + default 10 + +config TUSBD_HID_0_STRING + string "HID0 descriptor string" + depends on TUSBD_HID_NUMOF > 0 + default "TinyUSB HID0 (Generic In/Out)" + +config TUSBD_HID_1_POLL_INTERVALL + int "HID1 polling interval [ms]" + depends on TUSBD_HID_NUMOF > 1 + default 10 + +config TUSBD_HID_1_STRING + string "HID1 descriptor string" + depends on TUSBD_HID_NUMOF > 1 + default "TinyUSB HID1 (Generic In/Out)" + +endif diff --git a/pkg/tinyusb/Kconfig.msc b/pkg/tinyusb/Kconfig.msc new file mode 100644 index 0000000000..abe6857d80 --- /dev/null +++ b/pkg/tinyusb/Kconfig.msc @@ -0,0 +1,26 @@ +# Copyright (c) 2022 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig MODULE_TINYUSB_CLASS_MSC + bool "Mass Storage Class (MSC)" + +if MODULE_TINYUSB_CLASS_MSC && MODULE_TINYUSB_DEVICE + +config TUSBD_MSC_NUMOF + int + default 1 + +config TUSBD_MSC_EP_SIZE + int "MSC endpoint size [byte]" + default 512 + +config TUSBD_MSC_STRING + string "MSC descriptor string" + depends on TUSBD_MSC_NUMOF > 0 + default "TinyUSB MSC" + +endif