From 4bd057013d589edf252d591193b961bfdc3d4fc9 Mon Sep 17 00:00:00 2001 From: "pedro.minatel" Date: Wed, 25 Aug 2021 11:51:27 +0100 Subject: [PATCH] Added driver unistall function for I2S --- .../i2s/i2s_audio_recorder_sdcard/main/i2s_recorder_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/peripherals/i2s/i2s_audio_recorder_sdcard/main/i2s_recorder_main.c b/examples/peripherals/i2s/i2s_audio_recorder_sdcard/main/i2s_recorder_main.c index 655ac97804..f7ad8e9ee8 100644 --- a/examples/peripherals/i2s/i2s_audio_recorder_sdcard/main/i2s_recorder_main.c +++ b/examples/peripherals/i2s/i2s_audio_recorder_sdcard/main/i2s_recorder_main.c @@ -178,7 +178,7 @@ void init_microphone(void) .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, .communication_format = I2S_COMM_FORMAT_STAND_I2S, .intr_alloc_flags = ESP_INTR_FLAG_LEVEL2, - .dma_buf_count = 8, + .dma_buf_count = 16, .dma_buf_len = 1024, .use_apll = 1, }; @@ -191,9 +191,9 @@ void init_microphone(void) .data_in_num = CONFIG_EXAMPLE_I2S_DATA_GPIO, }; + // Call driver installation function before any I2S R/W operation. ESP_ERROR_CHECK( i2s_driver_install(CONFIG_EXAMPLE_I2S_CH, &i2s_config, 0, NULL) ); ESP_ERROR_CHECK( i2s_set_pin(CONFIG_EXAMPLE_I2S_CH, &pin_config) ); - // Set the I2S clock using the sample rate divided by 2 if channel is mono ESP_ERROR_CHECK( i2s_set_clk(CONFIG_EXAMPLE_I2S_CH, (CONFIG_EXAMPLE_AUDIO_SAMPLE_RATE / 2), I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_MONO) ); } @@ -207,4 +207,6 @@ void app_main(void) ESP_LOGI(TAG, "Starting recording for %d seconds!", CONFIG_EXAMPLE_REC_TIME); // Start Recording record_wav(); + // Stop I2S driver and destroy + ESP_ERROR_CHECK( i2s_driver_uninstall(CONFIG_EXAMPLE_I2S_CH) ); }