diff --git a/components/esp_hw_support/linker.lf b/components/esp_hw_support/linker.lf index c63173bf35..c1129d8c54 100644 --- a/components/esp_hw_support/linker.lf +++ b/components/esp_hw_support/linker.lf @@ -30,3 +30,8 @@ entries: gdma: gdma_reset (noflash) if SOC_SYSTIMER_SUPPORTED = y: systimer (noflash) + + if ADC_ONESHOT_CTRL_FUNC_IN_IRAM = y: + sar_periph_ctrl (noflash) + else: + sar_periph_ctrl: sar_periph_ctrl_power_enable (noflash) diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index dd8fa22092..4d89f30032 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -313,8 +313,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) { #ifndef CONFIG_IDF_TARGET_ESP32 if (!periph_ll_periph_enabled(PERIPH_UART0_MODULE + i)) { @@ -322,6 +326,7 @@ static void IRAM_ATTR suspend_uarts(void) } #endif uart_ll_force_xoff(i); + suspended_uarts_bmap |= BIT(i); #if SOC_UART_SUPPORT_FSM_TX_WAIT_SEND uint32_t uart_fsm = 0; do { @@ -331,17 +336,16 @@ static void IRAM_ATTR suspend_uarts(void) while (uart_ll_get_fsm_status(i) != 0) {} #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) { -#ifndef CONFIG_IDF_TARGET_ESP32 - if (!periph_ll_periph_enabled(PERIPH_UART0_MODULE + i)) { - continue; + if (uarts_resume_bmap & 0x1) { + uart_ll_force_xon(i); } -#endif - uart_ll_force_xon(i); + uarts_resume_bmap >>= 1; } } @@ -400,11 +404,12 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) // For light sleep, suspend UART output — it will resume after wakeup. // For deep sleep, wait for the contents of UART FIFO to be sent. bool deep_sleep = pd_flags & RTC_SLEEP_PD_DIG; + uint32_t suspended_uarts_bmap = 0; if (deep_sleep) { flush_uarts(); } else { - suspend_uarts(); + suspended_uarts_bmap = suspend_uarts(); } #if SOC_RTC_SLOW_CLOCK_SUPPORT_8MD256 @@ -583,7 +588,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) } // re-enable UART output - resume_uarts(); + resume_uarts(suspended_uarts_bmap); return result; }