Changed config variable determination to macro variable determination

This commit is contained in:
nopnop2002 2024-09-09 16:32:24 +09:00
parent 53bf6d2db7
commit 9ae36e05f6
2 changed files with 20 additions and 5 deletions

View File

@ -1,4 +1,17 @@
set(COMPONENT_SRCS "main.c")
set(COMPONENT_ADD_INCLUDEDIRS "")
set(srcs "main.c")
# get IDF version for comparison
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}")
if(idf_version VERSION_GREATER_EQUAL "5.2")
if(CONFIG_LEGACY_DRIVER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D LEGACY_DRIVER")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D NEW_DRIVER")
endif()
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D LEGACY_DRIVER")
endif()
idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ".")
register_component()

View File

@ -49,7 +49,7 @@ void app_main(void)
i2c_port_t i2c_num = I2C_NUM_1;
#endif
#if CONFIG_LEGACY_DRIVER
#ifdef LEGACY_DRIVER
ESP_LOGI(tag, "I2C_LEGACY_DRIVER");
// install i2c master driver
i2c_config_t i2c_config = {
@ -65,7 +65,9 @@ void app_main(void)
// add new device to i2c bus
i2c_device_add(&dev, i2c_num, CONFIG_RESET_GPIO);
#else
#endif
#ifdef NEW_DRIVER
ESP_LOGI(tag, "I2C_NEW_DRIVER");
// install i2c master driver
i2c_master_bus_config_t i2c_mst_config = {