mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-15 14:36:45 +00:00
fix(esp_hw_support): move deepsleep phy callback before PLL disable
This commit is contained in:
@@ -170,7 +170,8 @@
|
||||
|
||||
#define MAX_DSLP_HOOKS 3
|
||||
|
||||
static esp_deep_sleep_cb_t s_dslp_cb[MAX_DSLP_HOOKS]={0};
|
||||
static esp_deep_sleep_cb_t s_dslp_cb[MAX_DSLP_HOOKS] = {0};
|
||||
static esp_deep_sleep_cb_t s_dslp_phy_cb[MAX_DSLP_HOOKS] = {0};
|
||||
|
||||
/**
|
||||
* Internal structure which holds all requested sleep parameters
|
||||
@@ -387,12 +388,12 @@ esp_err_t esp_deep_sleep_try(uint64_t time_in_us)
|
||||
return esp_deep_sleep_try_to_start();
|
||||
}
|
||||
|
||||
esp_err_t esp_deep_sleep_register_hook(esp_deep_sleep_cb_t new_dslp_cb)
|
||||
static esp_err_t s_sleep_hook_register(esp_deep_sleep_cb_t new_cb, esp_deep_sleep_cb_t s_cb_array[MAX_DSLP_HOOKS])
|
||||
{
|
||||
portENTER_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
for(int n = 0; n < MAX_DSLP_HOOKS; n++){
|
||||
if (s_dslp_cb[n]==NULL || s_dslp_cb[n]==new_dslp_cb) {
|
||||
s_dslp_cb[n]=new_dslp_cb;
|
||||
for (int n = 0; n < MAX_DSLP_HOOKS; n++) {
|
||||
if (s_cb_array[n]==NULL || s_cb_array[n]==new_cb) {
|
||||
s_cb_array[n]=new_cb;
|
||||
portEXIT_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -402,17 +403,46 @@ esp_err_t esp_deep_sleep_register_hook(esp_deep_sleep_cb_t new_dslp_cb)
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
void esp_deep_sleep_deregister_hook(esp_deep_sleep_cb_t old_dslp_cb)
|
||||
static void s_sleep_hook_deregister(esp_deep_sleep_cb_t old_cb, esp_deep_sleep_cb_t s_cb_array[MAX_DSLP_HOOKS])
|
||||
{
|
||||
portENTER_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
for(int n = 0; n < MAX_DSLP_HOOKS; n++){
|
||||
if(s_dslp_cb[n] == old_dslp_cb) {
|
||||
s_dslp_cb[n] = NULL;
|
||||
for (int n = 0; n < MAX_DSLP_HOOKS; n++) {
|
||||
if(s_cb_array[n] == old_cb) {
|
||||
s_cb_array[n] = NULL;
|
||||
}
|
||||
}
|
||||
portEXIT_CRITICAL(&spinlock_rtc_deep_sleep);
|
||||
}
|
||||
|
||||
esp_err_t esp_deep_sleep_register_hook(esp_deep_sleep_cb_t new_dslp_cb)
|
||||
{
|
||||
return s_sleep_hook_register(new_dslp_cb, s_dslp_cb);
|
||||
}
|
||||
|
||||
void esp_deep_sleep_deregister_hook(esp_deep_sleep_cb_t old_dslp_cb)
|
||||
{
|
||||
s_sleep_hook_deregister(old_dslp_cb, s_dslp_cb);
|
||||
}
|
||||
|
||||
esp_err_t esp_deep_sleep_register_phy_hook(esp_deep_sleep_cb_t new_dslp_cb)
|
||||
{
|
||||
return s_sleep_hook_register(new_dslp_cb, s_dslp_phy_cb);
|
||||
}
|
||||
|
||||
void esp_deep_sleep_deregister_phy_hook(esp_deep_sleep_cb_t old_dslp_cb)
|
||||
{
|
||||
s_sleep_hook_deregister(old_dslp_cb, s_dslp_phy_cb);
|
||||
}
|
||||
|
||||
static void s_do_deep_sleep_phy_callback(void)
|
||||
{
|
||||
for (int n = 0; n < MAX_DSLP_HOOKS; n++) {
|
||||
if (s_dslp_phy_cb[n] != NULL) {
|
||||
s_dslp_phy_cb[n]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int s_cache_suspend_cnt = 0;
|
||||
|
||||
// Must be called from critical sections.
|
||||
@@ -659,6 +689,12 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
||||
should_skip_sleep = light_sleep_uart_prepare(pd_flags, sleep_duration);
|
||||
}
|
||||
|
||||
// Do deep-sleep PHY related callback, which need to be executed when the PLL clock is exists.
|
||||
// For light-sleep, PHY state is managed by the upper layer of the wifi/bt protocol stack.
|
||||
if (deep_sleep) {
|
||||
s_do_deep_sleep_phy_callback();
|
||||
}
|
||||
|
||||
// Will switch to XTAL turn down MSPI speed
|
||||
mspi_timing_change_speed_mode_cache_safe(true);
|
||||
|
||||
|
Reference in New Issue
Block a user