You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/26 03:59:04 UTC

[nuttx] 02/02: boards/esp32-wrover-kit: Fix GPIO conflicts

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/nuttx.git

commit 83a4b45dd4c7f9e510812062df708429c4ae8628
Author: SuGliger <rp...@gmail.com>
AuthorDate: Fri Nov 25 15:04:17 2022 -0300

    boards/esp32-wrover-kit: Fix GPIO conflicts
---
 .../xtensa/esp32/esp32-wrover-kit/include/board.h  | 30 +++++++++++++++++++---
 .../esp32/esp32-wrover-kit/src/esp32_userleds.c    | 21 +++++++++++++++
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/boards/xtensa/esp32/esp32-wrover-kit/include/board.h b/boards/xtensa/esp32/esp32-wrover-kit/include/board.h
index bfcdf4b461..3b0449a05a 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/include/board.h
+++ b/boards/xtensa/esp32/esp32-wrover-kit/include/board.h
@@ -53,11 +53,10 @@
 #define BOARD_LED1        0
 #define BOARD_LED2        1
 #define BOARD_LED3        2
-#define BOARD_NLEDS       3
 
-#define BOARD_LED_RED     BOARD_LED1
-#define BOARD_LED_GREEN   BOARD_LED2
-#define BOARD_LED_BLUE    BOARD_LED3
+#define BOARD_LED_RED     BOARD_LED1    /* GPIO 0 */
+#define BOARD_LED_GREEN   BOARD_LED2    /* GPIO 2 */
+#define BOARD_LED_BLUE    BOARD_LED3    /* GPIO 4 */
 
 /* LED bits for use with autoleds */
 
@@ -65,6 +64,29 @@
 #define BOARD_LED2_BIT    (1 << BOARD_LED2)
 #define BOARD_LED3_BIT    (1 << BOARD_LED3)
 
+/* GPIO 2 is used by MMCSD driver as MISO, therefore, it can't be used as
+ * USER LED
+ */
+#ifdef CONFIG_MMCSD
+
+/* GPIO 0 is used by BUTTONS, it can't be used as USER LED */
+#ifdef CONFIG_INPUT_BUTTONS
+#  define BOARD_NLEDS       1
+#else
+#  define BOARD_NLEDS       2
+#endif
+
+#else  /* MMCSD */
+
+/* GPIO 0 is used by BUTTONS, it can't be used as USER LED */
+#ifdef CONFIG_INPUT_BUTTONS
+#  define BOARD_NLEDS       2
+#else
+#  define BOARD_NLEDS       3
+#endif
+
+#endif
+
 /* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 3 LEDs on
  * board the ESP-WROVER-KIT.  The following definitions describe how
  * NuttX controls the LEDs:
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_userleds.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_userleds.c
index d0b9c58974..ad2fab5ed8 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_userleds.c
+++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_userleds.c
@@ -42,7 +42,28 @@
 
 static const uint32_t g_ledcfg[BOARD_NLEDS] =
 {
+  /* GPIO 2 is used by MMCSD driver as MISO, therefore, it can't be used as
+   * USER LED
+   */
+#ifdef CONFIG_MMCSD
+
+  /* GPIO 0 is used by BUTTONS, it can't be used as USER LED */
+#ifdef CONFIG_INPUT_BUTTONS
+  GPIO_LED3
+#else
+  GPIO_LED1, GPIO_LED3
+#endif
+
+#else  /* MMCSD */
+
+  /* GPIO 0 is used by BUTTONS, it can't be used as USER LED */
+#ifdef CONFIG_INPUT_BUTTONS
+  GPIO_LED2, GPIO_LED3
+#else
   GPIO_LED1, GPIO_LED2, GPIO_LED3
+#endif
+
+#endif
 };
 
 /****************************************************************************