From 6625e2edf23f5f09db96fc94c4ddef660ee38411 Mon Sep 17 00:00:00 2001 From: Andry Date: Sat, 22 Apr 2023 11:31:26 +0300 Subject: [PATCH] Add I2S_MODE_ADC_BUILT_IN support to i2s_stream.c --- components/audio_stream/i2s_stream.c | 4 ++++ components/audio_stream/include/i2s_stream.h | 1 + 2 files changed, 5 insertions(+) diff --git a/components/audio_stream/i2s_stream.c b/components/audio_stream/i2s_stream.c index c4c03cb7a..e7594afdb 100644 --- a/components/audio_stream/i2s_stream.c +++ b/components/audio_stream/i2s_stream.c @@ -389,6 +389,10 @@ audio_element_handle_t i2s_stream_init(i2s_stream_cfg_t *config) #if SOC_I2S_SUPPORTS_ADC_DAC if ((config->i2s_config.mode & I2S_MODE_DAC_BUILT_IN) != 0) { i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN); + } else if ((config->i2s_config.mode & I2S_MODE_ADC_BUILT_IN) != 0) { + i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_7); + adc1_config_channel_atten(ADC1_CHANNEL_7, i2s->config.adc_atten_db); + i2s_adc_enable(i2s->config.i2s_port); } else #endif { diff --git a/components/audio_stream/include/i2s_stream.h b/components/audio_stream/include/i2s_stream.h index 3fb2445a2..dcb5e14ac 100644 --- a/components/audio_stream/include/i2s_stream.h +++ b/components/audio_stream/include/i2s_stream.h @@ -53,6 +53,7 @@ typedef struct { bool uninstall_drv; /*!< whether uninstall the i2s driver when stream destroyed*/ bool need_expand; /*!< whether to expand i2s data */ i2s_bits_per_sample_t expand_src_bits; /*!< The source bits per sample when data expand */ + int adc_atten_db; } i2s_stream_cfg_t; #define I2S_STREAM_TASK_STACK (3072+512)