Skip to content

Commit 263a056

Browse files
committed
feat: add i2s & etm sleep retention entry on H4
1 parent 424991f commit 263a056

File tree

31 files changed

+317
-233
lines changed

31 files changed

+317
-233
lines changed

components/esp_driver_i2s/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ endif()
3737
idf_component_register(SRCS ${srcs}
3838
INCLUDE_DIRS ${include}
3939
PRIV_REQUIRES esp_driver_gpio esp_pm esp_mm
40+
LDFRAGMENTS linker.lf
4041
)

components/esp_driver_i2s/i2s_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ uint32_t i2s_get_source_clk_freq(i2s_clock_src_t clk_src, uint32_t mclk_freq_hz)
575575
}
576576

577577
#if SOC_GDMA_SUPPORTED
578-
static bool IRAM_ATTR i2s_dma_rx_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data)
578+
static bool i2s_dma_rx_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data)
579579
{
580580
i2s_chan_handle_t handle = (i2s_chan_handle_t)user_data;
581581
BaseType_t need_yield1 = 0;
@@ -606,7 +606,7 @@ static bool IRAM_ATTR i2s_dma_rx_callback(gdma_channel_handle_t dma_chan, gdma_e
606606
return need_yield1 | need_yield2 | user_need_yield;
607607
}
608608

609-
static bool IRAM_ATTR i2s_dma_tx_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data)
609+
static bool i2s_dma_tx_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data)
610610
{
611611
i2s_chan_handle_t handle = (i2s_chan_handle_t)user_data;
612612
BaseType_t need_yield1 = 0;
@@ -653,7 +653,7 @@ static bool IRAM_ATTR i2s_dma_tx_callback(gdma_channel_handle_t dma_chan, gdma_e
653653

654654
#else
655655

656-
static void IRAM_ATTR i2s_dma_rx_callback(void *arg)
656+
static void i2s_dma_rx_callback(void *arg)
657657
{
658658
BaseType_t need_yield1 = 0;
659659
BaseType_t need_yield2 = 0;
@@ -691,7 +691,7 @@ static void IRAM_ATTR i2s_dma_rx_callback(void *arg)
691691
}
692692
}
693693

694-
static void IRAM_ATTR i2s_dma_tx_callback(void *arg)
694+
static void i2s_dma_tx_callback(void *arg)
695695
{
696696
BaseType_t need_yield1 = 0;
697697
BaseType_t need_yield2 = 0;
@@ -1485,7 +1485,7 @@ void i2s_sync_reset_fifo_count(i2s_chan_handle_t tx_handle)
14851485
}
14861486
#endif // SOC_I2S_SUPPORTS_TX_SYNC_CNT
14871487

1488-
#if SOC_I2S_SUPPORTS_ETM_SYNC
1488+
#if SOC_I2S_SUPPORTS_TX_FIFO_SYNC
14891489
uint32_t i2s_sync_get_fifo_sync_diff_count(i2s_chan_handle_t tx_handle)
14901490
{
14911491
return i2s_ll_tx_get_fifo_sync_diff_count(tx_handle->controller->hal.dev);

components/esp_driver_i2s/i2s_etm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ esp_err_t i2s_new_etm_task(i2s_chan_handle_t handle, const i2s_etm_task_config_t
8484
{
8585
ESP_RETURN_ON_FALSE(handle && config && out_task, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
8686
ESP_RETURN_ON_FALSE(config->task_type < I2S_ETM_TASK_MAX, ESP_ERR_INVALID_ARG, TAG, "invalid task type");
87-
#if SOC_I2S_SUPPORTS_ETM_SYNC
88-
ESP_RETURN_ON_FALSE(config->task_type != I2S_ETM_TASK_SYNC_CHECK || handle->dir == I2S_DIR_TX,
89-
ESP_ERR_NOT_SUPPORTED, TAG, "rx is not supported");
87+
#if SOC_I2S_SUPPORTS_TX_FIFO_SYNC
88+
ESP_RETURN_ON_FALSE(config->task_type != I2S_ETM_TASK_SYNC_FIFO || handle->dir == I2S_DIR_TX,
89+
ESP_ERR_NOT_SUPPORTED, TAG, "rx does not support sync check");
9090
#endif
9191

9292
i2s_etm_task_t *task = heap_caps_calloc(1, sizeof(i2s_etm_task_t), ETM_MEM_ALLOC_CAPS);

components/esp_driver_i2s/include/esp_private/i2s_sync.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <stdint.h>
2323
#include "driver/i2s_types.h"
24+
#include "esp_err.h"
2425

2526
#ifdef __cplusplus
2627
extern "C" {
@@ -31,7 +32,7 @@ extern "C" {
3132
/**
3233
* @brief Get the counter number of BCLK ticks
3334
* @note The BCLK tick count reflects the real data that have sent on line
34-
* @note It will be reset automatically when `I2S_ETM_TASK_SYNC_CHECK` is triggered
35+
* @note It will be reset automatically when `I2S_ETM_TASK_SYNC_FIFO` is triggered
3536
*
3637
* @param[in] tx_handle The I2S tx channel handle
3738
* @return
@@ -44,7 +45,7 @@ uint32_t i2s_sync_get_bclk_count(i2s_chan_handle_t tx_handle);
4445
* @note The FIFO count reflects how many slots have processed
4546
* Normally, fifo_cnt = slot_bit_width * bclk_cnt
4647
* If fifo_cnt < slot_bit_width * bclk_cnt, that means some data are still stuck in the I2S controller
47-
* @note It will be reset automatically when `I2S_ETM_TASK_SYNC_CHECK` is triggered
48+
* @note It will be reset automatically when `I2S_ETM_TASK_SYNC_FIFO` is triggered
4849
*
4950
* @param[in] tx_handle The I2S tx channel handle
5051
* @return
@@ -68,7 +69,7 @@ void i2s_sync_reset_fifo_count(i2s_chan_handle_t tx_handle);
6869

6970
#endif // SOC_I2S_SUPPORTS_TX_SYNC_CNT
7071

71-
#if SOC_I2S_SUPPORTS_ETM_SYNC
72+
#if SOC_I2S_SUPPORTS_TX_FIFO_SYNC
7273
/**
7374
* @brief I2S hardware FIFO synchronization supplement mode
7475
* @note When the FIFO sync difference count is out of threshold, the hardware will supplement data automatically

components/esp_driver_i2s/linker.lf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
[mapping:i2s_driver]
22
archive: libesp_driver_i2s.a
33
entries:
4+
if I2S_ISR_IRAM_SAFE = y:
5+
i2s_common: i2s_dma_rx_callback (noflash)
6+
i2s_common: i2s_dma_tx_callback (noflash)
47
if I2S_CTRL_FUNC_IN_IRAM = y:
58
if SOC_I2S_SUPPORTS_TX_SYNC_CNT = y:
69
i2s_common: i2s_sync_get_bclk_count (noflash)
710
i2s_common: i2s_sync_get_fifo_count (noflash)
811
i2s_common: i2s_sync_reset_bclk_count (noflash)
912
i2s_common: i2s_sync_reset_fifo_count (noflash)
10-
if SOC_I2S_SUPPORTS_ETM_SYNC = y:
13+
if SOC_I2S_SUPPORTS_TX_FIFO_SYNC = y:
1114
i2s_common: i2s_sync_get_fifo_sync_diff_count (noflash)
1215
i2s_common: i2s_sync_reset_fifo_sync_diff_count (noflash)
1316
i2s_common: i2s_sync_enable_hw_fifo_sync (noflash)

components/esp_driver_i2s/test_apps/i2s/sdkconfig.ci.iram_safe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CONFIG_COMPILER_DUMP_RTL_FILES=y
22
CONFIG_I2S_ISR_IRAM_SAFE=y
3+
CONFIG_I2S_CTRL_FUNC_IN_IRAM=y
34
CONFIG_COMPILER_OPTIMIZATION_NONE=y
45
# silent the error check, as the error string are stored in rodata, causing RTL check failure
56
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y

components/hal/esp32h4/include/hal/i2s_ll.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ extern "C" {
6060
[I2S_DIR_RX - 1] = { \
6161
[I2S_ETM_TASK_START] = I2S0_TASK_START_RX, \
6262
[I2S_ETM_TASK_STOP] = I2S0_TASK_STOP_RX, \
63-
[I2S_ETM_TASK_SYNC_CHECK] = -1, \
63+
[I2S_ETM_TASK_SYNC_FIFO] = -1, \
6464
}, \
6565
[I2S_DIR_TX - 1] = { \
6666
[I2S_ETM_TASK_START] = I2S0_TASK_START_TX, \
6767
[I2S_ETM_TASK_STOP] = I2S0_TASK_STOP_TX, \
68-
[I2S_ETM_TASK_SYNC_CHECK] = I2S0_TASK_SYNC_CHECK, \
68+
[I2S_ETM_TASK_SYNC_FIFO] = I2S0_TASK_SYNC_CHECK, \
6969
}}}[i2s_port][(chan_dir) - 1][task]
7070
#define I2S_LL_ETM_MAX_THRESH_NUM (0x3FFFUL)
7171

@@ -1344,7 +1344,7 @@ static inline void i2s_ll_tx_set_hw_fifo_sync_static_suppl_data(i2s_dev_t *hw, u
13441344
* @brief Set the TX ETM synchronization ideal count
13451345
*
13461346
* @param hw Peripheral I2S hardware instance address.
1347-
* @param ideal_cnt The ideal FIFO count when I2S_ETM_TASK_SYNC_CHECK triggered.
1347+
* @param ideal_cnt The ideal FIFO count when I2S_ETM_TASK_SYNC_FIFO triggered.
13481348
*/
13491349
__attribute__((always_inline))
13501350
static inline void i2s_ll_tx_set_etm_sync_ideal_cnt(i2s_dev_t *hw, uint32_t ideal_cnt)

components/hal/include/hal/i2s_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ typedef enum {
233233
typedef enum {
234234
I2S_ETM_TASK_START, /*!< Start the I2S channel */
235235
I2S_ETM_TASK_STOP, /*!< Stop the I2S channel */
236-
#if SOC_I2S_SUPPORTS_ETM_SYNC
237-
I2S_ETM_TASK_SYNC_CHECK, /*!< Check the I2S TX channel sync status */
236+
#if SOC_I2S_SUPPORTS_TX_FIFO_SYNC
237+
I2S_ETM_TASK_SYNC_FIFO, /*!< Check the I2S TX channel sync status */
238238
#endif
239239
I2S_ETM_TASK_MAX, /*!< Maximum number of tasks */
240240
} i2s_etm_task_type_t;

components/soc/esp32/register/soc/i2s_reg.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#ifndef _SOC_I2S_REG_H_
7-
#define _SOC_I2S_REG_H_
6+
#pragma once
87

98
#include "soc/soc.h"
109

11-
#define REG_I2S_BASE( i ) ( DR_REG_I2S_BASE + ((i)*0x1E000))
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
1213

14+
#define REG_I2S_BASE( i ) ( DR_REG_I2S_BASE + ((i)*0x1E000))
1315

1416
#define I2S_CONF_REG(i) (REG_I2S_BASE(i) + 0x0008)
1517
/* I2S_SIG_LOOPBACK : R/W ;bitpos:[18] ;default: 1'b0 ; */
@@ -1511,7 +1513,6 @@
15111513
#define I2S_I2SDATE_V 0xFFFFFFFF
15121514
#define I2S_I2SDATE_S 0
15131515

1514-
1515-
1516-
1517-
#endif /*_SOC_I2S_REG_H_ */
1516+
#ifdef __cplusplus
1517+
}
1518+
#endif

components/soc/esp32c3/include/soc/soc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#define REG_UART_BASE(i) (DR_REG_UART_BASE + (i) * 0x10000)
2121
#define REG_UART_AHB_BASE(i) (0x60000000 + (i) * 0x10000)
2222
#define UART_FIFO_AHB_REG(i) (REG_UART_AHB_BASE(i) + 0x0)
23-
#define REG_I2S_BASE(i) (DR_REG_I2S_BASE) // only one I2S on C3
2423
#define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i)*0x1000)
2524
#define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000)
2625
#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (0)) // only one GPSPI

0 commit comments

Comments
 (0)