Skip to content

Commit

Permalink
Merge pull request #91 from espressif/feature/esp32p4_fs_phy_config
Browse files Browse the repository at this point in the history
feature(esp_tinyusb): Added config option to select USB OTG1.1 periph on P4
  • Loading branch information
roma-jam authored Jan 17, 2025
2 parents b347dc2 + c219d0c commit ab7db80
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions device/esp_tinyusb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [Unreleased]

- esp_tinyusb: Added possibility to configure NCM Transfer Blocks (NTB) via menuconfig
- esp_tinyusb: Added option to select TinyUSB peripheral on esp32p4 via menuconfig (USB_PHY_SUPPORTS_P4_OTG11 in esp-idf is required)

## 1.6.0

Expand Down
16 changes: 11 additions & 5 deletions device/esp_tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ menu "TinyUSB Stack"
Specify verbosity of TinyUSB log output.

choice TINYUSB_RHPORT
depends on IDF_TARGET_ESP32P4
prompt "TinyUSB PHY"
default TINYUSB_RHPORT_HS
prompt "USB Peripheral"
default TINYUSB_RHPORT_HS if IDF_TARGET_ESP32P4
default TINYUSB_RHPORT_FS
help
Allows set the USB PHY Controller for TinyUSB: HS (USB OTG2.0 PHY for HighSpeed)
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"
depends on IDF_TARGET_ESP32P4
config TINYUSB_RHPORT_FS
bool "OTG1.1"
endchoice

menu "TinyUSB DCD"
Expand Down
9 changes: 8 additions & 1 deletion device/esp_tinyusb/tinyusb.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -32,6 +32,13 @@ 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 (USB_PHY_SUPPORTS_P4_OTG11)
.otg_speed = (TUD_OPT_HIGH_SPEED) ? USB_PHY_SPEED_HIGH : USB_PHY_SPEED_FULL,
#else
#if (CONFIG_IDF_TARGET_ESP32P4 && CONFIG_TINYUSB_RHPORT_FS)
#error "USB PHY for OTG1.1 is not supported, please update your esp-idf."
#endif // IDF_TARGET_ESP32P4 && CONFIG_TINYUSB_RHPORT_FS
#endif // USB_PHY_SUPPORTS_P4_OTG11
};

// External PHY IOs config
Expand Down

0 comments on commit ab7db80

Please sign in to comment.