Skip to content

Commit

Permalink
Arduino ESP32 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 12, 2023
1 parent 0363803 commit 6a1ae1b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/AudioAnalog/AnalogAudioBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions src/AudioAnalog/AnalogAudioESP32V1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 6a1ae1b

Please sign in to comment.