You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/10/07 14:52:18 UTC
[incubator-nuttx] 03/04: arch/xtensa/src/esp32/esp32_gpio.c: When
configuring a pin pad, set the function first, if no function was assigned,
fall back to the GPIO function.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5593683552720bbeec0c6f04830da6295cae6520
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Mon Oct 5 11:31:41 2020 +0100
arch/xtensa/src/esp32/esp32_gpio.c: When configuring a pin pad, set the
function first, if no function was assigned, fall back to the GPIO
function.
Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
arch/xtensa/src/esp32/esp32_gpio.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/xtensa/src/esp32/esp32_gpio.c b/arch/xtensa/src/esp32/esp32_gpio.c
index c881737..af15119 100644
--- a/arch/xtensa/src/esp32/esp32_gpio.c
+++ b/arch/xtensa/src/esp32/esp32_gpio.c
@@ -161,7 +161,6 @@ int esp32_configgpio(int pin, gpio_pinattr_t attr)
uintptr_t regaddr;
uint32_t func;
uint32_t cntrl;
- unsigned int pinmode;
DEBUGASSERT(pin >= 0 && pin <= ESP32_NGPIOS);
@@ -213,14 +212,17 @@ int esp32_configgpio(int pin, gpio_pinattr_t attr)
func |= FUN_IE;
- pinmode = (attr & PINMODE_MASK);
- if (pinmode == INPUT || pinmode == OUTPUT)
+ /* Select the pad's function. If no function was given, consider it a normal
+ * input or output (i.e. function2).
+ */
+
+ if ((attr & FUNCTION) != 0)
{
- func |= (uint32_t)(2 << MCU_SEL_S);
+ func |= (uint32_t)((attr >> FUNCTION_SHIFT) << MCU_SEL_S);
}
- else /* if ((attr & FUNCTION) != 0) */
+ else
{
- func |= (uint32_t)((attr >> FUNCTION_SHIFT) << MCU_SEL_S);
+ func |= (uint32_t)((2 >> FUNCTION_SHIFT) << MCU_SEL_S);
}
if ((attr & OPEN_DRAIN) != 0)