Skip to content

Commit

Permalink
lcd_driver: fix LCD peripheral (source) timing issue caused by ESP-ID…
Browse files Browse the repository at this point in the history
…F v5.3 API breaking changes

Ref: #345
  • Loading branch information
huming2207 committed Aug 27, 2024
1 parent df2f64d commit bae2f06
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/output_lcd/lcd_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,12 @@ static esp_err_t init_lcd_peripheral() {

// enable RGB mode and set data width
lcd_ll_enable_rgb_mode(lcd.hal.dev, true);
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
lcd_ll_set_dma_read_stride(lcd.hal.dev, lcd.config.bus_width);
lcd_ll_set_data_wire_width(lcd.hal.dev, lcd.config.bus_width);
#else
lcd_ll_set_data_width(lcd.hal.dev, lcd.config.bus_width);
#endif
lcd_ll_set_phase_cycles(lcd.hal.dev, 0, (lcd.dummy_bytes > 0), 1); // enable data phase only
lcd_ll_enable_output_hsync_in_porch_region(lcd.hal.dev, false); // enable data phase only

Expand Down Expand Up @@ -612,7 +617,18 @@ void epd_lcd_set_pixel_clock_MHz(int frequency) {

// set pclk
int flags = 0;

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
hal_utils_clk_div_t clk_div = {};
uint32_t freq
= lcd_hal_cal_pclk_freq(&lcd.hal, 240000000, lcd.config.pixel_clock, flags, &clk_div);
lcd_ll_set_group_clock_coeff(
&LCD_CAM, (int)clk_div.integer, (int)clk_div.denominator, (int)clk_div.numerator
);
#else
uint32_t freq = lcd_hal_cal_pclk_freq(&lcd.hal, 240000000, lcd.config.pixel_clock, flags);
#endif

ESP_LOGI(TAG, "pclk freq: %d Hz", freq);
lcd.line_length_us = (lcd.lcd_res_h + lcd.config.le_high_time + lcd.config.line_front_porch - 1)
* 1000000 / lcd.config.pixel_clock
Expand Down

0 comments on commit bae2f06

Please sign in to comment.