esp-box icon indicating copy to clipboard operation
esp-box copied to clipboard

Support for new I2C master driver. (AEGHB-572)

Open ammaree opened this issue 1 year ago • 6 comments

When is support planned for the new I2C master driver?

ammaree avatar Mar 01 '24 12:03 ammaree

Hello, do you mean the file esp_lcd_panel_io_i2c_v1.c and esp_lcd_panel_io_i2c_v2.c. This interface should not be used in the application, compatibility has been done at the io_handle layer. Can I learn more about your needs?

espressif2022 avatar Mar 05 '24 02:03 espressif2022

I am building our application for the ESP-BOX using latest VSCode, IDF Master (v5.3-dev-2381-g9f4e8eb0cd). Application compiles and links, only complains about: /Users/andremaree/DevSpace/z-comp/gui_basic/gui_lvgl.cpp:87:33: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix] 87 | lv_label_set_text(lv_label, "#FF0000 "LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"#\n#FF9400 "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING" #"); | ^ /Users/andremaree/DevSpace/z-comp/gui_basic/gui_lvgl.cpp:87:57: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix] 87 | lv_label_set_text(lv_label, "#FF0000 "LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"#\n#FF9400 "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING" #"); | ^ /Users/andremaree/DevSpace/z-comp/gui_basic/gui_lvgl.cpp:87:105: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix] 87 | lv_label_set_text(lv_label, "#FF0000 "LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"#\n#FF9400 "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING" #"); | ^ /Users/andremaree/DevSpace/z-comp/gui_basic/gui_lvgl.cpp:87:135: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix] 87 | lv_label_set_text(lv_label, "#FF0000 "LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"#\n#FF9400 "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING" #"); | ^ In file included from /Users/andremaree/DevSpace/z-projects/irmacs/managed_components/lvgl__lvgl/src/core/lv_obj.h:140, from /Users/andremaree/DevSpace/z-projects/irmacs/managed_components/lvgl__lvgl/lvgl.h:35, from /Users/andremaree/DevSpace/z-projects/irmacs/managed_components/espressif__esp-box/include/bsp/esp-box.h:18, from /Users/andremaree/DevSpace/z-projects/irmacs/managed_components/espressif__esp-box/include/bsp/esp-bsp.h:8, from /Users/andremaree/DevSpace/z-comp/gui_basic/gui_lvgl.cpp:16: /Users/andremaree/DevSpace/z-projects/irmacs/managed_components/lvgl__lvgl/src/core/lv_obj_style.h: In function 'void lv_obj_remove_style_all(_lv_obj_t*)': /Users/andremaree/DevSpace/z-projects/irmacs/managed_components/lvgl__lvgl/src/core/lv_obj_style.h:94:48: warning: bitwise operation between different enumeration types '<unnamed enum>' and '<unnamed enum>' is deprecated [-Wdeprecated-enum-enum-conversion] 94 | lv_obj_remove_style(obj, NULL, LV_PART_ANY | LV_STATE_ANY); | ~~~~~~~~~~~~^~~~~~~~~~~~~~ On boot complains in log about: boot i2c This driver is an old driver, please migrate your application code to adaptdriver/i2c_master.h

ammaree avatar Mar 06 '24 07:03 ammaree

@espressif2022

The way I understand it the build should automatically use the new i2c_master functionality when compiled with IDF v5.3 ie Master?

ammaree avatar Mar 06 '24 10:03 ammaree

@ammaree , hello, sorry for my delayed reply.

  • I think it'll still use the old driver.

    #define esp_lcd_new_panel_io_i2c(bus, io_config, ret_io) _Generic((bus),  \
                i2c_master_bus_handle_t : esp_lcd_new_panel_io_i2c_v2, \
                default : esp_lcd_new_panel_io_i2c_v1) (bus, io_config, ret_io) \
    
    esp_err_t esp_lcd_new_panel_io_i2c_v2(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io)
    esp_err_t esp_lcd_new_panel_io_i2c_v1(uint32_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io)
    

    It can be seen that IDF internally handles compatibility between V1 and V2, mainly to determine the parameter type.

    If the parameter of new_panel is i2c_master_bus_handle_t, V2 will be selected; If it is uint32_t type, the driver of V1 will be selected.

    I saw the following definition in esp_lcd/esp_lcd_panel_io.h, so the V1 driver should still be used. typedef uint32_t esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */

  • About warnning.

    There are also some compilation warnning mentioned above, this example code is from esp_bsp? And it should be caused by some differences between C++ and C compilers.

espressif2022 avatar Mar 11 '24 07:03 espressif2022

@espressif2022

I just tried to rebuild the app using latest esp_box v3.0.5 with esl_lvgl_port v2.0.0 and lvgl v9 build the build fails, unable to find a working combination.

The last working combination was using box/v3.0.4 with port/v1.4.0 and lvgl 8.3.11

We are not too worried about tsp-box or lvgl or esp_lvgl_port versions, what is critical is to use the new (5.1.x. onwards) I2C master driver since this allows us to intercept the I2C API calls and transparently route them throughout our dedicated I2C task.

How can we achieve this?

As far as the "invalid suffix" compile warnings/errors are concerned, the code was lifted from a BSP example but we have fixed those.

Help on making the I2C master driver interface work will be much appreciated.

ammaree avatar Mar 14 '24 10:03 ammaree

what is critical is to use the new (5.1.x. onwards) I2C master driver since this allows us to intercept the I2C API calls and transparently route them throughout our dedicated I2C task. I'm sorry. This description above is not very clear to me. According to the existing driver, if we use our esp_lcd/esp_lcd_panel_io interface, the old IIC driver will be called, which requires modification by IDF. Does the current driver not meet the requirements?

espressif2022 avatar Mar 15 '24 11:03 espressif2022