Skip to content
Open
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ elseif(${target} STREQUAL "esp32s2")
elseif(${target} STREQUAL "esp32p4")
set(tusb_mcu "OPT_MCU_ESP32P4")
set(tusb_family "esp32px")
elseif(${target} STREQUAL "esp32h4")
set(tusb_mcu "OPT_MCU_ESP32H4")
set(tusb_family "esp32sx")
endif()

set(compile_options
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ Supported CPUs
| Espressif | S2, S3 | ✔ | ✔ | ✖ | dwc2 or esp32sx | |
| ESP32 +-----------------------------+--------+------+-----------+------------------------+-------------------+
| | P4 | ✔ | ✔ | ✔ | dwc2 | |
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
| | H4 | ✔ | ✔ | ✖ | dwc2 | |
+--------------+----+------------------------+--------+------+-----------+------------------------+-------------------+
| GigaDevice | GD32VF103 | ✔ | | ✖ | dwc2 | |
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
Expand Down
6 changes: 3 additions & 3 deletions hw/bsp/espressif/boards/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void board_init(void) {
gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
gpio_set_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN_ONLY : GPIO_PULLUP_ONLY);

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4)
usb_init();
#endif

Expand All @@ -103,7 +103,7 @@ void board_init(void) {
#endif
}

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4)

#endif

Expand Down Expand Up @@ -158,7 +158,7 @@ int board_getchar(void) {
// PHY Init
//--------------------------------------------------------------------

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)

#include "esp_private/usb_phy.h"
Expand Down
1 change: 1 addition & 0 deletions idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ targets:
- esp32s2
- esp32s3
- esp32p4
- esp32h4
2 changes: 1 addition & 1 deletion src/common/tusb_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
//--------------------------------------------------------------------+
// Espressif
//--------------------------------------------------------------------+
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4)
#define TUP_USBIP_DWC2
#define TUP_USBIP_DWC2_ESP32
#define TUP_DCD_ENDPOINT_MAX 7 // only 5 TX FIFO for endpoint IN
Expand Down
17 changes: 17 additions & 0 deletions src/portable/synopsys/dwc2/dwc2_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ static const dwc2_controller_t _dwc2_controller[] = {
{ .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 }
};

#elif TU_CHECK_MCU(OPT_MCU_ESP32H4)
// H4's USB_WRAP register block uses "wrap_*" field names. Map them to the
// names used by TinyUSB's DWC2 port to keep the source unchanged.
#define otg_conf wrap_otg_conf
#define pad_pull_override wrap_pad_pull_override
#define dp_pullup wrap_dp_pullup
#define dp_pulldown wrap_dp_pulldown
#define dm_pullup wrap_dm_pullup
#define dm_pulldown wrap_dm_pulldown

#define DWC2_FS_REG_BASE 0x60040000UL
#define DWC2_EP_MAX 7

static const dwc2_controller_t _dwc2_controller[] = {
{ .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_OTG11_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 }
};

#elif TU_CHECK_MCU(OPT_MCU_ESP32P4)
#define DWC2_FS_REG_BASE 0x50040000UL
#define DWC2_HS_REG_BASE 0x50000000UL
Expand Down
1 change: 1 addition & 0 deletions src/tusb_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
#define OPT_MCU_ESP32C2 905 ///< Espressif ESP32-C2
#define OPT_MCU_ESP32H2 906 ///< Espressif ESP32-H2
#define OPT_MCU_ESP32P4 907 ///< Espressif ESP32-P4
#define OPT_MCU_ESP32H4 910 ///< Espressif ESP32-H4, 908, 909 are already used in the upstream
#define TUSB_MCU_VENDOR_ESPRESSIF (CFG_TUSB_MCU >= 900 && CFG_TUSB_MCU < 1000) // check if Espressif MCU
#define TUP_MCU_ESPRESSIF TUSB_MCU_VENDOR_ESPRESSIF // for backward compatibility

Expand Down