Skip to content

Commit

Permalink
refactor(esp_tinyusb): Changed the PHY to periph (as we select the pe…
Browse files Browse the repository at this point in the history
…riph) and added run-time selection option
  • Loading branch information
roma-jam committed Jan 14, 2025
1 parent d9c5e8b commit 14be063
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
25 changes: 18 additions & 7 deletions device/esp_tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@ menu "TinyUSB Stack"
help
Specify verbosity of TinyUSB log output.

choice TINYUSB_RHPORT
config TINYUSB_DYNAMIC_RHPORT_CONFIG
depends on IDF_TARGET_ESP32P4
prompt "TinyUSB PHY"
bool "TinyUSB Peripheral dynamic selection"
default n
help
Allows to select and configure the Peripheral for TinyUSB in run-time.

- Disable to select peripheral via CFG_TUSB_RHPORTx_MODE (legacy way).
- Enable to use run-time port selection via TinyUSB configuration parameter.

choice TINYUSB_RHPORT
depends on !TINYUSB_DYNAMIC_RHPORT_CONFIG
prompt "USB Peripheral"
default TINYUSB_RHPORT_HS
help
Allows set the USB PHY Controller for TinyUSB:
- HS (USB OTG2.0 PHY for HighSpeed)
- FS (USB OTG1.1 PHY for FullSpeed)
Allows set the USB Peripheral Controller for TinyUSB.

- High-speed (USB OTG2.0 Peripheral for High-, Full- and Low-speed)
- Full-speed (USB OTG1.1 Peripheral for Full- and Low-speed)

config TINYUSB_RHPORT_HS
bool "HS"
bool "OTG2.0"
config TINYUSB_RHPORT_FS
bool "FS"
bool "OTG1.1"
endchoice

menu "TinyUSB DCD"
Expand Down
3 changes: 3 additions & 0 deletions device/esp_tinyusb/tinyusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "esp_private/periph_ctrl.h"
#include "esp_private/usb_phy.h"
#include "soc/usb_pins.h"
#include "soc/usb_dwc_cfg.h" // To get awailable OTG interfaces
#include "tinyusb.h"
#include "descriptors_control.h"
#include "tusb.h"
Expand All @@ -32,7 +33,9 @@ esp_err_t tinyusb_driver_install(const tinyusb_config_t *config)
usb_phy_config_t phy_conf = {
.controller = USB_PHY_CTRL_OTG,
.otg_mode = USB_OTG_MODE_DEVICE,
#if OTG20_HSPHY_INTERFACE
.otg_speed = (TUD_OPT_HIGH_SPEED) ? USB_PHY_SPEED_HIGH : USB_PHY_SPEED_FULL,
#endif // OTG20_HSPHY_INTERFACE
};

// External PHY IOs config
Expand Down

0 comments on commit 14be063

Please sign in to comment.