From 4c744f1c0eb8370e981a533de80d97491166754f Mon Sep 17 00:00:00 2001 From: Omar <omarfaruk.dc@gmail.com> Date: Sat, 6 Apr 2024 03:56:07 +0600 Subject: [PATCH] ESP32S3 configuring gpio pin 19 or 20 ( USB_D+/- ) for any purposes --- arch/xtensa/src/esp32s3/esp32s3_gpio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/xtensa/src/esp32s3/esp32s3_gpio.c b/arch/xtensa/src/esp32s3/esp32s3_gpio.c index d36b951b9f..d89799ac23 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_gpio.c +++ b/arch/xtensa/src/esp32s3/esp32s3_gpio.c @@ -41,6 +41,7 @@ #include "esp32s3_irq.h" #include "hardware/esp32s3_gpio.h" #include "hardware/esp32s3_iomux.h" +#include "hardware/esp32s3_usb_serial_jtag.h" /**************************************************************************** * Pre-processor Definitions @@ -207,6 +208,17 @@ int esp32s3_configgpio(uint32_t pin, gpio_pinattr_t attr) func = 0; cntrl = 0; + /* if pin 19 or 20 disable the USB/JTAG function and pull-up */ + + if (pin == 19 || pin == 20) + { + uint32_t regval; + regval = getreg32(USB_SERIAL_JTAG_CONF0_REG); + regval &= ~(USB_SERIAL_JTAG_USB_PAD_ENABLE | + USB_SERIAL_JTAG_DP_PULLUP); + putreg32(regval, USB_SERIAL_JTAG_CONF0_REG); + } + /* Handle input pins */ if ((attr & INPUT) != 0)