#pragma once // The Elecrow CrowPanel 7.0" wires its GT911 touch I2C to GPIO19 and GPIO20, the ESP32-S3's USB D- and D+. The ROM // leaves the USB_SERIAL_JTAG PHY on those pads, and ESP-IDF's I2C driver cannot take them back: the bus reads as // "I2C software timeout" and the touch never answers (esphome/esphome#15356, ESPHome 2026.3+). This runs before any // ESPHome component (a static constructor at priority 101): the PHY lets the pads go, and both become plain GPIOs // with their pull-ups, as the I2C driver expects to find them. The board's USB-C port is a CH340 on UART0, so nothing // is lost. // // ESPHome includes every header of the component in every build, so the code is behind a flag only the Elecrow's board // file sets (`-DESP_SCREENS_FREE_USB_PADS=1`, packages/boards/elecrow-crowpanel7.yaml): the CYD has no such peripheral, // and the Guition, an ESP32-S3 too, keeps its USB. #if defined(ESP_SCREENS_FREE_USB_PADS) && ESP_SCREENS_FREE_USB_PADS #include "hal/usb_serial_jtag_ll.h" #include "soc/io_mux_reg.h" #include "soc/usb_serial_jtag_reg.h" namespace elecrow { static __attribute__((constructor(101))) void release_usb_pads() { usb_serial_jtag_ll_phy_enable_pad(false); CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE); CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP); for (uint32_t reg : {IO_MUX_GPIO19_REG, IO_MUX_GPIO20_REG}) { PIN_FUNC_SELECT(reg, PIN_FUNC_GPIO); PIN_INPUT_ENABLE(reg); REG_SET_BIT(reg, FUN_PU); REG_CLR_BIT(reg, FUN_PD); } } } // namespace elecrow #endif