From 3ecdcf556e68c127598347fb27bc06c190454d69 Mon Sep 17 00:00:00 2001 From: halyssonJr Date: Thu, 19 Jun 2025 17:15:34 -0300 Subject: [PATCH] add lcd suport --- .../xtensa/esp32s3/esp32s3-8048S043/Kconfig | 7 ++ .../esp32s3-8048S043/configs/lcd/defconfig | 90 ++++++++++++++++ .../esp32s3/esp32s3-8048S043/src/Make.defs | 4 + .../esp32s3-8048S043/src/esp32s3-8048S043.h | 26 ++++- .../esp32s3-8048S043/src/esp32s3_bringup.c | 8 ++ .../esp32s3-8048S043/src/esp32s3_lcd.c | 101 ++++++++++++++++++ 6 files changed, 233 insertions(+), 3 deletions(-) create mode 100644 boards/xtensa/esp32s3/esp32s3-8048S043/configs/lcd/defconfig create mode 100644 boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_lcd.c diff --git a/boards/xtensa/esp32s3/esp32s3-8048S043/Kconfig b/boards/xtensa/esp32s3/esp32s3-8048S043/Kconfig index c4319bfc56f..b74da2e1687 100644 --- a/boards/xtensa/esp32s3/esp32s3-8048S043/Kconfig +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/Kconfig @@ -5,6 +5,13 @@ if ARCH_BOARD_ESP32S3_8048S043 +config ESP32S3_BOARD_LCD + bool "Enable Board LCD" + default n + depends on ESP32S3_LCD + ---help--- + Enable board LCD support. + config ESP32S3_BOARD_TOUCHSCREEN bool "Enable Board Touchscreen" default n diff --git a/boards/xtensa/esp32s3/esp32s3-8048S043/configs/lcd/defconfig b/boards/xtensa/esp32s3/esp32s3-8048S043/configs/lcd/defconfig new file mode 100644 index 00000000000..b57872857c6 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/configs/lcd/defconfig @@ -0,0 +1,90 @@ +# +# 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_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-8048S043" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_8048S043=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N4=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_BOARD_LCD=y +CONFIG_ESP32S3_DMA=y +CONFIG_ESP32S3_FLASH_FREQ_80M=y +CONFIG_ESP32S3_FLASH_MODE_QIO=y +CONFIG_ESP32S3_LCD=y +CONFIG_ESP32S3_LCD_CLOCK_MHZ=18 +CONFIG_ESP32S3_LCD_DATA0_PIN=8 +CONFIG_ESP32S3_LCD_DATA10_PIN=4 +CONFIG_ESP32S3_LCD_DATA11_PIN=45 +CONFIG_ESP32S3_LCD_DATA12_PIN=48 +CONFIG_ESP32S3_LCD_DATA13_PIN=47 +CONFIG_ESP32S3_LCD_DATA14_PIN=21 +CONFIG_ESP32S3_LCD_DATA15_PIN=14 +CONFIG_ESP32S3_LCD_DATA1_PIN=3 +CONFIG_ESP32S3_LCD_DATA2_PIN=46 +CONFIG_ESP32S3_LCD_DATA3_PIN=9 +CONFIG_ESP32S3_LCD_DATA4_PIN=1 +CONFIG_ESP32S3_LCD_DATA5_PIN=5 +CONFIG_ESP32S3_LCD_DATA6_PIN=6 +CONFIG_ESP32S3_LCD_DATA7_PIN=7 +CONFIG_ESP32S3_LCD_DATA8_PIN=15 +CONFIG_ESP32S3_LCD_DATA9_PIN=16 +CONFIG_ESP32S3_LCD_HBACKPORCH=16 +CONFIG_ESP32S3_LCD_HE_PIN=40 +CONFIG_ESP32S3_LCD_HFRONTPORCH=20 +CONFIG_ESP32S3_LCD_HPULSEWIDTH=30 +CONFIG_ESP32S3_LCD_HRES=800 +CONFIG_ESP32S3_LCD_HSYNC_PIN=39 +CONFIG_ESP32S3_LCD_PCLK_PIN=42 +CONFIG_ESP32S3_LCD_REGDEBUG=y +CONFIG_ESP32S3_LCD_VBACKPORCH=10 +CONFIG_ESP32S3_LCD_VFRONTPORCH=22 +CONFIG_ESP32S3_LCD_VSYNC_PIN=41 +CONFIG_ESP32S3_PSRAM_8M=y +CONFIG_ESP32S3_SPEED_UP_ISR=y +CONFIG_ESP32S3_SPIRAM=y +CONFIG_ESP32S3_SPIRAM_MODE_OCT=y +CONFIG_ESP32S3_SPIRAM_SPEED_80M=y +CONFIG_ESP32S3_UART0=y +CONFIG_EXAMPLES_FB=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LINE_MAX=64 +CONFIG_MM_REGIONS=2 +CONFIG_NDEBUG=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +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_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/esp32s3/esp32s3-8048S043/src/Make.defs b/boards/xtensa/esp32s3/esp32s3-8048S043/src/Make.defs index bfc8c015b12..2a6a16151c2 100644 --- a/boards/xtensa/esp32s3/esp32s3-8048S043/src/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/src/Make.defs @@ -41,6 +41,10 @@ ifeq ($(CONFIG_DEV_GPIO),y) CSRCS += esp32s3_gpio.c endif +ifeq ($(CONFIG_ESP32S3_BOARD_LCD),y) +CSRCS += esp32s3_lcd.c +endif + ifeq ($(CONFIG_ESP32S3_BOARD_TOUCHSCREEN),y) CSRCS += esp32s3_board_touchsceen.c endif diff --git a/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3-8048S043.h b/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3-8048S043.h index bdef352e009..43364f0833e 100644 --- a/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3-8048S043.h +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3-8048S043.h @@ -44,9 +44,11 @@ * SDA: 19 */ -#define TOUCHSCEEN_ADDR (0x5D) -#define TOUCHSCEEN_CLOCK (400 * 1000) -#define TOUCHSCEEN_INT (-1) +#define TOUCHSCEEN_ADDR (0x5D) +#define TOUCHSCEEN_CLOCK (400 * 1000) +#define TOUCHSCEEN_INT (-1) + +#define ESP32S3_DISPLAY_BCKL (2) /* BOOT Button */ @@ -144,5 +146,23 @@ int board_i2c_init(void); int board_touchscreen_initialize(void); #endif +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize LCD. + * + * Input Parameters: + * None. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_BOARD_LCD +int board_lcd_initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_8048S043_SRC_ESP32S3_8048S043_H */ \ No newline at end of file diff --git a/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_bringup.c index 6aa63bb405f..e19570155b7 100644 --- a/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_bringup.c @@ -255,6 +255,14 @@ int esp32s3_bringup(void) } #endif +#ifdef CONFIG_ESP32S3_BOARD_LCD + ret = board_lcd_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize the LCD\n"); + } +#endif + /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. diff --git a/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_lcd.c b/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_lcd.c new file mode 100644 index 00000000000..7c378fd5af8 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_lcd.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-8048S043/src/esp32s3_lcd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "esp32s3_gpio.h" +#include "esp32s3-8048S043.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * External Functions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize LCD. + * + * Input Parameters: + * None. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + int ret; + + esp32s3_configgpio(ESP32S3_DISPLAY_BCKL, OUTPUT); + esp32s3_gpiowrite(ESP32S3_DISPLAY_BCKL, true); + +#ifdef CONFIG_VIDEO_FB + /* Initialize and register the framebuffer driver */ + + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); + return ret; + } +#else + UNUSED(ret); +#endif + + return 0; +}