From 1bb0c2c723b7b098f44bf3538a774873847ef847 Mon Sep 17 00:00:00 2001 From: xiaqilin Date: Mon, 19 Jun 2023 19:21:15 +0800 Subject: [PATCH] ieee802154: change light sleep config in ieee802154 --- components/ieee802154/Kconfig | 1 + components/ieee802154/driver/esp_ieee802154_dev.c | 12 ++++++------ .../private_include/esp_openthread_sleep.h | 2 +- components/openthread/src/esp_openthread.cpp | 9 ++++----- .../openthread/src/port/esp_openthread_sleep.c | 4 ++-- examples/openthread/README.md | 2 +- examples/openthread/ot_sleepy_device/partitions.csv | 1 - 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/components/ieee802154/Kconfig b/components/ieee802154/Kconfig index 6b01de4e72..981945e50c 100644 --- a/components/ieee802154/Kconfig +++ b/components/ieee802154/Kconfig @@ -76,6 +76,7 @@ menu "IEEE 802.15.4" config IEEE802154_SLEEP_ENABLE + # Todo: Remove when support safe power-down of the power domain (IDF-7317) bool "Enable IEEE802154 light sleep" depends on PM_ENABLE && PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP default n diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index 50a13a2710..27c95a3a69 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -26,7 +26,7 @@ #include "esp_attr.h" #include "esp_phy_init.h" -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE #include "esp_pm.h" #include "esp_private/esp_clk.h" #include "esp_private/sleep_retention.h" @@ -735,7 +735,7 @@ esp_err_t ieee802154_receive_at(uint32_t time) static esp_err_t ieee802154_sleep_init(void) { esp_err_t err = ESP_OK; -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE #define N_REGS_IEEE802154() (((IEEE802154_MAC_DATE_REG - IEEE802154_REG_BASE) / 4) + 1) const static sleep_retention_entries_config_t ieee802154_mac_regs_retention[] = { [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_IEEE802154_LINK(0x00), IEEE802154_REG_BASE, IEEE802154_REG_BASE, N_REGS_IEEE802154(), 0, 0), .owner = ENTRY(3) }, @@ -750,24 +750,24 @@ static esp_err_t ieee802154_sleep_init(void) IRAM_ATTR void ieee802154_enter_sleep(void) { -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE esp_phy_disable(); #if SOC_PM_RETENTION_HAS_CLOCK_BUG sleep_retention_do_extra_retention(true);// backup #endif ieee802154_disable(); // IEEE802154 CLOCK Disable -#endif // CONFIG_IEEE802154_SLEEP_ENABLE +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE } IRAM_ATTR void ieee802154_wakeup(void) { -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE ieee802154_enable(); // IEEE802154 CLOCK Enable #if SOC_PM_RETENTION_HAS_CLOCK_BUG sleep_retention_do_extra_retention(false);// restore #endif esp_phy_enable(); -#endif //CONFIG_IEEE802154_SLEEP_ENABLE +#endif //CONFIG_FREERTOS_USE_TICKLESS_IDLE } esp_err_t ieee802154_sleep(void) diff --git a/components/openthread/private_include/esp_openthread_sleep.h b/components/openthread/private_include/esp_openthread_sleep.h index bae2913d4f..0a1bad56ca 100644 --- a/components/openthread/private_include/esp_openthread_sleep.h +++ b/components/openthread/private_include/esp_openthread_sleep.h @@ -12,7 +12,7 @@ extern "C" { #endif -#ifdef CONFIG_IEEE802154_SLEEP_ENABLE +#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE /** * @brief This function initializes the OpenThread sleep. * diff --git a/components/openthread/src/esp_openthread.cpp b/components/openthread/src/esp_openthread.cpp index adac293f63..00f1992b5a 100644 --- a/components/openthread/src/esp_openthread.cpp +++ b/components/openthread/src/esp_openthread.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,6 @@ #include "openthread/tasklet.h" #include "openthread/thread.h" - static int hex_digit_to_int(char hex) { if ('A' <= hex && hex <= 'F') { @@ -60,7 +59,7 @@ esp_err_t esp_openthread_init(const esp_openthread_platform_config_t *config) { ESP_RETURN_ON_ERROR(esp_openthread_platform_init(config), OT_PLAT_LOG_TAG, "Failed to initialize OpenThread platform driver"); -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE ESP_RETURN_ON_ERROR(esp_openthread_sleep_init(), OT_PLAT_LOG_TAG, "Failed to initialize OpenThread esp pm_lock"); #endif @@ -160,7 +159,7 @@ esp_err_t esp_openthread_launch_mainloop(void) mainloop.timeout.tv_sec = 0; mainloop.timeout.tv_usec = 0; } -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE esp_openthread_sleep_process(); #endif esp_openthread_lock_release(); @@ -168,7 +167,7 @@ esp_err_t esp_openthread_launch_mainloop(void) if (select(mainloop.max_fd + 1, &mainloop.read_fds, &mainloop.write_fds, &mainloop.error_fds, &mainloop.timeout) >= 0) { esp_openthread_lock_acquire(portMAX_DELAY); -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE esp_openthread_wakeup_process(); #endif error = esp_openthread_platform_process(instance, &mainloop); diff --git a/components/openthread/src/port/esp_openthread_sleep.c b/components/openthread/src/port/esp_openthread_sleep.c index c4a1361b31..e59a45b898 100644 --- a/components/openthread/src/port/esp_openthread_sleep.c +++ b/components/openthread/src/port/esp_openthread_sleep.c @@ -8,7 +8,7 @@ #include "esp_check.h" #include "esp_ieee802154.h" -#if CONFIG_IEEE802154_SLEEP_ENABLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE #include "esp_pm.h" static esp_pm_lock_handle_t s_pm_lock = NULL; static const char* TAG = "esp openthread sleep"; @@ -48,4 +48,4 @@ void esp_openthread_wakeup_process(void) s_ot_sleep = false; } } -#endif // CONFIG_IEEE802154_SLEEP_ENABLE +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE diff --git a/examples/openthread/README.md b/examples/openthread/README.md index 459adf65c2..b8c16cf36f 100644 --- a/examples/openthread/README.md +++ b/examples/openthread/README.md @@ -12,4 +12,4 @@ In this folder, it contains following OpenThread examples: * [ot_br](ot_br) is an [OpenThread Border Router](https://openthread.io/guides/border-router) example. It runs on a Wi-Fi SoC such as ESP32, ESP32-C3 and ESP32-S3. It needs an 802.15.4 SoC like ESP32-H2 running [ot_rcp](ot_rcp) example to provide 802.15.4 radio. -* [ot_sleepy_device](ot_sleepy_device) is an OpenThread sleepy device example, it supports 802.15.4 radio light sleep. It runs on an 802.15.4 SoC like ESP32-C6. \ No newline at end of file +* [ot_sleepy_device](ot_sleepy_device) is an OpenThread sleepy device example, it supports 802.15.4 radio light sleep. It runs on an 802.15.4 SoC like ESP32-C6. diff --git a/examples/openthread/ot_sleepy_device/partitions.csv b/examples/openthread/ot_sleepy_device/partitions.csv index 1874ddc89f..6c0e048dba 100644 --- a/examples/openthread/ot_sleepy_device/partitions.csv +++ b/examples/openthread/ot_sleepy_device/partitions.csv @@ -3,4 +3,3 @@ nvs, data, nvs, 0x9000, 0x6000, phy_init, data, phy, 0xf000, 0x1000, factory, app, factory, 0x10000, 0x120000, -ot_storage, data, 0x3a, , 0x2000,