change(esp_hw_support): replace esp_sleep_enable_adc_tsens_monitor with new API

This commit is contained in:
wuzhenghui
2024-08-30 19:37:28 +08:00
parent 417edbb2e2
commit b1df2688ce
3 changed files with 10 additions and 12 deletions

View File

@@ -127,7 +127,7 @@ esp_err_t adc_oneshot_new_unit(const adc_oneshot_unit_init_cfg_t *init_config, a
sar_periph_ctrl_adc_oneshot_power_acquire(); sar_periph_ctrl_adc_oneshot_power_acquire();
} else { } else {
#if SOC_LIGHT_SLEEP_SUPPORTED || SOC_DEEP_SLEEP_SUPPORTED #if SOC_LIGHT_SLEEP_SUPPORTED || SOC_DEEP_SLEEP_SUPPORTED
esp_sleep_enable_adc_tsens_monitor(true); esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TSEN_MONITOR_MODE, true);
#endif #endif
} }
@@ -230,7 +230,7 @@ esp_err_t adc_oneshot_del_unit(adc_oneshot_unit_handle_t handle)
sar_periph_ctrl_adc_oneshot_power_release(); sar_periph_ctrl_adc_oneshot_power_release();
} else { } else {
#if SOC_LIGHT_SLEEP_SUPPORTED || SOC_DEEP_SLEEP_SUPPORTED #if SOC_LIGHT_SLEEP_SUPPORTED || SOC_DEEP_SLEEP_SUPPORTED
esp_sleep_enable_adc_tsens_monitor(false); esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TSEN_MONITOR_MODE, false);
#endif #endif
} }

View File

@@ -271,7 +271,6 @@ static bool s_light_sleep_wakeup = false;
static portMUX_TYPE spinlock_rtc_deep_sleep = portMUX_INITIALIZER_UNLOCKED; static portMUX_TYPE spinlock_rtc_deep_sleep = portMUX_INITIALIZER_UNLOCKED;
static const char *TAG = "sleep"; static const char *TAG = "sleep";
static RTC_FAST_ATTR bool s_adc_tsen_enabled = false;
static RTC_FAST_ATTR int32_t s_sleep_sub_mode_ref_cnt[ESP_SLEEP_MODE_MAX] = { 0 }; static RTC_FAST_ATTR int32_t s_sleep_sub_mode_ref_cnt[ESP_SLEEP_MODE_MAX] = { 0 };
//in this mode, 2uA is saved, but RTC memory can't use at high temperature, and RTCIO can't be used as INPUT. //in this mode, 2uA is saved, but RTC memory can't use at high temperature, and RTCIO can't be used as INPUT.
static bool s_ultra_low_enabled = false; static bool s_ultra_low_enabled = false;
@@ -679,7 +678,7 @@ FORCE_INLINE_ATTR void misc_modules_sleep_prepare(uint32_t pd_flags, bool deep_s
#if !CONFIG_IDF_TARGET_ESP32P4 #if !CONFIG_IDF_TARGET_ESP32P4
// TODO: IDF-7370 // TODO: IDF-7370
if (!(deep_sleep && s_adc_tsen_enabled)){ if (!(deep_sleep && (s_sleep_sub_mode_ref_cnt[ESP_SLEEP_USE_ADC_TSEN_MONITOR_MODE] != 0))){
sar_periph_ctrl_power_disable(); sar_periph_ctrl_power_disable();
} }
#endif #endif
@@ -902,7 +901,7 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
//Append some flags in addition to power domains //Append some flags in addition to power domains
uint32_t sleep_flags = pd_flags; uint32_t sleep_flags = pd_flags;
if (s_adc_tsen_enabled) { if (s_sleep_sub_mode_ref_cnt[ESP_SLEEP_USE_ADC_TESEN_MONITOR_MODE]) {
sleep_flags |= RTC_SLEEP_USE_ADC_TESEN_MONITOR; sleep_flags |= RTC_SLEEP_USE_ADC_TESEN_MONITOR;
} }
if (!s_ultra_low_enabled) { if (!s_ultra_low_enabled) {

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -31,7 +31,7 @@ static void test_deepsleep(void)
// Deepsleep (with 8MD256 or ADC/TSEN in monitor) // Deepsleep (with 8MD256 or ADC/TSEN in monitor)
TEST_CASE("Power Test: DSLP_8MD256", "[pm]") TEST_CASE("Power Test: DSLP_8MD256", "[pm]")
{ {
esp_sleep_enable_adc_tsens_monitor(true); esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TESEN_MONITOR_MODE, true);
test_deepsleep(); test_deepsleep();
} }
@@ -40,7 +40,7 @@ TEST_CASE("Power Test: DSLP_8MD256", "[pm]")
// Deepsleep (default) // Deepsleep (default)
TEST_CASE("Power Test: DSLP_DEFAULT", "[pm]") TEST_CASE("Power Test: DSLP_DEFAULT", "[pm]")
{ {
esp_sleep_enable_adc_tsens_monitor(false); //This is the default option. Add this line to avoid the case executing this case directly after the DSLP_8MD256 case. esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TESEN_MONITOR_MODE, false); //This is the default option. Add this line to avoid the case executing this case directly after the DSLP_8MD256 case.
test_deepsleep(); test_deepsleep();
} }
@@ -48,7 +48,7 @@ TEST_CASE("Power Test: DSLP_DEFAULT", "[pm]")
// Deepsleep (ultra-low power) // Deepsleep (ultra-low power)
TEST_CASE("Power Test: DSLP_ULTRA_LOW", "[pm]") TEST_CASE("Power Test: DSLP_ULTRA_LOW", "[pm]")
{ {
esp_sleep_enable_adc_tsens_monitor(false); //This is the default option. Add this line to avoid the case executing this case directly after the DSLP_8MD256 case. esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TESEN_MONITOR_MODE, false); //This is the default option. Add this line to avoid the case executing this case directly after the DSLP_8MD256 case.
extern void rtc_sleep_enable_ultra_low(bool); extern void rtc_sleep_enable_ultra_low(bool);
rtc_sleep_enable_ultra_low(true); rtc_sleep_enable_ultra_low(true);
@@ -125,8 +125,7 @@ TEST_CASE("Power Test: LSLP_8MD256", "[pm]")
// Lightsleep (with ADC/TSEN in monitor) // Lightsleep (with ADC/TSEN in monitor)
TEST_CASE("Power Test: LSLP_ADC_TSENS", "[pm]") TEST_CASE("Power Test: LSLP_ADC_TSENS", "[pm]")
{ {
extern void esp_sleep_enable_adc_tsens_monitor(bool); esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TESEN_MONITOR_MODE, true);
esp_sleep_enable_adc_tsens_monitor(true);
test_lightsleep(); test_lightsleep();
} }
@@ -134,7 +133,7 @@ TEST_CASE("Power Test: LSLP_ADC_TSENS", "[pm]")
// Lightsleep (default) // Lightsleep (default)
TEST_CASE("Power Test: LSLP_DEFAULT", "[pm]") TEST_CASE("Power Test: LSLP_DEFAULT", "[pm]")
{ {
esp_sleep_enable_adc_tsens_monitor(false); //This is the default option. Add this line to avoid the case executing this case directly after the DSLP_8MD256 case. esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TESEN_MONITOR_MODE, false); //This is the default option. Add this line to avoid the case executing this case directly after the DSLP_8MD256 case.
test_lightsleep(); test_lightsleep();
} }