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: fix USB speed selection for STM32 boards with HS PHY #18926

Merged
merged 3 commits into from
Nov 18, 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
14 changes: 13 additions & 1 deletion cpu/stm32/include/tinyusb_hw_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,24 @@ extern "C" {
#define TINYUSB_TUH_RHPORT 1
#endif

/*
* Only if the module `periph_usbdev_hs_utmi` or `periph_usbdev_hs_ulpi` is
* enabled for the HS port, a HS PHY is used and OPT_MODE_HIGH_SPEED must be
* set. Otherwise, the built-in on-chip FS PHY is used and
* OPT_MODE_DEFAULT_SPEED should be set so tinyUSB can select the correct speed.
*/
#if (MODULE_PERIPH_USBDEV_HS_UTMI || MODULE_PERIPH_USBDEV_HS_ULPI)
#define TINYUSB_OPT_SPEED OPT_MODE_HIGH_SPEED
#else
#define TINYUSB_OPT_SPEED OPT_MODE_DEFAULT_SPEED
#endif

/*
* Since tinyUSB does not support host mode for STM32 MCUs yet, only
* OPT_MODE_DEVICE is enabled for the port. Once tinyUSB supports the host mode,
* OPT_MODE_HOST could be added to CFG_TUSB_RHPORT1_MODE
*/
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | TINYUSB_OPT_SPEED)

#else

Expand Down
4 changes: 0 additions & 4 deletions pkg/tinyusb/contrib/include/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,6 @@
*/
#define CFG_TUD_ENABLED MODULE_TINYUSB_DEVICE

#ifndef CFG_TUD_MAX_SPEED
#define CFG_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
#endif

#ifndef CFG_TUD_ENDPOINT0_SIZE
#define CFG_TUD_ENDPOINT0_SIZE CONFIG_TUSBD_EP0_SIZE
#endif
Expand Down
2 changes: 1 addition & 1 deletion pkg/tinyusb/hw/hw_stm32_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static int tinyusb_hw_init_dev(const dwc2_usb_otg_fshs_config_t *conf)
global_regs->GCCFG |= USB_OTG_GCCFG_PHYHSEN;

/* determine the PLL input clock of the USB HS PHY from HSE clock */
switch (CLOCK_HSE) {
switch (CONFIG_CLOCK_HSE) {
case 12000000:
USB_HS_PHYC->USB_HS_PHYC_PLL |= USB_HS_PHYC_PLL1_PLLSEL_12MHZ;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/pkg_tflite-micro/Makefile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ BOARD_INSUFFICIENT_MEMORY := \
stk3600 \
stm32f030f4-demo \
stm32f0discovery \
stm32f3discovery \
stm32f7508-dk \
stm32g0316-disco \
stm32l0538-disco \
Expand Down