ESP32S3 configuring gpio pin 19 or 20 ( USB_D+/- ) for any purposes

This commit is contained in:
Omar 2024-04-06 03:56:07 +06:00 committed by Xiang Xiao
parent b864522b65
commit 4c744f1c0e

View File

@ -41,6 +41,7 @@
#include "esp32s3_irq.h" #include "esp32s3_irq.h"
#include "hardware/esp32s3_gpio.h" #include "hardware/esp32s3_gpio.h"
#include "hardware/esp32s3_iomux.h" #include "hardware/esp32s3_iomux.h"
#include "hardware/esp32s3_usb_serial_jtag.h"
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@ -207,6 +208,17 @@ int esp32s3_configgpio(uint32_t pin, gpio_pinattr_t attr)
func = 0; func = 0;
cntrl = 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 */ /* Handle input pins */
if ((attr & INPUT) != 0) if ((attr & INPUT) != 0)