From 4182342112d92898d2b55ef9562c545a9ebf52ac Mon Sep 17 00:00:00 2001 From: "igor.masar" Date: Tue, 16 Sep 2025 12:18:50 +0200 Subject: Add ESP32-H4 as a supported MCU in TinyUSB and wire it into build/runtime: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tusb_option.h: define OPT_MCU_ESP32H4 - tusb_mcu.h: enable DWC2 USBIP for H4 - dcd_dwc2.c: add H4 USB_WRAP field aliases (wrap_* → legacy names) - dwc2_esp32.h: add H4 controller entry (FS base/IRQ, ep caps) - family.c: include H4 in USB init/PHY setup --- src/common/tusb_mcu.h | 2 +- src/portable/synopsys/dwc2/dwc2_esp32.h | 17 +++++++++++++++++ src/tusb_option.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/tusb_mcu.h b/src/common/tusb_mcu.h index 7722ca1e6..b647b2a7f 100644 --- a/src/common/tusb_mcu.h +++ b/src/common/tusb_mcu.h @@ -387,7 +387,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 diff --git a/src/portable/synopsys/dwc2/dwc2_esp32.h b/src/portable/synopsys/dwc2/dwc2_esp32.h index 49b8c54cb..a4e0d1770 100644 --- a/src/portable/synopsys/dwc2/dwc2_esp32.h +++ b/src/portable/synopsys/dwc2/dwc2_esp32.h @@ -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 diff --git a/src/tusb_option.h b/src/tusb_option.h index b2dd5fcb2..fe7e34111 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -131,6 +131,7 @@ #define OPT_MCU_ESP32P4 907 ///< Espressif ESP32-P4 #define OPT_MCU_ESP32C5 908 ///< Espressif ESP32-C5 #define OPT_MCU_ESP32C61 909 ///< Espressif ESP32-C61 +#define OPT_MCU_ESP32H4 910 ///< Espressif ESP32-H4 #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 -- cgit v1.3.1