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: add common USB descriptors implementation #18835

Merged
merged 4 commits into from
Nov 9, 2022
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
43 changes: 35 additions & 8 deletions pkg/tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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)"
Expand All @@ -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
32 changes: 32 additions & 0 deletions pkg/tinyusb/Kconfig.cdc
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions pkg/tinyusb/Kconfig.hid
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions pkg/tinyusb/Kconfig.msc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions pkg/tinyusb/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ else ifeq (stm32,$(CPU))
endif

# other module dependencies
USEMODULE += fmt
USEMODULE += luid
USEMODULE += periph_usbdev_clk
USEMODULE += sema
USEMODULE += ztimer_msec
Loading