From 6a1ae1b6cb331cbb146dc763bbe7169d5fa30b12 Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Thu, 12 Oct 2023 11:33:21 +0200 Subject: [PATCH] Arduino ESP32 3.0.0 --- src/AudioAnalog/AnalogAudioBase.h | 6 +++--- src/AudioAnalog/AnalogAudioESP32V1.h | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/AudioAnalog/AnalogAudioBase.h b/src/AudioAnalog/AnalogAudioBase.h index fd51057bd7..b49a9aedd2 100644 --- a/src/AudioAnalog/AnalogAudioBase.h +++ b/src/AudioAnalog/AnalogAudioBase.h @@ -63,13 +63,13 @@ class AnalogConfig : public AudioInfo { int adc_attenuation = ADC_ATTEN_DB_0; int adc_bit_width = SOC_ADC_DIGI_MAX_BITWIDTH; #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C2 - adc_channel_t channel[3] = {ADC_CHANNEL_2, ADC_CHANNEL_3, (ADC_CHANNEL_0 | 1 << 3)}; + adc_channel_t adc_channels[3] = {ADC_CHANNEL_2, ADC_CHANNEL_3, (ADC_CHANNEL_0 | 1 << 3)}; #endif #if CONFIG_IDF_TARGET_ESP32S2 - adc_channel_t channel[3] = {ADC_CHANNEL_2, ADC_CHANNEL_3, (ADC_CHANNEL_0 | 1 << 3)}; + adc_channel_t adc_channels[3] = {ADC_CHANNEL_2, ADC_CHANNEL_3, (ADC_CHANNEL_0 | 1 << 3)}; #endif #if CONFIG_IDF_TARGET_ESP32 - adc_channel_t channel[1] = {ADC_CHANNEL_7}; + adc_channel_t adc_channels[1] = {ADC_CHANNEL_7}; #endif #endif diff --git a/src/AudioAnalog/AnalogAudioESP32V1.h b/src/AudioAnalog/AnalogAudioESP32V1.h index b2b776ee81..01629dfed5 100644 --- a/src/AudioAnalog/AnalogAudioESP32V1.h +++ b/src/AudioAnalog/AnalogAudioESP32V1.h @@ -164,6 +164,11 @@ class AnalogDriverESP32V1 : public AnalogDriverBase { bool setup_rx(){ + int max_channels = sizeof(cfg.adc_channels)/sizeof(adc_channel_t); + if (cfg.channels > max_channels ){ + LOGE("channels: %d, max: %d", cfg.channels, max_channels); + return false; + } adc_continuous_handle_cfg_t adc_config = { .max_store_buf_size = (uint32_t)cfg.buffer_size * cfg.buffer_count, .conv_frame_size = (uint32_t)cfg.buffer_size, @@ -179,8 +184,8 @@ class AnalogDriverESP32V1 : public AnalogDriverBase { adc_continuous_config_t dig_cfg = {}; dig_cfg.pattern_num = cfg.channels; for (int i = 0; i < cfg.channels; i++) { - uint8_t unit = GET_UNIT(cfg.channel[i]); - uint8_t ch = cfg.channel[i] & 0x7; + uint8_t unit = GET_UNIT(cfg.adc_channels[i]); + uint8_t ch = cfg.adc_channels[i] & 0x7; adc_pattern[i].atten = cfg.adc_attenuation; adc_pattern[i].channel = ch; adc_pattern[i].unit = unit;