From 77afbd51aea88f679f7e0eb6e0cebe661a49cdf3 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 9 Sep 2020 23:34:54 +0200 Subject: [PATCH] sleep: fix esp32 light sleep duration Commit aa43ed8 was fixing the light sleep overhead calculation for ESP32-S2. However it also changed the overhead values for ESP32, resulting in incorrect light sleep time. This caused regression in light sleep example test. Revert the original values for the ESP32, keep different set of values for each chip. --- components/esp_system/sleep_modes.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/components/esp_system/sleep_modes.c b/components/esp_system/sleep_modes.c index aa6026c6a1..f61c52f305 100644 --- a/components/esp_system/sleep_modes.c +++ b/components/esp_system/sleep_modes.c @@ -70,13 +70,29 @@ #define DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ #endif -#if defined(CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS) || defined(CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS) +#if defined(CONFIG_IDF_TARGET_ESP32) +#if defined(CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS) +#define LIGHT_SLEEP_TIME_OVERHEAD_US (650 + 30 * 240 / DEFAULT_CPU_FREQ_MHZ) +#define DEEP_SLEEP_TIME_OVERHEAD_US (650 + 100 * 240 / DEFAULT_CPU_FREQ_MHZ) +#else // CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS +#define LIGHT_SLEEP_TIME_OVERHEAD_US (250 + 30 * 240 / DEFAULT_CPU_FREQ_MHZ) +#define DEEP_SLEEP_TIME_OVERHEAD_US (250 + 100 * 240 / DEFAULT_CPU_FREQ_MHZ) +#endif // CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS + +#elif defined(CONFIG_IDF_TARGET_ESP32S2) +#if defined(CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS) #define LIGHT_SLEEP_TIME_OVERHEAD_US (1650 + 30 * 240 / DEFAULT_CPU_FREQ_MHZ) #define DEEP_SLEEP_TIME_OVERHEAD_US (650 + 100 * 240 / DEFAULT_CPU_FREQ_MHZ) -#else +#else // CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS #define LIGHT_SLEEP_TIME_OVERHEAD_US (1250 + 30 * 240 / DEFAULT_CPU_FREQ_MHZ) #define DEEP_SLEEP_TIME_OVERHEAD_US (250 + 100 * 240 / DEFAULT_CPU_FREQ_MHZ) -#endif +#endif // CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS + +#else // other target +#define LIGHT_SLEEP_TIME_OVERHEAD_US 0 +#define DEEP_SLEEP_TIME_OVERHEAD_US 0 +#endif // CONFIG_IDF_TARGET_* + #if defined(CONFIG_IDF_TARGET_ESP32) && defined(CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY) #define DEEP_SLEEP_WAKEUP_DELAY CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY