Skip to content

Commit 46da51d

Browse files
Sped0nGOB52
authored andcommitted
feat: ESP-IDF v6.0 support (#2)
* fix: support IDF v6 GPIO register changes Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com> * fix: make IDF component dependencies version-aware Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com> * fix: build native IDF component as C++17 Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com> * fix: include FreeRTOS header in SPI adapter Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com> --------- Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com>
1 parent fdb03a9 commit 46da51d

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,30 @@
88
# (i2c_master_bus_handle_t) is the one used in non-Arduino builds.
99
# - googletest helpers (src/googletest/*) are EXCLUDED — they pull in
1010
# <M5Unified.h> for test scaffolding only and are not needed at runtime.
11+
include($ENV{IDF_PATH}/tools/cmake/version.cmake)
12+
1113
file(GLOB_RECURSE SRCS "src/*.cpp")
1214
list(FILTER SRCS EXCLUDE REGEX "/googletest/")
13-
# REQUIRES = public deps (exposed through src/ public headers); PRIV_REQUIRES = used only in .cpp.
14-
# Use the `driver` meta-component (exists in all IDF 5.x and publicly aggregates esp_driver_*),
15-
# NOT the split esp_driver_* components which only exist from IDF 5.3 and would break >=5.0.
15+
16+
set(public_requires driver M5HAL)
17+
set(private_requires esp_adc esp_timer M5Utility)
18+
19+
# Keep IDF 5.x on the driver meta-component. IDF v6 no longer exposes all split
20+
# driver include paths transitively, so add only the v6-specific component deps.
21+
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL "6")
22+
list(APPEND public_requires esp_driver_gpio esp_driver_i2c esp_driver_rmt esp_driver_spi esp_driver_uart esp_hw_support)
23+
list(APPEND private_requires esp_driver_ledc esp_ringbuf)
24+
endif()
25+
1626
idf_component_register(
1727
SRCS ${SRCS}
1828
INCLUDE_DIRS "src"
19-
REQUIRES driver M5HAL
20-
PRIV_REQUIRES esp_adc esp_timer M5Utility
29+
REQUIRES ${public_requires}
30+
PRIV_REQUIRES ${private_requires}
2131
)
2232

33+
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17" APPEND)
34+
2335
# Optionally link M5Unified only when it is already part of the build (e.g. a M5Unified-based
2436
# app or example). This puts M5GFX's <utility/I2C_Class.hpp> on adapter_i2c.cpp's include path,
2537
# so the real m5::I2C_Class adapter is compiled instead of the stub. Pure ESP-IDF builds without

src/m5_unit_component/adapter_gpio_v2.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ rmt_tx_channel_config_t to_rmt_tx_config(const adapter_config_t &cfg, const uint
2727
out.clk_src = RMT_CLK_SRC_DEFAULT;
2828
out.mem_block_symbols =
2929
std::max<uint32_t>(SOC_RMT_MEM_WORDS_PER_CHANNEL, cfg.tx.mem_blocks * SOC_RMT_MEM_WORDS_PER_CHANNEL);
30-
out.resolution_hz = calculate_rmt_resolution_hz(apb_freq_hz, cfg.tx.tick_ns);
31-
out.trans_queue_depth = 4;
32-
out.flags.with_dma = cfg.tx.with_dma;
30+
out.resolution_hz = calculate_rmt_resolution_hz(apb_freq_hz, cfg.tx.tick_ns);
31+
out.trans_queue_depth = 4;
32+
out.flags.with_dma = cfg.tx.with_dma;
33+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
3334
out.flags.io_loop_back = cfg.tx.loop_enabled;
34-
out.flags.invert_out = cfg.tx.invert_signal;
35+
#endif
36+
out.flags.invert_out = cfg.tx.invert_signal;
3537
return out;
3638
}
3739

src/m5_unit_component/adapter_spi.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "adapter_spi.hpp"
1212
#if defined(ESP_PLATFORM)
1313
#include <driver/gpio.h>
14+
#include <freertos/FreeRTOS.h>
1415
#endif
1516
#include <M5HAL.hpp>
1617
#include <M5Utility.hpp>

src/m5_unit_component/pin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <driver/i2c.h>
1515
#include <soc/gpio_struct.h>
1616
#include <soc/gpio_periph.h>
17+
#include <soc/gpio_reg.h>
1718

1819
namespace m5 {
1920
namespace unit {

0 commit comments

Comments
 (0)