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
The following commit(s) were added to refs/heads/master by this push:
new e1274d1c42 fix backlight GPIO, add backlight control, and add LVGL
defconfig
e1274d1c42 is described below
commit e1274d1c4212dddecc213c75ed5613eef7b3dfd6
Author: halyssonJr <[email protected]>
AuthorDate: Tue Nov 7 10:23:40 2023 -0300
fix backlight GPIO, add backlight control, and add LVGL defconfig
---
.../xtensa/esp32/common/include/esp32_backlight.h | 83 ++++++++++++++++++++++
boards/xtensa/esp32/common/src/Make.defs | 4 ++
boards/xtensa/esp32/common/src/esp32_backlight.c | 83 ++++++++++++++++++++++
.../esp32/esp32-2432S028/configs/lvgl/defconfig | 64 +++++++++++++++++
boards/xtensa/esp32/esp32-2432S028/include/board.h | 3 +-
.../esp32/esp32-2432S028/src/esp32_bringup.c | 7 ++
6 files changed, 243 insertions(+), 1 deletion(-)
diff --git a/boards/xtensa/esp32/common/include/esp32_backlight.h
b/boards/xtensa/esp32/common/include/esp32_backlight.h
new file mode 100644
index 0000000000..3f672f57c0
--- /dev/null
+++ b/boards/xtensa/esp32/common/include/esp32_backlight.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/include/esp32_backlight.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_BACKLIGHT_H
+#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_BACKLIGHT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp32_set_backlight
+ *
+ * Description:
+ * Configure the backlight gpio and set the brightness level.
+ *
+ * Input Parameters:
+ * level - select the brightness level
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int esp32_set_backlight(uint8_t level);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_BACKLIGHT_H */
\ No newline at end of file
diff --git a/boards/xtensa/esp32/common/src/Make.defs
b/boards/xtensa/esp32/common/src/Make.defs
index 7c3e370022..946c0e28b9 100644
--- a/boards/xtensa/esp32/common/src/Make.defs
+++ b/boards/xtensa/esp32/common/src/Make.defs
@@ -112,6 +112,10 @@ ifeq ($(CONFIG_LCD_BACKPACK),y)
CSRCS += esp32_lcd_backpack.c
endif
+ifeq ($(CONFIG_LCD_DEV),y)
+ CSRCS += esp32_backlight.c
+endif
+
ifeq ($(CONFIG_LCD_ILI9341),y)
CSRCS += esp32_ili9341.c
endif
diff --git a/boards/xtensa/esp32/common/src/esp32_backlight.c
b/boards/xtensa/esp32/common/src/esp32_backlight.c
new file mode 100644
index 0000000000..b0fdcc96ba
--- /dev/null
+++ b/boards/xtensa/esp32/common/src/esp32_backlight.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/esp32_backlight.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <arch/board/board.h>
+
+#include "esp32_gpio.h"
+#include "esp32_backlight.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+#define HAVE_BACKLIGHT 1
+
+#if !defined(DISPLAY_BCKL)
+ #undef HAVE_BACKLIGHT
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp32_set_backlight
+ *
+ * Description:
+ * Configure the backlight gpio and set the brightness level.
+ *
+ * Input Parameters:
+ * level - select the brightness level
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int esp32_set_backlight(uint8_t level)
+{
+ #ifdef HAVE_BACKLIGHT
+ esp32_configgpio(DISPLAY_BCKL, OUTPUT);
+
+ /* TODO: use PWM to set the display brightness */
+
+ if (level == 0)
+ {
+ esp32_gpiowrite(DISPLAY_BCKL, false);
+ }
+ else
+ {
+ /* Set full brightness */
+
+ esp32_gpiowrite(DISPLAY_BCKL, true);
+ }
+ #endif
+
+ return OK;
+}
diff --git a/boards/xtensa/esp32/esp32-2432S028/configs/lvgl/defconfig
b/boards/xtensa/esp32/esp32-2432S028/configs/lvgl/defconfig
new file mode 100644
index 0000000000..6c422cf967
--- /dev/null
+++ b/boards/xtensa/esp32/esp32-2432S028/configs/lvgl/defconfig
@@ -0,0 +1,64 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that
includes your
+# modifications.
+#
+# CONFIG_ESP32_SPI2_DMA is not set
+# CONFIG_ESP32_SPI_SWCS is not set
+# CONFIG_LV_BUILD_EXAMPLES is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="xtensa"
+CONFIG_ARCH_BOARD="esp32-2432S028"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32_2432S028=y
+CONFIG_ARCH_CHIP="esp32"
+CONFIG_ARCH_CHIP_ESP32=y
+CONFIG_ARCH_CHIP_ESP32WROVER=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARCH_XTENSA=y
+CONFIG_BOARD_LOOPSPERMSEC=16717
+CONFIG_BUILTIN=y
+CONFIG_ESP32_SPI2=y
+CONFIG_ESP32_UART0=y
+CONFIG_EXAMPLES_LVGLDEMO=y
+CONFIG_FS_PROCFS=y
+CONFIG_GRAPHICS_LVGL=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_IDLETHREAD_STACKSIZE=3072
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LCD=y
+CONFIG_LCD_DEV=y
+CONFIG_LCD_ILI9341=y
+CONFIG_LCD_ILI9341_IFACE0=y
+CONFIG_LV_COLOR_16_SWAP=y
+CONFIG_LV_DEMO_WIDGETS_SLIDESHOW=y
+CONFIG_LV_MEM_CUSTOM=y
+CONFIG_LV_PORT_LCDDEV_DOUBLE_BUFFER=y
+CONFIG_LV_PORT_USE_LCDDEV=y
+CONFIG_LV_TICK_CUSTOM=y
+CONFIG_LV_TICK_CUSTOM_INCLUDE="port/lv_port_tick.h"
+CONFIG_LV_USE_DEMO_WIDGETS=y
+CONFIG_LV_USE_LOG=y
+CONFIG_MM_REGIONS=3
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=114688
+CONFIG_RAM_START=0x20000000
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_SPI_CMDDATA=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_SYSLOG_BUFFER=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/xtensa/esp32/esp32-2432S028/include/board.h
b/boards/xtensa/esp32/esp32-2432S028/include/board.h
index 0abc60e250..9ae014b1f0 100644
--- a/boards/xtensa/esp32/esp32-2432S028/include/board.h
+++ b/boards/xtensa/esp32/esp32-2432S028/include/board.h
@@ -43,8 +43,9 @@
#define DISPLAY_SPI 2
#define DISPLAY_DC 2
-#define DISPLAY_RST 12
+#define DISPLAY_RST -1 /* Reset pin is connected to on EN pin */
#define DISPLAY_BCKL 21
+#define DISPLAY_BCKL_LEVEL 1 /* Logic level to turn on the backlight */
/* GPIO pins used by the GPIO Subsystem */
diff --git a/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c
b/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c
index 523daf4ddf..fb5ffc1179 100644
--- a/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c
@@ -71,6 +71,7 @@
#ifdef CONFIG_LCD_DEV
# include <nuttx/board.h>
# include <nuttx/lcd/lcd_dev.h>
+# include "esp32_backlight.h"
#endif
#include "esp32-2432S028.h"
@@ -335,6 +336,12 @@ int esp32_bringup(void)
syslog(LOG_ERR, "ERROR: board_lcd_initialize() failed: %d\n", ret);
}
+ ret = esp32_set_backlight(DISPLAY_BCKL_LEVEL);
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: esp32_set_backlight() failed: %d\n", ret);
+ }
+
ret = lcddev_register(0);
if (ret < 0)
{