mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-15 19:34:03 +00:00
feat(i2c_master): Support i2c sleep retention on esp32c5/p4/c61
This commit is contained in:
@@ -25,13 +25,10 @@ if(CONFIG_SOC_LP_I2C_SUPPORTED)
|
||||
list(APPEND srcs "test_lp_i2c.c")
|
||||
endif()
|
||||
|
||||
# Only build this file with `CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP` and `CONFIG_IEEE802154_ENABLED` enabled
|
||||
# Enable `CONFIG_IEEE802154_ENABLED` is for modem domain really power down.
|
||||
# This reliable can be removed if the sleep retention got finished.
|
||||
if(CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP AND CONFIG_IEEE802154_ENABLED)
|
||||
if(CONFIG_SOC_I2C_SUPPORT_SLEEP_RETENTION)
|
||||
list(APPEND srcs "test_i2c_sleep_retention.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity driver test_utils ieee802154
|
||||
PRIV_REQUIRES unity driver test_utils
|
||||
WHOLE_ARCHIVE)
|
||||
|
||||
@@ -43,6 +43,7 @@ static void i2c_master_write_sleep_retention_test(void)
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.flags.allow_pd = true,
|
||||
};
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
@@ -68,7 +69,9 @@ static void i2c_master_write_sleep_retention_test(void)
|
||||
TEST_ESP_OK(i2c_master_transmit(dev_handle, data_wr, DATA_LENGTH, -1));
|
||||
unity_wait_for_signal("i2c slave receive once, master to sleep");
|
||||
|
||||
#if ESP_SLEEP_POWER_DOWN_CPU
|
||||
TEST_ESP_OK(sleep_cpu_configure(true));
|
||||
#endif
|
||||
TEST_ESP_OK(esp_sleep_enable_timer_wakeup(3 * 1000 * 1000));
|
||||
TEST_ESP_OK(esp_light_sleep_start());
|
||||
|
||||
@@ -84,7 +87,9 @@ static void i2c_master_write_sleep_retention_test(void)
|
||||
unity_send_signal("master write again");
|
||||
|
||||
unity_wait_for_signal("ready to delete");
|
||||
#if ESP_SLEEP_POWER_DOWN_CPU
|
||||
TEST_ESP_OK(sleep_cpu_configure(false));
|
||||
#endif
|
||||
TEST_ESP_OK(i2c_master_bus_rm_device(dev_handle));
|
||||
|
||||
TEST_ESP_OK(i2c_del_master_bus(bus_handle));
|
||||
@@ -103,6 +108,7 @@ static void i2c_slave_read_sleep_retention_test(void)
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
.flags.allow_pd = true,
|
||||
};
|
||||
|
||||
i2c_slave_dev_handle_t slave_handle;
|
||||
@@ -128,7 +134,9 @@ static void i2c_slave_read_sleep_retention_test(void)
|
||||
|
||||
unity_send_signal("i2c slave receive once, master to sleep");
|
||||
// Slave sleep as well..
|
||||
#if ESP_SLEEP_POWER_DOWN_CPU
|
||||
TEST_ESP_OK(sleep_cpu_configure(true));
|
||||
#endif
|
||||
TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000));
|
||||
TEST_ESP_OK(esp_light_sleep_start());
|
||||
|
||||
@@ -147,7 +155,9 @@ static void i2c_slave_read_sleep_retention_test(void)
|
||||
|
||||
vQueueDelete(s_receive_queue);
|
||||
unity_send_signal("ready to delete");
|
||||
#if ESP_SLEEP_POWER_DOWN_CPU
|
||||
TEST_ESP_OK(sleep_cpu_configure(false));
|
||||
#endif
|
||||
TEST_ESP_OK(i2c_del_slave_device(slave_handle));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ def test_i2c(dut: Dut) -> None:
|
||||
'count, config',
|
||||
[
|
||||
(2, 'defaults',),
|
||||
(2, 'release',),
|
||||
(2, 'iram_safe',),
|
||||
],
|
||||
indirect=True
|
||||
)
|
||||
@@ -38,19 +40,3 @@ def test_i2c_multi_device(case_tester) -> None: # type: ignore
|
||||
for case in case_tester.test_menu:
|
||||
if case.attributes.get('test_env', 'generic_multi_device') == 'generic_multi_device':
|
||||
case_tester.run_multi_dev_case(case=case, reset=True)
|
||||
|
||||
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32h2
|
||||
@pytest.mark.generic_multi_device
|
||||
@pytest.mark.parametrize(
|
||||
'count, config',
|
||||
[
|
||||
(2, 'sleep_retention',),
|
||||
],
|
||||
indirect=True
|
||||
)
|
||||
def test_i2c_sleep_retention(case_tester) -> None: # type: ignore
|
||||
for case in case_tester.test_menu:
|
||||
if case.attributes.get('test_env', 'generic_multi_device') == 'generic_multi_device':
|
||||
case_tester.run_multi_dev_case(case=case, reset=True, timeout=250)
|
||||
|
||||
@@ -2,5 +2,6 @@ CONFIG_PM_ENABLE=y
|
||||
CONFIG_COMPILER_DUMP_RTL_FILES=y
|
||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_NONE=y
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
||||
CONFIG_I2C_ISR_IRAM_SAFE=y
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CONFIG_PM_ENABLE=y
|
||||
CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y
|
||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
CONFIG_PM_ENABLE=y
|
||||
CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
|
||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||
CONFIG_IEEE802154_ENABLED=y
|
||||
CONFIG_IEEE802154_SLEEP_ENABLE=y
|
||||
Reference in New Issue
Block a user