fix(lightsleep): fix access pu_cfg after sleep wake wakeup which is linked to flash

This commit is contained in:
wuzhenghui
2023-07-31 21:41:56 +08:00
parent 1acc14bf72
commit c5703cff8d
3 changed files with 12 additions and 9 deletions

View File

@@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "esp_attr.h"
#include "soc/soc.h" #include "soc/soc.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_reg.h"
@@ -21,6 +22,8 @@
#include "soc/regi2c_lp_bias.h" #include "soc/regi2c_lp_bias.h"
#include "soc/regi2c_dig_reg.h" #include "soc/regi2c_dig_reg.h"
static const DRAM_ATTR rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
/** /**
* Configure whether certain peripherals are powered down in deep sleep * Configure whether certain peripherals are powered down in deep sleep
* @param cfg power down flags as rtc_sleep_pu_config_t structure * @param cfg power down flags as rtc_sleep_pu_config_t structure
@@ -143,7 +146,6 @@ void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_
void rtc_sleep_init(rtc_sleep_config_t cfg) void rtc_sleep_init(rtc_sleep_config_t cfg)
{ {
if (cfg.lslp_mem_inf_fpu) { if (cfg.lslp_mem_inf_fpu) {
rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
rtc_sleep_pu(pu_cfg); rtc_sleep_pu(pu_cfg);
} }
@@ -229,7 +231,6 @@ static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu)
/* restore config if it is a light sleep */ /* restore config if it is a light sleep */
if (lslp_mem_inf_fpu) { if (lslp_mem_inf_fpu) {
rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
rtc_sleep_pu(pu_cfg); rtc_sleep_pu(pu_cfg);
} }
return reject; return reject;

View File

@@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "esp_attr.h"
#include "soc/soc.h" #include "soc/soc.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_reg.h"
@@ -27,6 +28,8 @@
#include "soc/systimer_reg.h" #include "soc/systimer_reg.h"
#endif #endif
static const DRAM_ATTR rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
/** /**
* Configure whether certain peripherals are powered down in deep sleep * Configure whether certain peripherals are powered down in deep sleep
* @param cfg power down flags as rtc_sleep_pu_config_t structure * @param cfg power down flags as rtc_sleep_pu_config_t structure
@@ -168,7 +171,6 @@ void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_
void rtc_sleep_init(rtc_sleep_config_t cfg) void rtc_sleep_init(rtc_sleep_config_t cfg)
{ {
if (cfg.lslp_mem_inf_fpu) { if (cfg.lslp_mem_inf_fpu) {
rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
rtc_sleep_pu(pu_cfg); rtc_sleep_pu(pu_cfg);
} }
if (cfg.wifi_pd_en) { if (cfg.wifi_pd_en) {
@@ -368,7 +370,6 @@ static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu)
/* restore config if it is a light sleep */ /* restore config if it is a light sleep */
if (lslp_mem_inf_fpu) { if (lslp_mem_inf_fpu) {
rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
rtc_sleep_pu(pu_cfg); rtc_sleep_pu(pu_cfg);
} }
return reject; return reject;

View File

@@ -1,10 +1,11 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <stdint.h> #include <stdint.h>
#include "esp_attr.h"
#include "soc/soc.h" #include "soc/soc.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_reg.h"
@@ -20,6 +21,8 @@
#define RTC_CNTL_MEM_FOLW_CPU (RTC_CNTL_SLOWMEM_FOLW_CPU | RTC_CNTL_FASTMEM_FOLW_CPU) #define RTC_CNTL_MEM_FOLW_CPU (RTC_CNTL_SLOWMEM_FOLW_CPU | RTC_CNTL_FASTMEM_FOLW_CPU)
static const DRAM_ATTR rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
/** /**
* Configure whether certain peripherals are powered up in sleep * Configure whether certain peripherals are powered up in sleep
* @param cfg power down flags as rtc_sleep_pu_config_t structure * @param cfg power down flags as rtc_sleep_pu_config_t structure
@@ -171,7 +174,6 @@ void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_
void rtc_sleep_init(rtc_sleep_config_t cfg) void rtc_sleep_init(rtc_sleep_config_t cfg)
{ {
if (cfg.lslp_mem_inf_fpu) { if (cfg.lslp_mem_inf_fpu) {
rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
rtc_sleep_pu(pu_cfg); rtc_sleep_pu(pu_cfg);
} }
@@ -289,7 +291,6 @@ static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu)
/* restore config if it is a light sleep */ /* restore config if it is a light sleep */
if (lslp_mem_inf_fpu) { if (lslp_mem_inf_fpu) {
rtc_sleep_pu_config_t pu_cfg = RTC_SLEEP_PU_CONFIG_ALL(1);
rtc_sleep_pu(pu_cfg); rtc_sleep_pu(pu_cfg);
} }