From ed585cfc2225b6526ef993eebc8b1fff16276419 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Wed, 30 Nov 2022 20:54:40 +0100 Subject: [PATCH 1/5] pkg/tinyusb: fix compilation with NDEBUG defined --- pkg/tinyusb/contrib/include/tusb_os_custom.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/tinyusb/contrib/include/tusb_os_custom.h b/pkg/tinyusb/contrib/include/tusb_os_custom.h index 930170aade..901dcac784 100644 --- a/pkg/tinyusb/contrib/include/tusb_os_custom.h +++ b/pkg/tinyusb/contrib/include/tusb_os_custom.h @@ -110,6 +110,7 @@ static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) return mutex_lock_cancelable(&_mc) == 0; #else + (void)msec; assert(msec == OSAL_TIMEOUT_WAIT_FOREVER); mutex_lock(mutex_hdl); return true; From b97da1bfdee551e728540c48cdc7123865125a26 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sat, 3 Dec 2022 12:05:26 +0100 Subject: [PATCH 2/5] pkg/tinyusb: use RIOT internal USB_VID/USB_PID --- pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c | 2 ++ pkg/tinyusb/contrib/tinyusb_descriptors.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c b/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c index 00c75404ce..a77bbecf71 100644 --- a/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c +++ b/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c @@ -20,6 +20,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include diff --git a/pkg/tinyusb/contrib/tinyusb_descriptors.c b/pkg/tinyusb/contrib/tinyusb_descriptors.c index d35c5471da..76f65f1674 100644 --- a/pkg/tinyusb/contrib/tinyusb_descriptors.c +++ b/pkg/tinyusb/contrib/tinyusb_descriptors.c @@ -23,6 +23,8 @@ * THE SOFTWARE. */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include "fmt.h" #include "luid.h" #include "tusb.h" From 4b328203d25f3abac9eb0f61d7ff3e837f6d5fed Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sat, 3 Dec 2022 10:56:34 +0100 Subject: [PATCH 3/5] tests/pkg_tinyusb_cdc_msc: cleanup app.config.test Modules `tinyusb_common` and `tinyusb_device` are enabled automatically when package `tinyusb` is used. There is no need to enable them manually. --- tests/pkg_tinyusb_cdc_msc/app.config.test | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/pkg_tinyusb_cdc_msc/app.config.test b/tests/pkg_tinyusb_cdc_msc/app.config.test index efd8b538ab..e005a5990d 100644 --- a/tests/pkg_tinyusb_cdc_msc/app.config.test +++ b/tests/pkg_tinyusb_cdc_msc/app.config.test @@ -1,5 +1,3 @@ CONFIG_PACKAGE_TINYUSB=y CONFIG_MODULE_TINYUSB_CLASS_CDC=y CONFIG_MODULE_TINYUSB_CLASS_MSC=y -CONFIG_MODULE_TINYUSB_COMMON=y -CONFIG_MODULE_TINYUSB_DEVICE=y From 6aa267c4b57a10ed59384d77e913f3757bca71f5 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 4 Dec 2022 16:55:16 +0100 Subject: [PATCH 4/5] pkg/tinyusb/cdc_acm_stdio: support usb_board_reset --- pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c b/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c index a77bbecf71..fa3775ea8f 100644 --- a/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c +++ b/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c @@ -34,6 +34,7 @@ #ifdef MODULE_USB_BOARD_RESET #include "usb_board_reset_internal.h" +#include "class/cdc/cdc.h" #endif static mutex_t data_lock = MUTEX_INIT_LOCKED; @@ -80,3 +81,21 @@ void tud_cdc_rx_cb(uint8_t itf) mutex_unlock(&data_lock); } + +#ifdef MODULE_USB_BOARD_RESET + +void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding) +{ + (void)itf; + assert(p_line_coding != NULL); + + /* The first parameter is the USBUS CDC ACM device, but this is + * not used in `usb_board_reset_coding_cb`. Therefore we can simply + * reuse this callback function in tinyUSB without any problems. */ + usb_board_reset_coding_cb(NULL, + p_line_coding->bit_rate, + p_line_coding->data_bits, + p_line_coding->parity, + p_line_coding->stop_bits); +} +#endif From d390b6c7f6d79613f7967e3434585a310c0f9119 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 4 Dec 2022 16:56:19 +0100 Subject: [PATCH 5/5] sys/usb_board_reset: add stdio_tinyusb_cdc_acm support --- sys/usb_board_reset/Kconfig | 2 +- sys/usb_board_reset/usb_board_reset.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/usb_board_reset/Kconfig b/sys/usb_board_reset/Kconfig index 9962368c0e..a3de925222 100644 --- a/sys/usb_board_reset/Kconfig +++ b/sys/usb_board_reset/Kconfig @@ -8,4 +8,4 @@ config MODULE_USB_BOARD_RESET bool "Trigger a board reset via USB CDC ACM" depends on TEST_KCONFIG - depends on MODULE_USBUS_CDC_ACM + depends on MODULE_USBUS_CDC_ACM || MODULE_STDIO_TINYUSB_CDC_ACM diff --git a/sys/usb_board_reset/usb_board_reset.c b/sys/usb_board_reset/usb_board_reset.c index 44e4af4dec..8d39f5cb30 100644 --- a/sys/usb_board_reset/usb_board_reset.c +++ b/sys/usb_board_reset/usb_board_reset.c @@ -36,7 +36,12 @@ int usb_board_reset_coding_cb(usbus_cdcacm_device_t *cdcacm, uint32_t baud, uint8_t bits, uint8_t parity, uint8_t stop) { + /* Note: This function is also used by tinyUSB if module `usb_board_reset` + * is used. In this case no USBUS CDC ACM device is defined and parameter + * `cdcacm` is NULL. Please keep this in mind if `cdcacm` is to be used + * in future versions. */ (void)cdcacm; + (void)bits; (void)parity; (void)stop;