From 335e8b4648b7203e7e5b5125979410a82cb5d31d Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Fri, 26 Jul 2024 07:47:53 +0200 Subject: [PATCH] fix(esp_lcd): Fix I2C receive without param --- components/esp_lcd/src/esp_lcd_panel_io_i2c_v2.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/esp_lcd/src/esp_lcd_panel_io_i2c_v2.c b/components/esp_lcd/src/esp_lcd_panel_io_i2c_v2.c index fa2c834adc..e59226f698 100644 --- a/components/esp_lcd/src/esp_lcd_panel_io_i2c_v2.c +++ b/components/esp_lcd/src/esp_lcd_panel_io_i2c_v2.c @@ -121,10 +121,10 @@ static esp_err_t panel_io_i2c_rx_buffer(esp_lcd_panel_io_t *io, int lcd_cmd, voi lcd_panel_io_i2c_t *i2c_panel_io = __containerof(io, lcd_panel_io_i2c_t, base); bool send_param = (lcd_cmd >= 0); - int write_size = 0; - uint8_t write_buffer[CONTROL_PHASE_LENGTH + CMD_LENGTH] = {0}; - if (send_param) { + int write_size = 0; + uint8_t write_buffer[CONTROL_PHASE_LENGTH + CMD_LENGTH] = {0}; + if (i2c_panel_io->control_phase_enabled) { write_buffer[0] = i2c_panel_io->control_phase_cmd; write_size += 1; @@ -136,9 +136,12 @@ static esp_err_t panel_io_i2c_rx_buffer(esp_lcd_panel_io_t *io, int lcd_cmd, voi memcpy(write_buffer + write_size, cmds + (sizeof(cmds) - cmds_size), cmds_size); write_size += cmds_size; } + + ESP_GOTO_ON_ERROR(i2c_master_transmit_receive(i2c_panel_io->i2c_handle, write_buffer, write_size, buffer, buffer_size, -1), err, TAG, "i2c transaction failed"); + } else { + ESP_GOTO_ON_ERROR(i2c_master_receive(i2c_panel_io->i2c_handle, buffer, buffer_size, -1), err, TAG, "i2c transaction failed"); } - ESP_GOTO_ON_ERROR(i2c_master_transmit_receive(i2c_panel_io->i2c_handle, write_buffer, write_size, buffer, buffer_size, -1), err, TAG, "i2c transaction failed"); return ESP_OK; err: return ret;