Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# <M5Unified.h> 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 <utility/I2C_Class.hpp> 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
Expand Down
10 changes: 6 additions & 4 deletions src/m5_unit_component/adapter_gpio_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(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;
}

Expand Down
1 change: 1 addition & 0 deletions src/m5_unit_component/adapter_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "adapter_spi.hpp"
#if defined(ESP_PLATFORM)
#include <driver/gpio.h>
#include <freertos/FreeRTOS.h>
#endif
#include <M5HAL.hpp>
#include <M5Utility.hpp>
Expand Down
1 change: 1 addition & 0 deletions src/m5_unit_component/pin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <driver/i2c.h>
#include <soc/gpio_struct.h>
#include <soc/gpio_periph.h>
#include <soc/gpio_reg.h>

namespace m5 {
namespace unit {
Expand Down
Loading