Merge branch 'bugfix/fix_wakeup_failed_if_powerdown_flash_in_lightsleep' into 'master'

Power Management: fixed flash funcs called in sleep wakeup process

See merge request espressif/esp-idf!23906
This commit is contained in:
Wu Zheng Hui
2023-06-01 14:10:15 +08:00
2 changed files with 17 additions and 9 deletions

View File

@@ -46,3 +46,5 @@ entries:
if ADC_ONESHOT_CTRL_FUNC_IN_IRAM = y: if ADC_ONESHOT_CTRL_FUNC_IN_IRAM = y:
sar_periph_ctrl (noflash) sar_periph_ctrl (noflash)
else:
sar_periph_ctrl: sar_periph_ctrl_power_enable (noflash)

View File

@@ -395,8 +395,12 @@ static void IRAM_ATTR flush_uarts(void)
} }
} }
static void IRAM_ATTR suspend_uarts(void) /**
* Suspend enabled uarts and return suspended uarts bit map
*/
static uint32_t IRAM_ATTR suspend_uarts(void)
{ {
uint32_t suspended_uarts_bmap = 0;
for (int i = 0; i < SOC_UART_NUM; ++i) { for (int i = 0; i < SOC_UART_NUM; ++i) {
#ifndef CONFIG_IDF_TARGET_ESP32 #ifndef CONFIG_IDF_TARGET_ESP32
if (!periph_ll_periph_enabled(PERIPH_UART0_MODULE + i)) { if (!periph_ll_periph_enabled(PERIPH_UART0_MODULE + i)) {
@@ -404,6 +408,7 @@ static void IRAM_ATTR suspend_uarts(void)
} }
#endif #endif
uart_ll_force_xoff(i); uart_ll_force_xoff(i);
suspended_uarts_bmap |= BIT(i);
#if SOC_UART_SUPPORT_FSM_TX_WAIT_SEND #if SOC_UART_SUPPORT_FSM_TX_WAIT_SEND
uint32_t uart_fsm = 0; uint32_t uart_fsm = 0;
do { do {
@@ -413,17 +418,16 @@ static void IRAM_ATTR suspend_uarts(void)
while (uart_ll_get_fsm_status(i) != 0) {} while (uart_ll_get_fsm_status(i) != 0) {}
#endif #endif
} }
return suspended_uarts_bmap;
} }
static void IRAM_ATTR resume_uarts(void) static void IRAM_ATTR resume_uarts(uint32_t uarts_resume_bmap)
{ {
for (int i = 0; i < SOC_UART_NUM; ++i) { for (int i = 0; i < SOC_UART_NUM; ++i) {
#ifndef CONFIG_IDF_TARGET_ESP32 if (uarts_resume_bmap & 0x1) {
if (!periph_ll_periph_enabled(PERIPH_UART0_MODULE + i)) { uart_ll_force_xon(i);
continue;
} }
#endif uarts_resume_bmap >>= 1;
uart_ll_force_xon(i);
} }
} }
@@ -488,6 +492,8 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo
// For deep sleep, wait for the contents of UART FIFO to be sent. // For deep sleep, wait for the contents of UART FIFO to be sent.
bool deep_sleep = (mode == ESP_SLEEP_MODE_DEEP_SLEEP); bool deep_sleep = (mode == ESP_SLEEP_MODE_DEEP_SLEEP);
bool should_skip_sleep = false; bool should_skip_sleep = false;
uint32_t suspended_uarts_bmap = 0;
#if SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256 #if SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256
//Keep the RTC8M_CLK on if RTC clock is rc_fast_d256. //Keep the RTC8M_CLK on if RTC clock is rc_fast_d256.
@@ -639,7 +645,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo
} else } else
#endif #endif
{ {
suspend_uarts(); suspended_uarts_bmap = suspend_uarts();
} }
} }
@@ -730,7 +736,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo
} }
// re-enable UART output // re-enable UART output
resume_uarts(); resume_uarts(suspended_uarts_bmap);
s_lightsleep_cnt++; s_lightsleep_cnt++;
return result; return result;
} }