mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_hw_support/sleep: fix cannot pd cpu and rc fast at the same time during light sleep
Since cpu retention dma use rc fast as clk source, so rc_fast_digi will be enabled when we config to pd cpu. And cpu retention does not need rc fast keep on during light sleep. So, if we use rc_fast_digi to determine whether rc fast can be powered down, then cpu and and rc fast cannot pd at the same time.
This commit is contained in:
parent
7931c033ed
commit
81b98881ac
@ -265,6 +265,8 @@ esp_err_t ledc_isr_register(void (*fn)(void*), void * arg, int intr_alloc_flags,
|
||||
}
|
||||
|
||||
// Setting the LEDC timer divisor with the given source clock, frequency and resolution.
|
||||
extern void esp_sleep_periph_use_8m(bool use_or_not);
|
||||
|
||||
static esp_err_t ledc_set_timer_div(ledc_mode_t speed_mode, ledc_timer_t timer_num, ledc_clk_cfg_t clk_cfg, int freq_hz, int duty_resolution)
|
||||
{
|
||||
uint32_t div_param = 0;
|
||||
@ -303,6 +305,9 @@ static esp_err_t ledc_set_timer_div(ledc_mode_t speed_mode, ledc_timer_t timer_n
|
||||
goto error;
|
||||
}
|
||||
if (speed_mode == LEDC_LOW_SPEED_MODE) {
|
||||
|
||||
/* keep ESP_PD_DOMAIN_RTC8M on during light sleep */
|
||||
esp_sleep_periph_use_8m(clk_cfg == LEDC_USE_RTC8M_CLK);
|
||||
portENTER_CRITICAL(&ledc_spinlock);
|
||||
ledc_hal_set_slow_clk(&(p_ledc_obj[speed_mode]->ledc_hal), clk_cfg);
|
||||
portEXIT_CRITICAL(&ledc_spinlock);
|
||||
|
@ -179,6 +179,13 @@ static portMUX_TYPE spinlock_rtc_deep_sleep = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
static const char *TAG = "sleep";
|
||||
|
||||
static bool s_periph_use_8m_flag = false;
|
||||
|
||||
void esp_sleep_periph_use_8m(bool use_or_not)
|
||||
{
|
||||
s_periph_use_8m_flag = use_or_not;
|
||||
}
|
||||
|
||||
static uint32_t get_power_down_flags(void);
|
||||
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||
static void ext0_wakeup_prepare(void);
|
||||
@ -511,10 +518,10 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags)
|
||||
bool rtc_using_8md256 = false;
|
||||
#endif
|
||||
//Keep the RTC8M_CLK on if the ledc low-speed channel is clocked by RTC8M_CLK in lightsleep mode
|
||||
bool dig_8m_enabled = !deep_sleep && rtc_dig_8m_enabled();
|
||||
bool periph_using_8m = !deep_sleep && s_periph_use_8m_flag;
|
||||
|
||||
//Override user-configured power modes.
|
||||
if (rtc_using_8md256 || dig_8m_enabled) {
|
||||
if (rtc_using_8md256 || periph_using_8m) {
|
||||
pd_flags &= ~RTC_SLEEP_PD_INT_8M;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user