Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash of uDisplay on ESP32S3 with IDF5.1 #19383

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/lib_display/UDisplay/uDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,11 @@ Renderer *uDisplay::Init(void) {
_panel_config->disp_gpio_num = GPIO_NUM_NC;

_panel_config->flags.disp_active_low = 0;
#if ESP_IDF_VERSION_MAJOR >= 5
_panel_config->flags.refresh_on_demand = 0;
#else
_panel_config->flags.relax_on_idle = 0;
#endif // ESP_IDF_VERSION_MAJOR >= 5
_panel_config->flags.fb_in_psram = 1; // allocate frame buffer in PSRAM

ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(_panel_config, &_panel_handle));
Expand All @@ -955,9 +959,16 @@ Renderer *uDisplay::Init(void) {
uint16_t color = random(0xffff);
ESP_ERROR_CHECK(_panel_handle->draw_bitmap(_panel_handle, 0, 0, 1, 1, &color));

#if ESP_IDF_VERSION_MAJOR < 5
_rgb_panel = __containerof(_panel_handle, esp_rgb_panel_t, base);

rgb_fb = (uint16_t *)_rgb_panel->fb;
#else
void * buf = NULL;
esp_lcd_rgb_panel_get_frame_buffer(_panel_handle, 1, &buf);
rgb_fb = (uint16_t *)buf;
#endif



#endif // USE_ESP32_S3
}
Expand Down Expand Up @@ -1032,12 +1043,14 @@ Renderer *uDisplay::Init(void) {

esp_lcd_new_i80_bus(&bus_config, &_i80_bus);

#if ESP_IDF_VERSION_MAJOR < 5
_dma_chan = _i80_bus->dma_chan;
#endif

uint32_t div_a, div_b, div_n, clkcnt;
calcClockDiv(&div_a, &div_b, &div_n, &clkcnt, 240*1000*1000, spi_speed*1000000);
lcd_cam_lcd_clock_reg_t lcd_clock;
lcd_clock.lcd_clkcnt_n = std::max(1u, clkcnt - 1);
lcd_clock.lcd_clkcnt_n = std::max((uint32_t)1u, clkcnt - 1); // ESP_IDF_VERSION_MAJOR >= 5
lcd_clock.lcd_clk_equ_sysclk = (clkcnt == 1);
lcd_clock.lcd_ck_idle_edge = true;
lcd_clock.lcd_ck_out_edge = false;
Expand Down
11 changes: 8 additions & 3 deletions lib/lib_display/UDisplay/uDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "driver/spi_master.h"
#if ESP_IDF_VERSION_MAJOR >= 5
#include "soc/gpio_periph.h"
#include <rom/gpio.h>
#endif // ESP_IDF_VERSION_MAJOR >= 5
#endif

Expand All @@ -36,6 +37,9 @@ static inline void gpio_lo(int_fast8_t pin) { if (pin >= 0) *get_gpio_lo_reg(pin
#include "esp_lcd_panel_ops.h"
#include <hal/dma_types.h>
#include <rom/cache.h>
#if ESP_IDF_VERSION_MAJOR >= 5
#include "esp_rom_lldesc.h"
#endif // ESP_IDF_VERSION_MAJOR >= 5
#endif // USE_ESP32_S3

#define _UDSP_I2C 1
Expand Down Expand Up @@ -112,7 +116,7 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR };
#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET_SLOW(spi_dc);


#ifdef USE_ESP32_S3
#if defined(USE_ESP32_S3) && ESP_IDF_VERSION_MAJOR < 5
struct esp_lcd_i80_bus_t {
int bus_id; // Bus ID, index from 0
portMUX_TYPE spinlock; // spinlock used to protect i80 bus members(hal, device_list, cur_trans)
Expand Down Expand Up @@ -157,8 +161,7 @@ struct esp_rgb_panel_t
} flags;
dma_descriptor_t dma_nodes[]; // DMA descriptor pool of size `num_dma_nodes`
};

#endif
#endif //USE_ESP32_S3 && ESP_IDF_VERSION_MAJOR < 5


class uDisplay : public Renderer {
Expand Down Expand Up @@ -354,7 +357,9 @@ class uDisplay : public Renderer {
uint16_t pclk_active_neg;

esp_lcd_panel_handle_t _panel_handle = NULL;
#if ESP_IDF_VERSION_MAJOR < 5
esp_rgb_panel_t *_rgb_panel;
#endif //ESP_IDF_VERSION_MAJOR < 5
uint16_t *rgb_fb;


Expand Down