Essence ESP32 LVGL_V8 Fastest Porting Guide

Essence ESP32 LVGL_V8 Fastest Porting Guide

Series article address: ESP32 LVGLV7 fastest porting strategy

This article is the latest transplant before publication. If you need Lvgl V7, you can refer to the above.

This article comes from Anxinke technology developers. It is said that this is the sharing of zzy ~

Software Environment

  • VSCODE-ESP32-IDF4.4 plug-in version supports ESP32-S3
  • LVGL project for ESP32 master branch
  • LVGL V8 master branch

hardware environment

  • Anxinke ESP-S3-12K development board
    - has been listed on Taobao, →Click here to buy←insert image description here

  • 1.3TFT, plug-in version ST7789

Introduction of ESP-S3-12K Development Board

The ESP-S3-12K-Kit development board is a core development board designed by Essence for the ESP-S3-12K module. The development board continues the classic design of the NodeMCU development board and leads all I/Os to the Pin headers, developers can connect peripherals according to their needs. When using a breadboard for development and debugging, the 2.54mm pitch pin headers on both sides make the operation easier and more convenient.

Parameters of the development board

insert image description here

It can be seen that Anxinke ESP32-S3-12k development board not only has 8M Byte SPI Flash but also 8M Byte Psram .

SPI of ESP32S3

ESP32-S3 has a total of four SPIs (SPI0, SPI1, SPI2 and SPI3). SPI0 and SPI1 can be configured in SPI memory mode, and SPI2 and SPI3 can be configured in general SPI mode.

SPI Memory Mode SPI

The memory modes (SPI0 and SPI1) are used to connect the external memory of the SPI interface. In SPI memory mode, the data transfer length is in bytes, and supports up to eight-wire SDR/DDR (single data sampling edge/double data sampling edge) read and write operations. The clock frequency is configurable and supports up to OPI 120 MHz SDR/DDR mode.

SPI2 General Purpose SPI (GPSPI) mode

SPI2 can be configured in both master mode and slave mode. The master mode supports two-wire full-duplex and single-wire, two-wire, four-wire or eight-wire half-duplex communication; the slave mode supports two-wire full-duplex and single-wire, two-wire or four-wire half-duplex communication. The master clock frequency of the general-purpose SPI is configurable; the data transfer length is in bytes; the clock polarity (CPOL) and phase (CPHA) are configurable; a DMA channel can be connected.

SPI3 General Purpose SPI (GPSPI) mode

SPI3 can be configured in both master mode and slave mode, with dual-wire full-duplex and single-wire, dual-wire or quad-wire half-duplex communication functions, and only supports SDR read and write operations. The master clock frequency of the general-purpose SPI is configurable; the data transfer length is in bytes; the clock polarity (CPOL) and phase (CPHA) are configurable; a DMA channel can be connected.

Normally, the data port connection relationship between ESP32-S3 and flash chip is:

insert image description here

Four-wire SPI is used in Anxin's module, and the specific occupied pins are:

insert image description here

The corresponding GPIO is:

insert image description here

When using it, be careful not to use these pins. Of course, these pins are not brought out on the development board, and they are avoided to a certain extent.

LVGL_V8 porting guide

The first is to download the source code:

You can use it directly by downloading my ported code or download the latest code from github (of course, as of the article published my latest code).

Use my code directly:

gitee code address .

Download the code by git:

First download the latest LVGL V8, just download the master branch directly:

git clone [email protected]:lvgl/lvgl.git

Then download the latest driver for ESP32:

git clone [email protected]:lvgl/lvgl_esp32_drivers.git

After the download is complete, you can see two items in the folder:

insert image description here

Then we will create a new ESP32 project. For simplicity, we will create a new blink project:

insert image description here

Select the blink project and create the project in the appropriate location:

insert image description here

Find the project you created:

insert image description here

Create a components folder in the project directory:

insert image description here

Put the code you just downloaded into your project folder:

insert image description here

Then use VScode to open the project folder:

You can see the extra lvgl and drivers in the project folder location:

insert image description here

Next we modify the code and configure the project:

The first is to modify the chip model:

Click on the image below

insert image description here

Select ESP32-S3 :

insert image description here

Then open the configuration project:

Find the LVGL configuration project, if your configuration project does not have LVGL, please reopen VSCode;

After opening, you can see four key configuration items:

insert image description here

Then click the configuration item of the corresponding driver:

I am using ST7789V here, so the configuration items corresponding to the driver appear below me:

insert image description here

The pins that need to be configured after opening are as follows:

insert image description here

Note that these are the default pins, we need to make some modifications to fit S3:

insert image description here

Because ST7735S and ST7789 are high-order 16-bit short integers when receiving 16-bit color values. And because ESP32 is in little-endian mode, when DMA sends 16-bit data, it will send the lower 8-bit bytes first and then the upper 8-bit bytes, which results in inconsistent data! So you need to check it, and after checking it, it is changed. If you check this option and cause the color to be wrong, you can uncheck it.

insert image description here

If instead of seeing black text on a white background, the colors are reversed, you can check this option to correct the color.

insert image description here

After the modification is completed, the configuration project is basically completed.

Next modify the code:

The first is to add a few macro definitions below lvgl_helpers.h:

insert image description here

#define LV_HOR_RES_MAX 240
#define LV_VER_RES_MAX 240
#define SPI_HOST_MAX 3

Then modify the code in this location of lvgl_helpers.c:

insert image description here

Modify the source code to esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)SPI_DMA_CH_AUTO);.

You can edit it here first to see if an error will be reported. If there is no error, start writing the lvgl code.

Of course, I have already written the code to initialize LVGL, just in the project, you can directly Download it and use it:

After downloading, find these two files and put them in the main directory:

His path is: ./main/…

insert image description here

Adding files alone doesn't make them compile. We also need to add them manually:

Open the CMAKELists in the main directory and add the following:

insert image description here

Back to main.c:

Add header support:

insert image description here

Modify the app_main function and add the lvgl initialization thread to it:

void app_main(void)
{
    
    
    /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
       muxed to GPIO on reset already, but some default to other
       functions and need to be switched to GPIO. Consult the
       Technical Reference for a list of pads and their default
       functions.)
    */
    xTaskCreatePinnedToCore(guiTask, "gui", 4096*2, NULL, 1, NULL, 1);
    gpio_reset_pin(BLINK_GPIO);
    /* Set the GPIO as a push/pull output */
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    while(1) {
    
    
        /* Blink off (output low) */
        printf("Turning off the LED\n");
        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        /* Blink on (output high) */
        printf("Turning on the LED\n");
        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

Compile again, and you can see the effect after downloading:

insert image description here

Thanks to the author of this article. It is said that this is zzy 's sharing ~
read the original text: https://blog.csdn.net/qq_20540901/article/details/123608655?spm=1001.2014.3001.5501

Guess you like

Origin blog.csdn.net/Boantong_/article/details/123677448