Skip to content

Commit 1c61231

Browse files
committed
audio: replace es7210_adc_set_gain
Apparently the ESP32-S3-BOX-Lite uses different audio chips than the other ESP32-S3-BOX variants. We unconditionally call es7210_adc_set_gain() to set the MIC gain, and with ESP-ADF 2.7 and ESP-IDF 5.3, using the new I2C driver, this causes a crash due to the es7210 i2c_handle being NULL. Fix this by using audio_codec_set_volume on the ADC audio handle. Fixes: #437
1 parent d456530 commit 1c61231

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

main/audio.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "audio_pipeline.h"
55
#include "audio_thread.h"
66
#include "board.h"
7-
#include "es7210.h"
87
#include "esp_check.h"
98
#include "esp_decoder.h"
109
#include "esp_http_client.h"
@@ -1023,7 +1022,7 @@ void init_adc(void)
10231022
};
10241023

10251024
hdl_aha->audio_codec_config_iface(AUDIO_HAL_CODEC_MODE_ENCODE, &cfg_i2s);
1026-
es7210_adc_set_gain(ES7210_MIC_SELECT, config_get_int("mic_gain", DEFAULT_MIC_GAIN));
1025+
hdl_aha->audio_codec_set_volume(config_get_int("mic_gain", DEFAULT_MIC_GAIN));
10271026
}
10281027

10291028
esp_err_t init_audio(void)
@@ -1052,7 +1051,7 @@ esp_err_t init_audio(void)
10521051
}
10531052
free(speech_rec_mode);
10541053
ESP_RETURN_ON_ERROR(start_rec(), TAG, "start_rec failed");
1055-
es7210_adc_set_gain(ES7210_MIC_SELECT, config_get_int("mic_gain", DEFAULT_MIC_GAIN));
1054+
hdl_aha->audio_codec_set_volume(config_get_int("mic_gain", DEFAULT_MIC_GAIN));
10561055

10571056
ESP_LOGI(TAG, "app_main() - start_rec() finished");
10581057

main/shared.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22
#define DEFAULT_MIC_GAIN 14
33
#define DEFAULT_SPEECH_REC_MODE "WIS"
44
#define DEFAULT_WAS_MODE false
5-
6-
#ifndef ES7210_MIC_SELECT
7-
#define ES7210_MIC_SELECT (ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2)
8-
#endif

0 commit comments

Comments
 (0)