From 048438738c7e74e40ec90d210e9b249ad6e1b1d8 Mon Sep 17 00:00:00 2001 From: Rop Gonggrijp Date: Mon, 12 Jul 2021 10:18:20 +0200 Subject: [PATCH] Things noted by @tore-espressif See https://github.com/lvgl/lvgl_esp32_drivers/pull/70#pullrequestreview-703588587 --- i2c_manager/Kconfig | 14 -------------- i2c_manager/i2c_manager.c | 8 ++++---- lvgl_tft/ssd1306.c | 25 ++----------------------- 3 files changed, 6 insertions(+), 41 deletions(-) diff --git a/i2c_manager/Kconfig b/i2c_manager/Kconfig index 0c11ab1..72cbec2 100644 --- a/i2c_manager/Kconfig +++ b/i2c_manager/Kconfig @@ -9,14 +9,8 @@ menu "I2C Port Settings" if I2C_MANAGER_0_ENABLED config I2C_MANAGER_0_SDA int "SDA (GPIO pin)" - range 0 39 if IDF_TARGET_ESP32 - range 0 46 if IDF_TARGET_ESP32S2 - range 0 21 if IDF_TARGET_ESP32C3 config I2C_MANAGER_0_SCL int "SCL (GPIO pin)" - range 0 39 if IDF_TARGET_ESP32 - range 0 46 if IDF_TARGET_ESP32S2 - range 0 21 if IDF_TARGET_ESP32C3 config I2C_MANAGER_0_FREQ_HZ int "Frequency (Hz)" default 400000 @@ -64,16 +58,8 @@ menu "I2C Port Settings" if I2C_MANAGER_1_ENABLED config I2C_MANAGER_1_SDA int "SDA (GPIO pin)" - default 32 - range 0 39 if IDF_TARGET_ESP32 - range 0 46 if IDF_TARGET_ESP32S2 - range 0 21 if IDF_TARGET_ESP32C3 config I2C_MANAGER_1_SCL int "SCL (GPIO pin)" - default 33 - range 0 39 if IDF_TARGET_ESP32 - range 0 46 if IDF_TARGET_ESP32S2 - range 0 21 if IDF_TARGET_ESP32C3 config I2C_MANAGER_1_FREQ_HZ int "Frequency (Hz)" default 1000000 diff --git a/i2c_manager/i2c_manager.c b/i2c_manager/i2c_manager.c index d301aff..095143d 100644 --- a/i2c_manager/i2c_manager.c +++ b/i2c_manager/i2c_manager.c @@ -66,8 +66,8 @@ static const uint8_t ACK_CHECK_EN = 1; #define I2C_MANAGER_0_PULLUPS false #endif - #define I2C_MANAGER_0_TIMEOUT CONFIG_I2C_MANAGER_0_TIMEOUT / portTICK_RATE_MS - #define I2C_MANAGER_0_LOCK_TIMEOUT CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT / portTICK_RATE_MS + #define I2C_MANAGER_0_TIMEOUT ( CONFIG_I2C_MANAGER_0_TIMEOUT / portTICK_RATE_MS ) + #define I2C_MANAGER_0_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT / portTICK_RATE_MS ) #endif @@ -79,8 +79,8 @@ static const uint8_t ACK_CHECK_EN = 1; #define I2C_MANAGER_1_PULLUPS false #endif - #define I2C_MANAGER_1_TIMEOUT CONFIG_I2C_MANAGER_1_TIMEOUT / portTICK_RATE_MS - #define I2C_MANAGER_1_LOCK_TIMEOUT CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT / portTICK_RATE_MS + #define I2C_MANAGER_1_TIMEOUT ( CONFIG_I2C_MANAGER_1_TIMEOUT / portTICK_RATE_MS ) + #define I2C_MANAGER_1_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT / portTICK_RATE_MS ) #endif #define ERROR_PORT(port, fail) { \ diff --git a/lvgl_tft/ssd1306.c b/lvgl_tft/ssd1306.c index 459cd00..811f164 100644 --- a/lvgl_tft/ssd1306.c +++ b/lvgl_tft/ssd1306.c @@ -211,36 +211,15 @@ void ssd1306_sleep_out(void) static uint8_t send_data(lv_disp_drv_t *disp_drv, void *bytes, size_t bytes_len) { (void) disp_drv; - esp_err_t err; uint8_t *data = (uint8_t *) bytes; - err = lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, data[0], data + 1, bytes_len - 1 ); - -// i2c_cmd_handle_t cmd = i2c_cmd_link_create(); -// -// i2c_master_start(cmd); -// i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true); -// -// for (size_t idx = 0; idx < bytes_len; idx++) { -// i2c_master_write_byte(cmd, data[idx], true); -// } -// -// i2c_master_stop(cmd); -// -// /* Send queued commands */ -// err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS); -// i2c_cmd_link_delete(cmd); - - return ESP_OK == err ? 0 : 1; + return lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, data[0], data + 1, bytes_len - 1 ); } static uint8_t send_pixels(lv_disp_drv_t *disp_drv, void *color_buffer, size_t buffer_len) { (void) disp_drv; - esp_err_t err; - err = lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, OLED_CONTROL_BYTE_DATA_STREAM, color_buffer, buffer_len); - - return ESP_OK == err ? 0 : 1; + return lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, OLED_CONTROL_BYTE_DATA_STREAM, color_buffer, buffer_len); }