diff --git a/examples/peripherals/i2s/i2s_codec/i2s_es8311/README.md b/examples/peripherals/i2s/i2s_codec/i2s_es8311/README.md index 79aee879b6..936964f98f 100644 --- a/examples/peripherals/i2s/i2s_codec/i2s_es8311/README.md +++ b/examples/peripherals/i2s/i2s_codec/i2s_es8311/README.md @@ -129,6 +129,11 @@ If you have a logic analyzer, you can use a logic analyzer to grab GPIO signal d | SDOUT |serial data out| GPIO_NUM_18/2 | | SDIN |serial data in | GPIO_NUM_19/3 | +Other pins like I2C please refer to `example_config.h`. + +Please note that the power amplifier on some development boards (like P4 EV board) are disabled by default, you might need to set the PA_CTRL pin to high to play the music via a speaker. +The PA_CTRL pin can be configured by `idf.py menuconfig`, please check if the PA_CTRL pin is correct on your board if the audio can only be played from the earphones but not the speaker. + ### Customize your own music The example have contained a piece of music in canon.pcm, if you want to play your own music, you can follow these steps: @@ -150,4 +155,9 @@ The example have contained a piece of music in canon.pcm, if you want to play yo * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. +* Failed to get audio from specker + + * The PA (Power Amplifier) on some dev-kits might be disabled by default, please check the schematic to see if PA_CTRL is connected to any GPIO or something. + * Pull-up the PA_CTRL pin either by setting that GPIO to high or by connecting it to 3.3V with a jump wire should help. + For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/Kconfig.projbuild b/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/Kconfig.projbuild index 4595d6e1d8..72ce831be6 100644 --- a/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/Kconfig.projbuild +++ b/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/Kconfig.projbuild @@ -56,6 +56,13 @@ menu "Example Configuration" help Set voice volume + config EXAMPLE_PA_CTRL_IO + int "Power Amplifier control IO" + default 53 if IDF_TARGET_ESP32P4 + default -1 + help + Set GPIO number for PA control. Set -1 to disable PA control. + config EXAMPLE_BSP bool "Enable Board Support Package (BSP) support" default n diff --git a/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/example_config.h b/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/example_config.h index 87f1cbfecd..5c3181c4e2 100644 --- a/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/example_config.h +++ b/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/example_config.h @@ -14,6 +14,7 @@ #define EXAMPLE_MCLK_MULTIPLE (384) // If not using 24-bit data width, 256 should be enough #define EXAMPLE_MCLK_FREQ_HZ (EXAMPLE_SAMPLE_RATE * EXAMPLE_MCLK_MULTIPLE) #define EXAMPLE_VOICE_VOLUME CONFIG_EXAMPLE_VOICE_VOLUME +#define EXAMPLE_PA_CTRL_IO CONFIG_EXAMPLE_PA_CTRL_IO #if CONFIG_EXAMPLE_MODE_ECHO #define EXAMPLE_MIC_GAIN CONFIG_EXAMPLE_MIC_GAIN #endif diff --git a/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/i2s_es8311_example.c b/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/i2s_es8311_example.c index 3abbb23efd..4b01208887 100644 --- a/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/i2s_es8311_example.c +++ b/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/i2s_es8311_example.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: CC0-1.0 */ @@ -10,6 +10,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/i2s_std.h" +#include "driver/gpio.h" #include "esp_system.h" #include "esp_check.h" #include "es8311.h" @@ -198,6 +199,17 @@ void app_main(void) } else { ESP_LOGI(TAG, "es8311 codec init success"); } + +#if EXAMPLE_PA_CTRL_IO >= 0 + /* Enable PA by setting the PA_CTRL_IO to high, because the power amplifier on some dev-kits are disabled by default */ + gpio_config_t gpio_cfg = { + .pin_bit_mask = (1ULL << EXAMPLE_PA_CTRL_IO), + .mode = GPIO_MODE_OUTPUT, + }; + ESP_ERROR_CHECK(gpio_config(&gpio_cfg)); + ESP_ERROR_CHECK(gpio_set_level(EXAMPLE_PA_CTRL_IO, 1)); +#endif + #if CONFIG_EXAMPLE_MODE_MUSIC /* Play a piece of music in music mode */ xTaskCreate(i2s_music, "i2s_music", 4096, NULL, 5, NULL);