From 0dad29563246efb229d696355d7254c445aad85a Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Tue, 23 Jun 2026 18:57:23 +0800 Subject: [PATCH] fix(i2c_oled): fix example hang when i2c transaction fails Closes https://github.com/espressif/esp-idf/issues/18713 --- examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c b/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c index f778ff63a86..de41a23886f 100644 --- a/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c +++ b/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c @@ -33,6 +33,7 @@ static const char *TAG = "example"; #define EXAMPLE_PIN_NUM_SCL 4 #define EXAMPLE_PIN_NUM_RST -1 #define EXAMPLE_I2C_HW_ADDR 0x3C +#define EXAMPLE_I2C_TRANSACTION_TIMEOUT_MS 1000 // The pixel number in horizontal and vertical #if CONFIG_EXAMPLE_LCD_CONTROLLER_SSD1306 @@ -67,10 +68,10 @@ void app_main(void) esp_lcd_panel_io_i2c_config_t io_config = { .dev_addr = EXAMPLE_I2C_HW_ADDR, .scl_speed_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ, + .transaction_timeout_ms = EXAMPLE_I2C_TRANSACTION_TIMEOUT_MS, .control_phase_bytes = 1, // According to SSD1306 datasheet .lcd_cmd_bits = EXAMPLE_LCD_CMD_BITS, // According to SSD1306 datasheet .lcd_param_bits = EXAMPLE_LCD_CMD_BITS, // According to SSD1306 datasheet - .transaction_timeout_ms = 0, // wait infinitely #if CONFIG_EXAMPLE_LCD_CONTROLLER_SSD1306 .dc_bit_offset = 6, // According to SSD1306 datasheet #elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH1107