i2s: support esp32h2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S3 | ESP32-H2 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- |
|
||||
|
||||
# I2S Basic Standard Mode Example
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-H2 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||
|
||||
# I2S Basic Standard Mode Example
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32-C3 | ESP32-S3 |
|
||||
| ----------------- | -------- | -------- |
|
||||
| Supported Targets | ESP32-C3 | ESP32-S3 | ESP32-H2 |
|
||||
| ----------------- | -------- | -------- | -------- |
|
||||
|
||||
# I2S Basic TDM Mode Example
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 | ESP32-H2 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||
|
||||
# I2S ES8311 Example
|
||||
|
||||
@@ -41,20 +41,20 @@ For more details, see [ES8311 datasheet](http://www.everest-semi.com/pdf/ES8311%
|
||||
│ WS-GPIO 5 ├──────────►│PIN8-LRCK PIN13-OUTN├───────────┤ │
|
||||
│ │ │ │ └─────────┘
|
||||
│ SDOUT-GPIO 18├──────────►│PIN9-SDIN │
|
||||
│ │ │ │
|
||||
│ (GPIO 2)│ │ │
|
||||
│ SDIN-GPIO 19│◄──────────┤PIN7-SDOUT │
|
||||
│ │ │ │ ┌─────────┐
|
||||
│ (GPIO 3)│ │ │ ┌─────────┐
|
||||
│ │ │ PIN18-MIC1P├───────────┤ │
|
||||
│ SCL-GPIO 16├──────────►│PIN1 -CCLK │ │ MIC │
|
||||
│ (GPIO 7)│ │ PIN17-MIC1N├───────────┤ │
|
||||
│ (GPIO 6)│ │ PIN17-MIC1N├───────────┤ │
|
||||
│ SDA-GPIO 17│◄─────────►│PIN19-CDATA │ └─────────┘
|
||||
│ (GPIO 8)│ │ │
|
||||
│ (GPIO 7)│ │ │
|
||||
│ VCC 3.3├───────────┤VCC │
|
||||
│ │ │ │
|
||||
│ GND├───────────┤GND │
|
||||
└─────────────────┘ └──────────────────────────┘
|
||||
```
|
||||
Note: Since ESP32-C3 board does not have GPIO 16/17, you can use other available GPIOs instead. In this example, we set GPIO 7/8 as I2C pins for ESP32-C3 and GPIO 16/17 for other chips.
|
||||
Note: Since ESP32-C3 & ESP32-H2 board does not have GPIO 16/17, you can use other available GPIOs instead. In this example, we set GPIO 6/7 as I2C pins for ESP32-C3 & ESP32-H2 and GPIO 16/17 for other chips, same as GPIO 18/19, we use GPIO 2/3 instead.
|
||||
|
||||
### Dependency
|
||||
|
||||
@@ -123,8 +123,8 @@ If you have a logic analyzer, you can use a logic analyzer to grab GPIO signal d
|
||||
| MCLK |module clock | GPIO_NUM_0|
|
||||
| BCLK |bit clock | GPIO_NUM_4 |
|
||||
| WS |word select | GPIO_NUM_5 |
|
||||
| SDOUT |serial data out| GPIO_NUM_18 |
|
||||
| SDIN |serial data in | GPIO_NUM_19 |
|
||||
| SDOUT |serial data out| GPIO_NUM_18/2 |
|
||||
| SDIN |serial data in | GPIO_NUM_19/3 |
|
||||
|
||||
### Customize your own music
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
|
||||
/* I2C port and GPIOs */
|
||||
#define I2C_NUM (0)
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32C3
|
||||
#define I2C_SDA_IO (GPIO_NUM_17)
|
||||
#define I2C_SCL_IO (GPIO_NUM_16)
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
#define I2C_SCL_IO (GPIO_NUM_6)
|
||||
#define I2C_SDA_IO (GPIO_NUM_7)
|
||||
#else
|
||||
#define I2C_SDA_IO (GPIO_NUM_15)
|
||||
#define I2C_SCL_IO (GPIO_NUM_14)
|
||||
#define I2C_SCL_IO (GPIO_NUM_16)
|
||||
#define I2C_SDA_IO (GPIO_NUM_17)
|
||||
#endif
|
||||
|
||||
/* I2S port and GPIOs */
|
||||
@@ -28,13 +28,18 @@
|
||||
#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_ESP32H2
|
||||
#define I2S_DO_IO (GPIO_NUM_2)
|
||||
#define I2S_DI_IO (GPIO_NUM_3)
|
||||
#else
|
||||
#define I2S_DO_IO (GPIO_NUM_18)
|
||||
#define I2S_DI_IO (GPIO_NUM_19)
|
||||
|
||||
#endif
|
||||
/* Example configurations */
|
||||
#define EXAMPLE_RECV_BUF_SIZE (2048)
|
||||
#define EXAMPLE_SAMPLE_RATE (16000)
|
||||
#define EXAMPLE_MCLK_MULTIPLE (256)
|
||||
#define EXAMPLE_MCLK_FREQ_HZ (EXAMPLE_SAMPLE_RATE * EXAMPLE_MCLK_MULTIPLE)
|
||||
#define EXAMPLE_VOICE_VOLUME CONFIG_EXAMPLE_VOICE_VOLUME
|
||||
#if CONFIG_EXAMPLE_MODE_ECHO
|
||||
#define EXAMPLE_MIC_GAIN CONFIG_EXAMPLE_MIC_GAIN
|
||||
@@ -71,7 +76,10 @@ static esp_err_t es8311_codec_init(void)
|
||||
es8311_handle_t es_handle = es8311_create(I2C_NUM, ES8311_ADDRRES_0);
|
||||
ESP_RETURN_ON_FALSE(es_handle, ESP_FAIL, TAG, "es8311 create failed");
|
||||
es8311_clock_config_t es_clk = {
|
||||
.mclk_inverted = false,
|
||||
.sclk_inverted = false,
|
||||
.mclk_from_mclk_pin = true,
|
||||
.mclk_frequency = EXAMPLE_MCLK_FREQ_HZ,
|
||||
.sample_frequency = EXAMPLE_SAMPLE_RATE
|
||||
};
|
||||
|
||||
@@ -88,16 +96,17 @@ static esp_err_t es8311_codec_init(void)
|
||||
static esp_err_t i2s_driver_init(void)
|
||||
{
|
||||
i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM, I2S_ROLE_MASTER);
|
||||
chan_cfg.auto_clear = true; // Auto clear the legacy data in the DMA buffer
|
||||
ESP_ERROR_CHECK(i2s_new_channel(&chan_cfg, &tx_handle, &rx_handle));
|
||||
i2s_std_config_t std_cfg = {
|
||||
.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(EXAMPLE_SAMPLE_RATE),
|
||||
.slot_cfg = I2S_STD_PHILIP_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO),
|
||||
.gpio_cfg = {
|
||||
.mclk = GPIO_NUM_0,
|
||||
.bclk = GPIO_NUM_4,
|
||||
.ws = GPIO_NUM_5,
|
||||
.dout = GPIO_NUM_18,
|
||||
.din = GPIO_NUM_19,
|
||||
.mclk = I2S_MCK_IO,
|
||||
.bclk = I2S_BCK_IO,
|
||||
.ws = I2S_WS_IO,
|
||||
.dout = I2S_DO_IO,
|
||||
.din = I2S_DI_IO,
|
||||
.invert_flags = {
|
||||
.mclk_inv = false,
|
||||
.bclk_inv = false,
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
## IDF Component Manager Manifest File
|
||||
## Version of your project. Should conform Semantic Versioning 2.0 rules https://semver.org/
|
||||
version: "1.0.0"
|
||||
|
||||
dependencies:
|
||||
espressif/es8311: ">=0.0.2"
|
||||
espressif/es8311: "==1.0.0"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: "^5.0"
|
||||
version: ">=4.1.0"
|
||||
# # Put list of dependencies here
|
||||
# # For components maintained by Espressif:
|
||||
# component:
|
||||
# version: "~1.0.0"
|
||||
# component: "~1.0.0"
|
||||
# # For 3rd party components:
|
||||
# username/component:
|
||||
# username/component: ">=1.0.0,<2.0.0"
|
||||
# username2/component2:
|
||||
# version: "~1.0.0"
|
||||
# # For transient dependencies `public` flag can be set.
|
||||
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
|
||||
Reference in New Issue
Block a user