From 83a4b45dd4c7f9e510812062df708429c4ae8628 Mon Sep 17 00:00:00 2001 From: SuGliger Date: Fri, 25 Nov 2022 15:04:17 -0300 Subject: [PATCH] boards/esp32-wrover-kit: Fix GPIO conflicts --- .../esp32/esp32-wrover-kit/include/board.h | 30 ++++++++++++++++--- .../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 }; /****************************************************************************