diff --git a/CMakeLists.txt b/CMakeLists.txt index 3219703..05b4484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,18 +8,30 @@ # (i2c_master_bus_handle_t) is the one used in non-Arduino builds. # - googletest helpers (src/googletest/*) are EXCLUDED — they pull in # for test scaffolding only and are not needed at runtime. +include($ENV{IDF_PATH}/tools/cmake/version.cmake) + file(GLOB_RECURSE SRCS "src/*.cpp") list(FILTER SRCS EXCLUDE REGEX "/googletest/") -# REQUIRES = public deps (exposed through src/ public headers); PRIV_REQUIRES = used only in .cpp. -# Use the `driver` meta-component (exists in all IDF 5.x and publicly aggregates esp_driver_*), -# NOT the split esp_driver_* components which only exist from IDF 5.3 and would break >=5.0. + +set(public_requires driver M5HAL) +set(private_requires esp_adc esp_timer M5Utility) + +# Keep IDF 5.x on the driver meta-component. IDF v6 no longer exposes all split +# driver include paths transitively, so add only the v6-specific component deps. +if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL "6") + list(APPEND public_requires esp_driver_gpio esp_driver_i2c esp_driver_rmt esp_driver_spi esp_driver_uart esp_hw_support) + list(APPEND private_requires esp_driver_ledc esp_ringbuf) +endif() + idf_component_register( SRCS ${SRCS} INCLUDE_DIRS "src" - REQUIRES driver M5HAL - PRIV_REQUIRES esp_adc esp_timer M5Utility + REQUIRES ${public_requires} + PRIV_REQUIRES ${private_requires} ) +idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17" APPEND) + # Optionally link M5Unified only when it is already part of the build (e.g. a M5Unified-based # app or example). This puts M5GFX's on adapter_i2c.cpp's include path, # so the real m5::I2C_Class adapter is compiled instead of the stub. Pure ESP-IDF builds without diff --git a/src/m5_unit_component/adapter_gpio_v2.cpp b/src/m5_unit_component/adapter_gpio_v2.cpp index 0a0ed56..282adf7 100644 --- a/src/m5_unit_component/adapter_gpio_v2.cpp +++ b/src/m5_unit_component/adapter_gpio_v2.cpp @@ -27,11 +27,13 @@ rmt_tx_channel_config_t to_rmt_tx_config(const adapter_config_t &cfg, const uint out.clk_src = RMT_CLK_SRC_DEFAULT; out.mem_block_symbols = std::max(SOC_RMT_MEM_WORDS_PER_CHANNEL, cfg.tx.mem_blocks * SOC_RMT_MEM_WORDS_PER_CHANNEL); - out.resolution_hz = calculate_rmt_resolution_hz(apb_freq_hz, cfg.tx.tick_ns); - out.trans_queue_depth = 4; - out.flags.with_dma = cfg.tx.with_dma; + out.resolution_hz = calculate_rmt_resolution_hz(apb_freq_hz, cfg.tx.tick_ns); + out.trans_queue_depth = 4; + out.flags.with_dma = cfg.tx.with_dma; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0) out.flags.io_loop_back = cfg.tx.loop_enabled; - out.flags.invert_out = cfg.tx.invert_signal; +#endif + out.flags.invert_out = cfg.tx.invert_signal; return out; } diff --git a/src/m5_unit_component/adapter_spi.cpp b/src/m5_unit_component/adapter_spi.cpp index c37dcf8..00d80e8 100644 --- a/src/m5_unit_component/adapter_spi.cpp +++ b/src/m5_unit_component/adapter_spi.cpp @@ -11,6 +11,7 @@ #include "adapter_spi.hpp" #if defined(ESP_PLATFORM) #include +#include #endif #include #include diff --git a/src/m5_unit_component/pin.cpp b/src/m5_unit_component/pin.cpp index 3089e96..0ddabb9 100644 --- a/src/m5_unit_component/pin.cpp +++ b/src/m5_unit_component/pin.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace m5 { namespace unit {