From 0f0baa5bb4a1ac474956d491ffbb40338a5dea37 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Mon, 5 Sep 2022 19:08:46 +0800 Subject: [PATCH 1/2] i2s: fixed the duplicated type name --- components/driver/i2s/i2s_private.h | 2 +- components/driver/include/driver/i2s_types.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/driver/i2s/i2s_private.h b/components/driver/i2s/i2s_private.h index e615be0f1d..e58b55e24f 100644 --- a/components/driver/i2s/i2s_private.h +++ b/components/driver/i2s/i2s_private.h @@ -68,7 +68,7 @@ typedef struct { int mclk; /*!< MCK out pin, shared by tx/rx*/ } i2s_controller_t; -struct i2s_channel_t { +struct i2s_channel_obj_t { /* Channel basic information */ i2s_controller_t *controller; /*!< Parent pointer to controller object */ i2s_comm_mode_t mode; /*!< i2s channel communication mode */ diff --git a/components/driver/include/driver/i2s_types.h b/components/driver/include/driver/i2s_types.h index 84cd39241b..3cd4ffa633 100644 --- a/components/driver/include/driver/i2s_types.h +++ b/components/driver/include/driver/i2s_types.h @@ -63,7 +63,7 @@ typedef struct { */ } i2s_event_data_t; -typedef struct i2s_channel_t *i2s_chan_handle_t; /*!< i2s channel handle, the control unit of the i2s driver*/ +typedef struct i2s_channel_obj_t *i2s_chan_handle_t; /*!< i2s channel object handle, the control unit of the i2s driver*/ /** * @brief I2S event callback From d836d8cf35cf04a35a0724e3f88d75a2d190b684 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Mon, 5 Sep 2022 19:10:42 +0800 Subject: [PATCH 2/2] i2s: add notes for the read task of i2s basic examples --- components/driver/i2s/i2s_common.c | 2 +- examples/peripherals/i2s/i2s_basic/i2s_pdm/main/i2s_pdm_rx.c | 3 +++ .../i2s/i2s_basic/i2s_std/main/i2s_std_example_main.c | 3 +++ .../i2s/i2s_basic/i2s_tdm/main/i2s_tdm_example_main.c | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/driver/i2s/i2s_common.c b/components/driver/i2s/i2s_common.c index 807c0fd672..3bd24a1ec7 100644 --- a/components/driver/i2s/i2s_common.c +++ b/components/driver/i2s/i2s_common.c @@ -242,7 +242,7 @@ static esp_err_t i2s_register_channel(i2s_controller_t *i2s_obj, i2s_dir_t dir, esp_err_t ret = ESP_OK; - i2s_chan_handle_t new_chan = (i2s_chan_handle_t)heap_caps_calloc(1, sizeof(struct i2s_channel_t), I2S_MEM_ALLOC_CAPS); + i2s_chan_handle_t new_chan = (i2s_chan_handle_t)heap_caps_calloc(1, sizeof(struct i2s_channel_obj_t), I2S_MEM_ALLOC_CAPS); ESP_RETURN_ON_FALSE(new_chan, ESP_ERR_NO_MEM, TAG, "No memory for new channel"); new_chan->mode = I2S_COMM_MODE_NONE; new_chan->role = I2S_ROLE_MASTER; // Set default role to master diff --git a/examples/peripherals/i2s/i2s_basic/i2s_pdm/main/i2s_pdm_rx.c b/examples/peripherals/i2s/i2s_basic/i2s_pdm/main/i2s_pdm_rx.c index 6b758b347f..dc44a3807d 100644 --- a/examples/peripherals/i2s/i2s_basic/i2s_pdm/main/i2s_pdm_rx.c +++ b/examples/peripherals/i2s/i2s_basic/i2s_pdm/main/i2s_pdm_rx.c @@ -60,6 +60,9 @@ void i2s_example_pdm_rx_task(void *args) i2s_chan_handle_t rx_chan = i2s_example_init_pdm_rx(); size_t r_bytes = 0; + /* ATTENTION: The print and delay in the read task only for monitoring the data by human, + * Normally there shouldn't be any delays to ensure a short polling time, + * Otherwise the dma buffer will overflow and lead to the data lost */ while (1) { /* Read i2s data */ if (i2s_channel_read(rx_chan, r_buf, EXAMPLE_BUFF_SIZE, &r_bytes, 1000) == ESP_OK) { diff --git a/examples/peripherals/i2s/i2s_basic/i2s_std/main/i2s_std_example_main.c b/examples/peripherals/i2s/i2s_basic/i2s_std/main/i2s_std_example_main.c index b46b41fff9..84a20b5d01 100644 --- a/examples/peripherals/i2s/i2s_basic/i2s_std/main/i2s_std_example_main.c +++ b/examples/peripherals/i2s/i2s_basic/i2s_std/main/i2s_std_example_main.c @@ -53,6 +53,9 @@ static void i2s_example_read_task(void *args) uint8_t *r_buf = (uint8_t *)calloc(1, EXAMPLE_BUFF_SIZE); assert(r_buf); // Check if r_buf allocation success size_t r_bytes = 0; + /* ATTENTION: The print and delay in the read task only for monitoring the data by human, + * Normally there shouldn't be any delays to ensure a short polling time, + * Otherwise the dma buffer will overflow and lead to the data lost */ while (1) { /* Read i2s data */ if (i2s_channel_read(rx_chan, r_buf, EXAMPLE_BUFF_SIZE, &r_bytes, 1000) == ESP_OK) { diff --git a/examples/peripherals/i2s/i2s_basic/i2s_tdm/main/i2s_tdm_example_main.c b/examples/peripherals/i2s/i2s_basic/i2s_tdm/main/i2s_tdm_example_main.c index c0c3536609..0fc04f713c 100644 --- a/examples/peripherals/i2s/i2s_basic/i2s_tdm/main/i2s_tdm_example_main.c +++ b/examples/peripherals/i2s/i2s_basic/i2s_tdm/main/i2s_tdm_example_main.c @@ -38,6 +38,9 @@ static void i2s_example_read_task(void *args) uint8_t *r_buf = (uint8_t *)calloc(1, EXAMPLE_BUFF_SIZE); assert(r_buf); // Check if r_buf allocation success size_t r_bytes = 0; + /* ATTENTION: The print and delay in the read task only for monitoring the data by human, + * Normally there shouldn't be any delays to ensure a short polling time, + * Otherwise the dma buffer will overflow and lead to the data lost */ while (1) { /* Read i2s data */ if (i2s_channel_read(rx_chan, r_buf, EXAMPLE_BUFF_SIZE, &r_bytes, 1000) == ESP_OK) {