This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b8c33e5 esp32c3: Fix GPIO Output on pins 18 and 19 USB/JTAG
b8c33e5 is described below
commit b8c33e585eb299359649b0cf40917326782a450f
Author: Alan C. Assis <[email protected]>
AuthorDate: Tue Nov 9 11:17:38 2021 -0300
esp32c3: Fix GPIO Output on pins 18 and 19 USB/JTAG
---
arch/risc-v/src/esp32c3/esp32c3_gpio.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/risc-v/src/esp32c3/esp32c3_gpio.c
b/arch/risc-v/src/esp32c3/esp32c3_gpio.c
index 920a466..e2200a4 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_gpio.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_gpio.c
@@ -38,10 +38,18 @@
#include "esp32c3_irq.h"
#include "hardware/esp32c3_iomux.h"
#include "hardware/esp32c3_gpio.h"
+#include "hardware/esp32c3_usb_serial_jtag.h"
#include "esp32c3_gpio.h"
/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define USB_JTAG_DM 18
+#define USB_JTAG_DP 19
+
+/****************************************************************************
* Private Data
****************************************************************************/
@@ -128,6 +136,18 @@ int esp32c3_configgpio(int pin, gpio_pinattr_t attr)
func = 0;
cntrl = 0;
+ /* If pin 18 or 19 then disable the USB/JTAG function and pull-up */
+
+ if ((pin == USB_JTAG_DM) || (pin == USB_JTAG_DP))
+ {
+ 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)