Skip to content

Commit 128e4ae

Browse files
committed
fix: support IDF v6 GPIO register changes
Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com>
1 parent ca471d2 commit 128e4ae

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/m5_unit_component/adapter_gpio.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
constexpr auto M5_ADC_ATTEN_DB = ADC_ATTEN_DB_12;
3131
#else
3232
#pragma message "Not exists ADC_ATTEN_DB_12"
33-
constexpr auto M5_ADC_ATTEN_DB = ADC_ATTEN_DB_11;
33+
constexpr auto M5_ADC_ATTEN_DB = ADC_ATTEN_DB_11;
3434
#endif
3535

3636
#if defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED
@@ -628,8 +628,8 @@ m5::hal::error::error_t AdapterGPIOBase::GPIOImpl::read_analog_millivolts(uint32
628628
cali_ok = (adc_cali_create_scheme_curve_fitting(&cali_config, &cali_handle) == ESP_OK);
629629
#elif ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED
630630
adc_cali_line_fitting_config_t cali_config = {
631-
.unit_id = unit,
632-
.atten = M5_ADC_ATTEN_DB,
631+
.unit_id = unit,
632+
.atten = M5_ADC_ATTEN_DB,
633633
.bitwidth = ADC_BITWIDTH_DEFAULT,
634634
#if CONFIG_IDF_TARGET_ESP32
635635
.default_vref = 1100, // Fallback Vref (mV); used only when eFuse has no calibration

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/pin.cpp

Lines changed: 2 additions & 1 deletion
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 {
@@ -39,7 +40,7 @@ void pin_backup_t::backup(void)
3940
_gpio_enable = (bool)((*reinterpret_cast<uint32_t*>(((pin_num & 32) ? GPIO_ENABLE1_REG : GPIO_ENABLE_REG)) &
4041
(1U << (pin_num & 31))) != 0);
4142
#else
42-
_gpio_enable = (bool)((*reinterpret_cast<uint32_t*>(GPIO_ENABLE_REG) & (1U << (pin_num & 31))) != 0);
43+
_gpio_enable = (bool)((*reinterpret_cast<uint32_t*>(GPIO_ENABLE_REG) & (1U << (pin_num & 31))) != 0);
4344
#endif
4445

4546
_in_func_num = -1;

0 commit comments

Comments
 (0)