From b422504d10f36980512f35e59f131963b745d5d8 Mon Sep 17 00:00:00 2001 From: xiaqilin Date: Thu, 29 Jun 2023 15:12:03 +0800 Subject: [PATCH] ieee802154: exclude sleep file when do not define CONFIG_FREERTOS_USE_TICKLESS_IDLE --- components/ieee802154/Kconfig | 1 - components/ieee802154/driver/esp_ieee802154_dev.c | 3 +-- components/ieee802154/include/esp_ieee802154.h | 1 - components/openthread/CMakeLists.txt | 5 +++++ components/openthread/private_include/esp_openthread_sleep.h | 1 + components/openthread/src/port/esp_openthread_sleep.c | 5 +++-- examples/openthread/ot_sleepy_device/README.md | 2 +- .../openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c | 5 +---- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/ieee802154/Kconfig b/components/ieee802154/Kconfig index 981945e50c..09aea764ed 100644 --- a/components/ieee802154/Kconfig +++ b/components/ieee802154/Kconfig @@ -74,7 +74,6 @@ menu "IEEE 802.15.4" Enabling this option increases throughput by ~5% at the expense of ~2.1k IRAM code size increase. - config IEEE802154_SLEEP_ENABLE # Todo: Remove when support safe power-down of the power domain (IDF-7317) bool "Enable IEEE802154 light sleep" diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index e2048b7ec1..dd428c6f29 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -636,7 +636,7 @@ esp_err_t ieee802154_mac_init(void) ret = esp_intr_alloc(ieee802154_periph.irq_id, 0, ieee802154_isr, NULL, NULL); ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, IEEE802154_TAG, "IEEE802154 MAC init failed"); - ret = ieee802154_sleep_init(); + ESP_RETURN_ON_FALSE(ieee802154_sleep_init() == ESP_OK, ESP_FAIL, IEEE802154_TAG, "IEEE802154 MAC sleep init failed"); return ret; } @@ -767,7 +767,6 @@ static esp_err_t ieee802154_sleep_init(void) 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) }, }; - err = sleep_retention_entries_create(ieee802154_mac_regs_retention, ARRAY_SIZE(ieee802154_mac_regs_retention), REGDMA_LINK_PRI_7, SLEEP_RETENTION_MODULE_802154_MAC); ESP_RETURN_ON_ERROR(err, IEEE802154_TAG, "failed to allocate memory for ieee802154 mac retention"); ESP_LOGI(IEEE802154_TAG, "ieee802154 mac sleep retention initialization"); diff --git a/components/ieee802154/include/esp_ieee802154.h b/components/ieee802154/include/esp_ieee802154.h index a1a7bd03fa..22d3acb52d 100644 --- a/components/ieee802154/include/esp_ieee802154.h +++ b/components/ieee802154/include/esp_ieee802154.h @@ -114,7 +114,6 @@ esp_err_t esp_ieee802154_sleep(void); /** * @brief The IEEE 802.15.4 enter sleep. */ - void esp_ieee802154_enter_sleep(void); /** diff --git a/components/openthread/CMakeLists.txt b/components/openthread/CMakeLists.txt index 26c3d5706a..7b02627731 100644 --- a/components/openthread/CMakeLists.txt +++ b/components/openthread/CMakeLists.txt @@ -140,6 +140,11 @@ if(CONFIG_OPENTHREAD_ENABLED) "src/esp_openthread_dns64.c") endif() + if(NOT CONFIG_FREERTOS_USE_TICKLESS_IDLE) + list(APPEND exclude_srcs + "src/port/esp_openthread_sleep.c") + endif() + if(CONFIG_OPENTHREAD_FTD) set(device_type "OPENTHREAD_FTD=1") elseif(CONFIG_OPENTHREAD_MTD) diff --git a/components/openthread/private_include/esp_openthread_sleep.h b/components/openthread/private_include/esp_openthread_sleep.h index 0a1bad56ca..e8b2679514 100644 --- a/components/openthread/private_include/esp_openthread_sleep.h +++ b/components/openthread/private_include/esp_openthread_sleep.h @@ -7,6 +7,7 @@ #pragma once #include "esp_err.h" +#include "sdkconfig.h" #ifdef __cplusplus extern "C" { diff --git a/components/openthread/src/port/esp_openthread_sleep.c b/components/openthread/src/port/esp_openthread_sleep.c index e59a45b898..fa6fdb3fcd 100644 --- a/components/openthread/src/port/esp_openthread_sleep.c +++ b/components/openthread/src/port/esp_openthread_sleep.c @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "sdkconfig.h" + +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE #include "esp_log.h" #include "esp_check.h" #include "esp_ieee802154.h" - -#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"; diff --git a/examples/openthread/ot_sleepy_device/README.md b/examples/openthread/ot_sleepy_device/README.md index 0aa2907879..e96137dd7e 100644 --- a/examples/openthread/ot_sleepy_device/README.md +++ b/examples/openthread/ot_sleepy_device/README.md @@ -3,7 +3,7 @@ # OpenThread Sleepy Device Example -The example demonstrates the Thread Sleepy End Device (SED), the device will enter [Light Sleep mode](https://docs.espressif.com/projects/esp-idf/en/latest/esp32h2/api-reference/system/sleep_modes.html#sleep-modes) during idle state. +The example demonstrates the Thread Sleepy End Device (SED), the device will enter [Light Sleep mode](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-reference/system/sleep_modes.html#sleep-modes) during idle state. ## How to use example ### Hardware Required diff --git a/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c b/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c index 584208a75f..42e53f0f09 100644 --- a/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c +++ b/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c @@ -16,7 +16,6 @@ #include #include #include - #include "esp_err.h" #include "esp_event.h" #include "esp_log.h" @@ -41,8 +40,7 @@ static void create_config_network(otInstance *instance) { - otLinkModeConfig linkMode; - memset(&linkMode, 0, sizeof(otLinkModeConfig)); + otLinkModeConfig linkMode = { 0 }; linkMode.mRxOnWhenIdle = false; linkMode.mDeviceType = false; @@ -136,7 +134,6 @@ void app_main(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config)); - ESP_ERROR_CHECK(ot_power_save_init()); xTaskCreate(ot_task_worker, "ot_power_save_main", 4096, NULL, 5, NULL);