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
@@ -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: