From bc335009d9653f300ac8c1228088052d5c25a6ac Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Tue, 2 Mar 2021 11:08:32 -0300 Subject: [PATCH] risc-v/esp32c3: Allow pin to be configured as Input and Output simultaneously --- arch/risc-v/src/esp32c3/esp32c3_gpio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/risc-v/src/esp32c3/esp32c3_gpio.c b/arch/risc-v/src/esp32c3/esp32c3_gpio.c index 36e923dffc..3b9bdba034 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_gpio.c +++ b/arch/risc-v/src/esp32c3/esp32c3_gpio.c @@ -134,11 +134,15 @@ int esp32c3_configgpio(int pin, gpio_pinattr_t attr) { putreg32((1ul << pin), GPIO_ENABLE_W1TC_REG); + /* Input enable */ + + func |= FUN_IE; + if ((attr & PULLUP) != 0) { func |= FUN_PU; } - else if (attr & PULLDOWN) + else if ((attr & PULLDOWN) != 0) { func |= FUN_PD; } @@ -146,7 +150,7 @@ int esp32c3_configgpio(int pin, gpio_pinattr_t attr) /* Handle output pins */ - else if ((attr & OUTPUT) != 0) + if ((attr & OUTPUT) != 0) { putreg32((1ul << pin), GPIO_ENABLE_W1TS_REG); } @@ -155,10 +159,6 @@ int esp32c3_configgpio(int pin, gpio_pinattr_t attr) func |= (uint32_t)(2ul << FUN_DRV_S); - /* Input enable... Required for output as well? */ - - func |= FUN_IE; - /* Select the pad's function. If no function was given, consider it a * normal input or output (i.e. function3). */