diff --git a/Documentation/platforms/xtensa/esp32s2/boards/esp32s2-kaluga-1/index.rst b/Documentation/platforms/xtensa/esp32s2/boards/esp32s2-kaluga-1/index.rst index ca3678791e1..d0896b22950 100644 --- a/Documentation/platforms/xtensa/esp32s2/boards/esp32s2-kaluga-1/index.rst +++ b/Documentation/platforms/xtensa/esp32s2/boards/esp32s2-kaluga-1/index.rst @@ -210,6 +210,30 @@ the ``buttons`` application and pressing on any of the available board buttons a Sample = 64 Sample = 0 +lvgl_ili9341 +------------ + +This is a demonstration of the LVGL graphics library running on the NuttX LCD +driver with the ILI9341 display. You can find LVGL here:: + + https://www.lvgl.io/ + https://github.com/lvgl/lvgl + +This configuration uses the LVGL demonstration at `apps/examples/lvgldemo` and +can be executed by running the `lvgldemo` application. + +lvgl_st7789 +----------- + +This is a demonstration of the LVGL graphics library running on the NuttX LCD +driver with the ST7799 display. You can find LVGL here:: + + https://www.lvgl.io/ + https://github.com/lvgl/lvgl + +This configuration uses the LVGL demonstration at `apps/examples/lvgldemo` and +can be executed by running the `lvgldemo` application. + nsh --- diff --git a/boards/xtensa/esp32s2/common/Kconfig b/boards/xtensa/esp32s2/common/Kconfig index 67d129236be..ae760d6949a 100644 --- a/boards/xtensa/esp32s2/common/Kconfig +++ b/boards/xtensa/esp32s2/common/Kconfig @@ -11,3 +11,13 @@ config ESP32S2_MERGE_BINS device. This is only useful when the path to binary files (e.g. bootloader) is provided via the ESPTOOL_BINDIR variable. + +config ESP32S2_LCD_OVERCLOCK + bool "Run LCD at higher clock speed than allowed" + default n + depends on LCD_ILI9341 + ---help--- + The ILI9341 and ST7789 specify that the maximum clock speed for the + SPI interface is 10MHz. However, in practice the driver chips work + fine with a higher clock rate, and using that gives a better + framerate. Select this to try using the out-of-spec clock rate. diff --git a/boards/xtensa/esp32s2/common/src/Make.defs b/boards/xtensa/esp32s2/common/src/Make.defs index e98e8deba0e..27e1ce2200e 100644 --- a/boards/xtensa/esp32s2/common/src/Make.defs +++ b/boards/xtensa/esp32s2/common/src/Make.defs @@ -36,6 +36,14 @@ ifeq ($(CONFIG_AUDIO_CS4344),y) CSRCS += esp32s2_cs4344.c endif +ifeq ($(CONFIG_LCD_ILI9341),y) + CSRCS += esp32s2_ili9341.c +endif + +ifeq ($(CONFIG_LCD_ST7789),y) + CSRCS += esp32s2_st7789.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src) diff --git a/boards/xtensa/esp32s2/common/src/esp32s2_ili9341.c b/boards/xtensa/esp32s2/common/src/esp32s2_ili9341.c new file mode 100644 index 00000000000..d020572b104 --- /dev/null +++ b/boards/xtensa/esp32s2/common/src/esp32s2_ili9341.c @@ -0,0 +1,459 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/common/src/esp32s2_ili9341.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 + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "esp32s2_gpio.h" +#include "esp32s2_spi.h" +#include "hardware/esp32s2_gpio_sigmap.h" + +/**************************************************************************** + * Preprocessor Definitions + ****************************************************************************/ + +/* Check if the following are defined in the board.h */ + +#ifndef GPIO_LCD_RST +# error "GPIO_LCD_RST must be defined in board.h!" +#endif +#ifndef GPIO_LCD_DC +# error "GPIO_LCD_DC must be defined in board.h!" +#endif +#ifndef GPIO_LCD_BCKL +# error "GPIO_LCD_BCKL must be defined in board.h!" +#endif +#ifndef LCD_SPI_PORTNO +# error "LCD_SPI_PORTNO must be defined in board.h!" +#endif + +#ifdef CONFIG_ESP32S2_LCD_OVERCLOCK +# define ILI9341_SPI_MAXFREQUENCY 40*1000*1000 +#else +# define ILI9341_SPI_MAXFREQUENCY 10*1000*1000 +#endif + +#ifndef CONFIG_SPI_CMDDATA +# error "The ILI9341 driver requires CONFIG_SPI_CMDATA in the configuration" +#endif + +/**************************************************************************** + * Private Type Definition + ****************************************************************************/ + +struct ili93414ws_lcd_s +{ + struct ili9341_lcd_s dev; + struct spi_dev_s *spi; +}; + +/**************************************************************************** + * Private Function Protototypes + ****************************************************************************/ + +static void esp32s2_ili93414ws_select(struct ili9341_lcd_s *lcd); +static void esp32s2_ili93414ws_deselect(struct ili9341_lcd_s *lcd); +static int esp32s2_ili93414ws_backlight(struct ili9341_lcd_s *lcd, + int level); +static int esp32s2_ili93414ws_sendcmd(struct ili9341_lcd_s *lcd, + const uint8_t cmd); +static int esp32s2_ili93414ws_sendparam(struct ili9341_lcd_s *lcd, + const uint8_t param); +static int esp32s2_ili93414ws_sendgram(struct ili9341_lcd_s *lcd, + const uint16_t *wd, uint32_t nwords); +static int esp32s2_ili93414ws_recvparam(struct ili9341_lcd_s *lcd, + uint8_t *param); +static int esp32s2_ili93414ws_recvgram(struct ili9341_lcd_s *lcd, + uint16_t *wd, uint32_t nwords); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct ili93414ws_lcd_s g_lcddev; +static struct lcd_dev_s *g_lcd = NULL; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s2_ili93414ws_select + * + * Description: + * Select the SPI, lock and reconfigure if necessary + * + * Input Parameters: + * lcd - Reference to the public driver structure + * + ****************************************************************************/ + +static void esp32s2_ili93414ws_select(struct ili9341_lcd_s *lcd) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + SPI_LOCK(priv->spi, true); + SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true); +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_deselect + * + * Description: + * De-select the SPI + * + * Input Parameters: + * lcd - Reference to the public driver structure + * + ****************************************************************************/ + +static void esp32s2_ili93414ws_deselect(struct ili9341_lcd_s *lcd) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false); + SPI_LOCK(priv->spi, false); +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_backlight + * + * Description: + * Set the backlight level of the connected display. + * NOTE: Currently this function either sets the brightness to the maximum + * level (level > 0) or turns the display off (level == 0). Although + * the ILI9341 chip provides an interface for configuring the + * backlight level via WRITE_DISPLAY_BRIGHTNESS (0x51), it depends on + * the actual circuit of the display device. Usually the backlight + * pins are hardwired to Vcc, making the backlight level setting + * effectless. + * + * Input Parameters: + * lcd - Reference to the public driver structure + * level - Backlight level + * + * Returned Value: + * OK - On Success + * + ****************************************************************************/ + +static int esp32s2_ili93414ws_backlight(struct ili9341_lcd_s *lcd, + int level) +{ + if (level > 0) + { + lcd->sendcmd(lcd, ILI9341_WRITE_CTRL_DISPLAY); + lcd->sendparam(lcd, 0x24); + } + else + { + lcd->sendcmd(lcd, ILI9341_WRITE_CTRL_DISPLAY); + lcd->sendparam(lcd, 0x0); + } + + return OK; +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_sendcmd + * + * Description: + * Send a command to the lcd driver. + * + * Input Parameters: + * lcd - Reference to the ili9341_lcd_s driver structure + * cmd - command to send + * + * Returned Value: + * On success - OK + * + ****************************************************************************/ + +static int esp32s2_ili93414ws_sendcmd(struct ili9341_lcd_s *lcd, + const uint8_t cmd) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + lcdinfo("%02x\n", cmd); + + SPI_SETBITS(priv->spi, 8); + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), true); + SPI_SEND(priv->spi, cmd); + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), false); + + return OK; +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_sendparam + * + * Description: + * Send a parameter to the lcd driver. + * + * Input Parameters: + * lcd - Reference to the ili9341_lcd_s driver structure + * param - Parameter to send + * + * Returned Value: + * OK - On Success + * + ****************************************************************************/ + +static int esp32s2_ili93414ws_sendparam(struct ili9341_lcd_s *lcd, + const uint8_t param) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + lcdinfo("param=%04x\n", param); + + SPI_SETBITS(priv->spi, 8); + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), false); + SPI_SEND(priv->spi, param); + + return OK; +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_sendgram + * + * Description: + * Send a number of pixel words to the lcd driver gram. + * + * Input Parameters: + * lcd - Reference to the ili9341_lcd_s driver structure + * wd - Reference to the words to send + * nwords - Number of words to send + * + * Returned Value: + * OK - On Success + * + ****************************************************************************/ + +static int esp32s2_ili93414ws_sendgram(struct ili9341_lcd_s *lcd, + const uint16_t *wd, uint32_t nwords) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + lcdinfo("lcd:%p, wd=%p, nwords=%" PRIu32 "\n", lcd, wd, nwords); + + SPI_SETBITS(priv->spi, 16); + SPI_SNDBLOCK(priv->spi, wd, nwords); + + return OK; +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_recvparam + * + * Description: + * Receive a parameter from the lcd driver. + * + * Input Parameters: + * lcd - Reference to the ili9341_lcd_s driver structure + * param - Reference to where parameter is received + * + * Returned Value: + * OK - On Success + * + ****************************************************************************/ + +static int esp32s2_ili93414ws_recvparam(struct ili9341_lcd_s *lcd, + uint8_t *param) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + SPI_SETBITS(priv->spi, 8); + + SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), false); + + *param = (uint8_t)(SPI_SEND(priv->spi, (uintptr_t)param) & 0xff); + + return OK; +} + +/**************************************************************************** + * Name: esp32s2_ili93414ws_recvgram + * + * Description: + * Receive pixel words from the lcd driver gram. + * + * Input Parameters: + * lcd - Reference to the public driver structure + * wd - Reference to where the pixel words are received + * nwords - Number of pixel words to receive + * + * Returned Value: + * OK - On Success + * + ****************************************************************************/ + +static int esp32s2_ili93414ws_recvgram(struct ili9341_lcd_s *lcd, + uint16_t *wd, uint32_t nwords) +{ + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; + + lcdinfo("wd=%p, nwords=%" PRIu32 "\n", wd, nwords); + + SPI_SETBITS(priv->spi, 16); + SPI_RECVBLOCK(priv->spi, wd, nwords); + + return OK; +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize the LCD video hardware. The initial state of the LCD is fully + * initialized, display memory cleared, and the LCD ready to use, but with + * the power setting at 0 (full off). + * + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + struct ili93414ws_lcd_s *priv = &g_lcddev; + struct spi_dev_s *spi; + lcdinfo("Initializing LCD\n"); + + if (g_lcd == NULL) + { + spi = esp32s2_spibus_initialize(LCD_SPI_PORTNO); + if (!spi) + { + lcderr("Failed to initialize SPI bus.\n"); + return -ENODEV; + } + + priv->spi = spi; + + /* Initialize non-SPI GPIOs */ + + esp32s2_configgpio(GPIO_LCD_DC, OUTPUT_FUNCTION_3); + esp32s2_gpio_matrix_out(GPIO_LCD_DC, SIG_GPIO_OUT_IDX, 0, 0); + + esp32s2_configgpio(GPIO_LCD_RST, INPUT_FUNCTION_3); + esp32s2_gpio_matrix_out(GPIO_LCD_RST, SIG_GPIO_OUT_IDX, 0, 0); + + esp32s2_configgpio(GPIO_LCD_BCKL, OUTPUT_FUNCTION_3); + esp32s2_gpio_matrix_out(GPIO_LCD_BCKL, SIG_GPIO_OUT_IDX, 0, 0); + + /* Reset ILI9341 */ + + up_mdelay(10); + esp32s2_gpiowrite(GPIO_LCD_RST, false); + up_mdelay(10); + esp32s2_gpiowrite(GPIO_LCD_RST, true); + up_mdelay(50); + + /* Configure SPI */ + + SPI_SETMODE(priv->spi, SPIDEV_MODE0); + SPI_SETBITS(priv->spi, 8); + SPI_HWFEATURES(priv->spi, 0); + SPI_SETFREQUENCY(priv->spi, ILI9341_SPI_MAXFREQUENCY); + + /* Initialize ILI9341 driver with necessary methods */ + + priv->dev.select = esp32s2_ili93414ws_select; + priv->dev.deselect = esp32s2_ili93414ws_deselect; + priv->dev.sendcmd = esp32s2_ili93414ws_sendcmd; + priv->dev.sendparam = esp32s2_ili93414ws_sendparam; + priv->dev.recvparam = esp32s2_ili93414ws_recvparam; + priv->dev.sendgram = esp32s2_ili93414ws_sendgram; + priv->dev.recvgram = esp32s2_ili93414ws_recvgram; + priv->dev.backlight = esp32s2_ili93414ws_backlight; + + g_lcd = ili9341_initialize(&priv->dev, 0); + + if (g_lcd != NULL) + { + /* Turn the LCD on at 100% power */ + + g_lcd->setpower(g_lcd, CONFIG_LCD_MAXPOWER); + } + } + + return OK; +} + +/**************************************************************************** + * Name: board_lcd_getdev + * + * Description: + * Return a reference to the LCD object for the specified LCD. This allows + * support for multiple LCD devices. + * + ****************************************************************************/ + +struct lcd_dev_s *board_lcd_getdev(int lcddev) +{ + if (lcddev == 0) + { + return g_lcd; + } + + return NULL; +} + +/**************************************************************************** + * Name: board_lcd_uninitialize + * + * Description: + * Uninitialize the LCD support. + * + ****************************************************************************/ + +void board_lcd_uninitialize(void) +{ + lcdinfo("Terminating LCD\n"); + + if (g_lcd != NULL) + { + /* Turn the display off */ + + g_lcd->setpower(g_lcd, 0); + + g_lcd = NULL; + } +} diff --git a/boards/xtensa/esp32s2/common/src/esp32s2_st7789.c b/boards/xtensa/esp32s2/common/src/esp32s2_st7789.c new file mode 100644 index 00000000000..019a725577d --- /dev/null +++ b/boards/xtensa/esp32s2/common/src/esp32s2_st7789.c @@ -0,0 +1,146 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/common/src/esp32s2_st7789.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 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "esp32s2_spi.h" +#include "esp32s2_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_SPI_CMDDATA +# error "The ST7789 driver requires CONFIG_SPI_CMDATA in the config" +#endif + +#ifndef CONFIG_ESP32S2_SPI_SWCS +# error "The ST7789 driver requires CONFIG_ESP32S2_SPI_SWCS in the config" +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct spi_dev_s *g_spidev; +static struct lcd_dev_s *g_lcd = NULL; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize the LCD video hardware. The initial state of the LCD is + * fully initialized, display memory cleared, and the LCD ready to use, but + * with the power setting at 0 (full off). + * + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + g_spidev = esp32s2_spibus_initialize(LCD_SPI_PORTNO); + if (!g_spidev) + { + lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO); + return -ENODEV; + } + + /* SPI RX is not used. Same pin is used as LCD Data/Command control */ + + esp32s2_configgpio(GPIO_LCD_DC, OUTPUT); + esp32s2_gpiowrite(GPIO_LCD_DC, true); + + /* Pull LCD_RESET high */ + + esp32s2_configgpio(GPIO_LCD_RST, OUTPUT); + esp32s2_gpiowrite(GPIO_LCD_RST, false); + up_mdelay(1); + esp32s2_gpiowrite(GPIO_LCD_RST, true); + up_mdelay(10); + + /* Set full brightness */ + + esp32s2_configgpio(GPIO_LCD_BCKL, OUTPUT); + esp32s2_gpiowrite(GPIO_LCD_BCKL, true); + + lcdinfo("LCD successfully initialized"); + + return OK; +} + +/**************************************************************************** + * Name: board_lcd_getdev + * + * Description: + * Return a a reference to the LCD object for the specified LCD. This + * allows support for multiple LCD devices. + * + ****************************************************************************/ + +struct lcd_dev_s *board_lcd_getdev(int devno) +{ + g_lcd = st7789_lcdinitialize(g_spidev); + if (g_lcd == NULL) + { + lcderr("ERROR: Failed to bind SPI port %d to LCD %d\n", LCD_SPI_PORTNO, + devno); + + return NULL; + } + + lcdinfo("SPI port %d bound to LCD %d\n", LCD_SPI_PORTNO, devno); + + return g_lcd; +} + +/**************************************************************************** + * Name: board_lcd_uninitialize + * + * Description: + * Uninitialize the LCD support + * + ****************************************************************************/ + +void board_lcd_uninitialize(void) +{ + /* Turn the display off */ + + g_lcd->setpower(g_lcd, 0); +} diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_ili9341/defconfig b/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_ili9341/defconfig new file mode 100644 index 00000000000..d8e89be9bfb --- /dev/null +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_ili9341/defconfig @@ -0,0 +1,66 @@ +# +# 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_ARCH_LEDS is not set +# CONFIG_ESP32S2_SPI2_DMA is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s2-kaluga-1" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S2_KALUGA_1=y +CONFIG_ARCH_CHIP="esp32s2" +CONFIG_ARCH_CHIP_ESP32S2=y +CONFIG_ARCH_CHIP_ESP32S2WROVER=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_ESP32S2_SPI2=y +CONFIG_ESP32S2_SPI2_CLKPIN=15 +CONFIG_ESP32S2_SPI2_CSPIN=11 +CONFIG_ESP32S2_SPI2_MISOPIN=8 +CONFIG_ESP32S2_SPI2_MOSIPIN=9 +CONFIG_ESP32S2_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_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_RAW_BINARY=y +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_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_st7789/defconfig b/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_st7789/defconfig new file mode 100644 index 00000000000..c88ae08170b --- /dev/null +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_st7789/defconfig @@ -0,0 +1,69 @@ +# +# 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_ARCH_LEDS is not set +# CONFIG_ESP32S2_SPI2_DMA is not set +# CONFIG_LCD_ST7789_INVCOLOR is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s2-kaluga-1" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S2_KALUGA_1=y +CONFIG_ARCH_CHIP="esp32s2" +CONFIG_ARCH_CHIP_ESP32S2=y +CONFIG_ARCH_CHIP_ESP32S2WROVER=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_ESP32S2_SPI2=y +CONFIG_ESP32S2_SPI2_CLKPIN=15 +CONFIG_ESP32S2_SPI2_CSPIN=11 +CONFIG_ESP32S2_SPI2_MISOPIN=8 +CONFIG_ESP32S2_SPI2_MOSIPIN=9 +CONFIG_ESP32S2_SPI_SWCS=y +CONFIG_ESP32S2_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_ST7789=y +CONFIG_LCD_ST7789_FREQUENCY=10000000 +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_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_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_CMDDATA=y +CONFIG_SPI_DRIVER=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/include/board.h b/boards/xtensa/esp32s2/esp32s2-kaluga-1/include/board.h index 529458a6b25..f27b866732e 100644 --- a/boards/xtensa/esp32s2/esp32s2-kaluga-1/include/board.h +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/include/board.h @@ -66,6 +66,15 @@ # define NUM_BUTTONS 1 #endif +/* GPIO definitions *********************************************************/ + +/* ST7789 or ILI9341 */ + +#define LCD_SPI_PORTNO 2 +#define GPIO_LCD_DC 13 +#define GPIO_LCD_RST 16 +#define GPIO_LCD_BCKL 6 + /* LED definitions **********************************************************/ /* Define how many LEDs this board has (needed by userleds) */ diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_board_spi.c b/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_board_spi.c index 33c6127c1fd..92dcc6a9a0e 100644 --- a/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_board_spi.c +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_board_spi.c @@ -30,6 +30,8 @@ #include +#include + #include "esp32s2_gpio.h" #include "esp32s2-kaluga-1.h" diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_bringup.c b/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_bringup.c index ff241e2fb29..c23ceb96044 100644 --- a/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_bringup.c +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_bringup.c @@ -62,6 +62,11 @@ # include "esp32s2_board_wdt.h" #endif +#ifdef CONFIG_LCD_DEV +# include +# include +#endif + #include "esp32s2-kaluga-1.h" /**************************************************************************** @@ -216,6 +221,20 @@ int esp32s2_bringup(void) } #endif +#ifdef CONFIG_LCD_DEV + ret = board_lcd_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_lcd_initialize() failed: %d\n", ret); + } + + ret = lcddev_register(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); + } +#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.