mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'bugfix/regression_in_light_sleep_mode' into 'master'
esp32: fix regression introduced in automatic light sleep pm See merge request idf/esp-idf!3371
This commit is contained in:
@@ -60,9 +60,7 @@ void esp_vApplicationIdleHook()
|
|||||||
esp_pm_impl_idle_hook();
|
esp_pm_impl_idle_hook();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
esp_pm_impl_waiti();
|
||||||
asm("waiti 0");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid)
|
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid)
|
||||||
|
@@ -80,6 +80,14 @@ static uint32_t s_mode_mask;
|
|||||||
static uint32_t s_ccount_div;
|
static uint32_t s_ccount_div;
|
||||||
static uint32_t s_ccount_mul;
|
static uint32_t s_ccount_mul;
|
||||||
|
|
||||||
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
/* Indicates if light sleep entry was successful for given CPU.
|
||||||
|
* This in turn gets used in IDLE hook to decide if `waiti` needs
|
||||||
|
* to be invoked or not.
|
||||||
|
*/
|
||||||
|
static bool s_entered_light_sleep[portNUM_PROCESSORS];
|
||||||
|
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
|
||||||
/* Indicates to the ISR hook that CCOMPARE needs to be updated on the given CPU.
|
/* Indicates to the ISR hook that CCOMPARE needs to be updated on the given CPU.
|
||||||
* Used in conjunction with cross-core interrupt to update CCOMPARE on the other CPU.
|
* Used in conjunction with cross-core interrupt to update CCOMPARE on the other CPU.
|
||||||
*/
|
*/
|
||||||
@@ -453,11 +461,24 @@ void IRAM_ATTR esp_pm_impl_isr_hook()
|
|||||||
ESP_PM_TRACE_EXIT(ISR_HOOK, core_id);
|
ESP_PM_TRACE_EXIT(ISR_HOOK, core_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void esp_pm_impl_waiti()
|
||||||
|
{
|
||||||
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
int core_id = xPortGetCoreID();
|
||||||
|
if (!s_entered_light_sleep[core_id]) {
|
||||||
|
asm("waiti 0");
|
||||||
|
} else {
|
||||||
|
s_entered_light_sleep[core_id] = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
asm("waiti 0");
|
||||||
|
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
|
||||||
void IRAM_ATTR vApplicationSleep( TickType_t xExpectedIdleTime )
|
void IRAM_ATTR vApplicationSleep( TickType_t xExpectedIdleTime )
|
||||||
{
|
{
|
||||||
bool result = false;
|
|
||||||
portENTER_CRITICAL(&s_switch_lock);
|
portENTER_CRITICAL(&s_switch_lock);
|
||||||
if (s_mode == PM_MODE_LIGHT_SLEEP && !s_is_switching) {
|
if (s_mode == PM_MODE_LIGHT_SLEEP && !s_is_switching) {
|
||||||
/* Calculate how much we can sleep */
|
/* Calculate how much we can sleep */
|
||||||
@@ -495,15 +516,10 @@ void IRAM_ATTR vApplicationSleep( TickType_t xExpectedIdleTime )
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = true;
|
s_entered_light_sleep[core_id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL(&s_switch_lock);
|
portEXIT_CRITICAL(&s_switch_lock);
|
||||||
|
|
||||||
/* Tick less idle was not successful, can block till next interrupt here */
|
|
||||||
if (!result) {
|
|
||||||
asm("waiti 0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif //CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#endif //CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
|
||||||
|
@@ -104,6 +104,10 @@ void esp_pm_impl_isr_hook();
|
|||||||
*/
|
*/
|
||||||
void esp_pm_impl_dump_stats(FILE* out);
|
void esp_pm_impl_dump_stats(FILE* out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Hook function implementing `waiti` instruction, should be invoked from idle task context
|
||||||
|
*/
|
||||||
|
void esp_pm_impl_waiti();
|
||||||
|
|
||||||
#ifdef CONFIG_PM_PROFILING
|
#ifdef CONFIG_PM_PROFILING
|
||||||
#define WITH_PROFILING
|
#define WITH_PROFILING
|
||||||
|
Reference in New Issue
Block a user