i2s: support on esp32c6

This commit is contained in:
laokaiyao
2022-11-14 16:28:00 +08:00
parent f080d647cc
commit 3b4ec64f26
24 changed files with 41 additions and 42 deletions
@@ -43,9 +43,6 @@ examples/peripherals/i2s/i2s_adc_dac:
examples/peripherals/i2s/i2s_basic/i2s_pdm:
disable:
- if: SOC_I2S_SUPPORTS_PDM != 1
- if: IDF_TARGET == "esp32c6"
temporary: true
reason: target esp32c6 is not supported yet
examples/peripherals/i2s/i2s_basic/i2s_std:
disable:
@@ -58,16 +55,10 @@ examples/peripherals/i2s/i2s_basic/i2s_tdm:
examples/peripherals/i2s/i2s_codec/i2s_es7210_tdm:
disable:
- if: SOC_I2S_SUPPORTS_TDM != 1
- if: IDF_TARGET == "esp32c6"
temporary: true
reason: target esp32c6 is not supported yet
examples/peripherals/i2s/i2s_codec/i2s_es8311:
disable:
- if: SOC_I2S_SUPPORTED != 1
- if: IDF_TARGET == "esp32c6"
temporary: true
reason: target esp32c6 is not supported yet
examples/peripherals/i2s/i2s_recorder:
enable:
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- |
# I2S Basic PDM Mode Example
@@ -13,7 +13,7 @@ This example is going to show how to use the PDM TX and RX mode.
#### General
* A development board with any one of ESP32, ESP32-C3 or ESP32-S3 SoC
* A development board with any supported Espressif SOC chip (see `Supported Targets` table above)
* A USB cable for power supply and programming
#### PDM RX
@@ -8,13 +8,13 @@ menu "I2S PDM Example Configuration"
config EXAMPLE_PDM_TX
bool "PDM TX"
depends on SOC_I2S_SUPPORTS_PDM_TX
help
PDM TX example will play 'twinkle twinkle little star' in three tones.
config EXAMPLE_PDM_RX
bool "PDM RX"
# ESP32-C3 not support PDM RX for now, its hardware does not fully supported PDM RX mode
depends on !IDF_TARGET_ESP32C3
depends on SOC_I2S_SUPPORTS_PDM_RX
help
PDM RX example will show the received data from a PDM microphone.
endchoice
@@ -98,7 +98,7 @@ void i2s_example_pdm_tx_task(void *args)
}
}
cnt++;
/* If finished played, switch the tone level */
/* If finished playing, switch the tone level */
if (cnt == sizeof(song)) {
cnt = 0;
tone_select++;
@@ -8,6 +8,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32
@pytest.mark.esp32s3
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
@@ -11,12 +11,12 @@ This example is going to show how to use the standard mode in simplex mode or fu
### Hardware Required
* A development board with any one of ESP32, ESP32-S2, ESP32-C3 or ESP32-S3 SoC
* A development board with any supported Espressif SOC chip (see `Supported Targets` table above)
* A USB cable for power supply and programming
### Configure the Project
There are simplex mode and duplex mode can be chosen in this example, you can choose the mode in the menuconfig or just setting `EXAMPLE_I2S_DUPLEX_MODE` derectly, when `EXAMPLE_I2S_DUPLEX_MODE` is `0` the example will adopt the simplex mode, otherwise it will adopt the full-duplex mode.
There are simplex mode and duplex mode can be chosen in this example, you can choose the mode in the menuconfig or just setting `EXAMPLE_I2S_DUPLEX_MODE` directly, when `EXAMPLE_I2S_DUPLEX_MODE` is `0` the example will adopt the simplex mode, otherwise it will adopt the full-duplex mode.
Note that ESP32-S2 simplex mode is not available because this example requires both TX & RX channels, however, ESP32-S2 has only one I2S controller and the simplex TX & RX channels can't coexist in a same controller. By the way, the simplex TX & RX channels can't coexist on ESP32 as well, but ESP32 has two I2S controllers so the simplex TX & RX channels can be registered on the different I2S controllers.
@@ -144,7 +144,7 @@ static void i2s_example_init_std_simplex(void)
* The default configuration can be generated by the helper macro,
* it only requires the I2S controller id and I2S role
* The tx and rx channels here are registered on different I2S controller,
* only ESP32-C3, ESP32-S3 and ESP32-H4 allow to register two separate tx & rx channels on a same controller */
* Except ESP32 and ESP32-S2, others allow to register two separate tx & rx channels on a same controller */
i2s_chan_config_t tx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
ESP_ERROR_CHECK(i2s_new_channel(&tx_chan_cfg, &tx_chan, NULL));
i2s_chan_config_t rx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
@@ -9,6 +9,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.generic
def test_i2s_basic_example(dut: Dut) -> None:
@@ -11,7 +11,7 @@ This example is going to show how to use the TDM mode in simplex mode or full-du
### Hardware Required
* A development board with any one of ESP32-C3 or ESP32-S3 SoC
* A development board with any supported Espressif SOC chip (see `Supported Targets` table above)
* A USB cable for power supply and programming
### Configure the Project
@@ -120,8 +120,8 @@ static void i2s_example_init_tdm_duplex(void)
},
},
};
/* While there are more than two slots activated, receiving data might be wrong if the mclk multiple is too samll
* The driver will increasing the multiple automatically to ensure the bclk_div bigger than 2.
/* While there are more than two slots activated, receiving data might be wrong if the mclk multiple is too small
* The driver will increasing the multiple automatically to ensure the bclk_div is greater than 2.
* Modify the mclk_multiple to 512 directly here to avoid the warning */
tdm_cfg.clk_cfg.mclk_multiple = I2S_MCLK_MULTIPLE_512;
@@ -184,8 +184,8 @@ static void i2s_example_init_tdm_simplex(void)
},
},
};
/* While there are more than two slots activated, receiving data might be wrong if the mclk multiple is too samll
* The driver will increasing the multiple automatically to ensure the bclk_div bigger than 2.
/* While there are more than two slots activated, receiving data might be wrong if the mclk multiple is too small
* The driver will increasing the multiple automatically to ensure the bclk_div is greater than 2.
* Modify the mclk_multiple to 512 directly here to avoid the warning */
rx_tdm_cfg.clk_cfg.mclk_multiple = I2S_MCLK_MULTIPLE_512;
ESP_ERROR_CHECK(i2s_channel_init_tdm_mode(rx_chan, &rx_tdm_cfg));
@@ -7,6 +7,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32s3
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.generic
def test_i2s_tdm_example(dut: Dut) -> None:
@@ -1,5 +1,5 @@
| Supported Targets | ESP32-C3 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-C3 | ESP32-C6 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# I2S TDM Example -- ES7210 4-Ch ADC Codec
@@ -30,7 +30,7 @@
#define EXAMPLE_SD_SPI_MOSI_IO (17)
#define EXAMPLE_SD_SPI_MISO_IO (16)
#define EXAMPLE_SD_SPI_CS_IO (15)
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#else
#define EXAMPLE_I2C_NUM (0)
#define EXAMPLE_I2C_SDA_IO (3)
#define EXAMPLE_I2C_SCL_IO (2)
@@ -6,6 +6,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32s3
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.generic
def test_i2s_es7210_tdm_example(dut: Dut) -> None:
dut.expect_exact('example: Create I2S receive channel')
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |
# I2S ES8311 Example
@@ -25,7 +25,7 @@ For more details, see [ES8311 datasheet](http://www.everest-semi.com/pdf/ES8311%
### Hardware Required
* An ESP development board that support I2S.
* A development board with any supported Espressif SOC chip (see `Supported Targets` table above)
* A USB cable for power supply and programming.
* A board with ES8311 codec, mic and earphone interface(e.g. ESP-LyraT-8311A extension board).
@@ -15,12 +15,12 @@
/* I2C port and GPIOs */
#define I2C_NUM (0)
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H4
#define I2C_SCL_IO (GPIO_NUM_6)
#define I2C_SDA_IO (GPIO_NUM_7)
#else
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
#define I2C_SCL_IO (GPIO_NUM_16)
#define I2C_SDA_IO (GPIO_NUM_17)
#else
#define I2C_SCL_IO (GPIO_NUM_6)
#define I2C_SDA_IO (GPIO_NUM_7)
#endif
/* I2S port and GPIOs */
@@ -28,12 +28,12 @@
#define I2S_MCK_IO (GPIO_NUM_0)
#define I2S_BCK_IO (GPIO_NUM_4)
#define I2S_WS_IO (GPIO_NUM_5)
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H4
#define I2S_DO_IO (GPIO_NUM_2)
#define I2S_DI_IO (GPIO_NUM_3)
#else
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
#define I2S_DO_IO (GPIO_NUM_18)
#define I2S_DI_IO (GPIO_NUM_19)
#else
#define I2S_DO_IO (GPIO_NUM_2)
#define I2S_DI_IO (GPIO_NUM_3)
#endif
/* Example configurations */
#define EXAMPLE_RECV_BUF_SIZE (2400)
@@ -9,6 +9,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.generic
def test_i2s_es8311_example_generic(dut: Dut) -> None:
dut.expect('i2s es8311 codec example start')