Refine code.

This commit is contained in:
Colin 2026-01-04 23:10:49 +08:00
parent 8ccb03d04e
commit 60f1d97871
1 changed files with 3 additions and 28 deletions

View File

@ -32,7 +32,7 @@
#define ES7210_I2C_CLK (100000)
#define ES7210_MIC_GAIN (ES7210_MIC_GAIN_30DB)
#define ES7210_MIC_BIAS (ES7210_MIC_BIAS_2V87)
#define ES7210_ADC_VOLUME (0)
#define ES7210_ADC_VOLUME (32)
/* I2S port and GPIOs */
#define I2S_NUM (0)
@ -58,13 +58,6 @@
#define I2S_SAMPLE_BITS (I2S_DATA_BIT_WIDTH_16BIT)
#define I2S_TDM_SLOT_MASK (I2S_TDM_SLOT0 | I2S_TDM_SLOT1)
/* ES7210 configurations */
#define ES7210_I2C_ADDR (0x41)
#define ES7210_I2C_CLK (100000)
#define ES7210_MIC_GAIN (ES7210_MIC_GAIN_30DB)
#define ES7210_MIC_BIAS (ES7210_MIC_BIAS_2V87)
#define ES7210_ADC_VOLUME (32)
// 配置参数
#define SAMPLE_RATE 16000
#define I2S_PORT I2S_NUM_0
@ -255,7 +248,7 @@ static void i2s_rx_task(void* arg) {
if (res != NULL) {
record_add2(res->data, res->data_size / 2);
if (res->vad_state > 0) {
printf("AFE data_size: %d\n", res->data_size / 2);
// printf("AFE data_size: %d\n", res->data_size / 2);
// printf("AFE data_volume: %f\n", res->data_volume);
// printf("AFE vad_state: %d\n", res->vad_state);
// printf("AFE ret_value: %d\n", res->ret_value);
@ -265,7 +258,7 @@ static void i2s_rx_task(void* arg) {
if (record_end1() && record_end2()) break;
vTaskDelay(10 / portTICK_PERIOD_MS);
// vTaskDelay(10 / portTICK_PERIOD_MS);
// esp_sleep_enable_timer_wakeup(10 * 1000);
// esp_light_sleep_start();
@ -348,23 +341,6 @@ static esp_err_t i2s_init(void) {
ESP_ERROR_CHECK(i2s_channel_init_tdm_mode(
rx_chan, &i2s_tdm_rx_conf)); // 初始化I2S通道为TDM模式
// // 配置STD模式
// i2s_std_config_t std_cfg = {
// .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(SAMPLE_RATE),
// .slot_cfg =
// I2S_STD_MSB_SLOT_DEFAULT_CONFIG(SAMPLE_BITS, I2S_SLOT_MODE_MONO),
// .gpio_cfg = {.mclk = I2S_GPIO_UNUSED,
// .bclk = I2S_BCK_PIN,
// .ws = I2S_WS_PIN,
// .dout = I2S_GPIO_UNUSED,
// .din = I2S_DATA_PIN,
// .invert_flags = {
// .mclk_inv = false,
// .bclk_inv = false,
// .ws_inv = false,
// }}};
// ESP_ERROR_CHECK(i2s_channel_init_std_mode(rx_chan, &std_cfg));
// 注册事件回调 - 这是DMA中断触发的回调
// i2s_event_callbacks_t callbacks = {
// .on_recv = i2s_evt_callback,
@ -373,7 +349,6 @@ static esp_err_t i2s_init(void) {
// ESP_ERROR_CHECK(
// i2s_channel_register_event_callback(rx_chan, &callbacks, NULL));
// 启用通道
ESP_ERROR_CHECK(i2s_channel_enable(rx_chan));
ESP_LOGI(TAG, "I2S初始化完成使用DMA中断");