|
|
@@ -80,6 +80,11 @@ static uint32_t s_ccount_div;
|
|
|
static uint32_t s_ccount_mul;
|
|
|
|
|
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
|
|
+#define PERIPH_SKIP_LIGHT_SLEEP_NO 1
|
|
|
+
|
|
|
+/* Indicates if light sleep shoule be skipped by peripherals. */
|
|
|
+static skip_light_sleep_cb_t s_periph_skip_light_sleep_cb[PERIPH_SKIP_LIGHT_SLEEP_NO];
|
|
|
+
|
|
|
/* Indicates if light sleep entry was skipped in vApplicationSleep for given CPU.
|
|
|
* This in turn gets used in IDLE hook to decide if `waiti` needs
|
|
|
* to be invoked or not.
|
|
|
@@ -477,6 +482,42 @@ void esp_pm_impl_waiti(void)
|
|
|
|
|
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
|
|
|
|
|
+esp_err_t esp_pm_register_skip_light_sleep_callback(skip_light_sleep_cb_t cb)
|
|
|
+{
|
|
|
+ for (int i = 0; i < PERIPH_SKIP_LIGHT_SLEEP_NO; i++) {
|
|
|
+ if (s_periph_skip_light_sleep_cb[i] == cb) {
|
|
|
+ return ESP_OK;
|
|
|
+ } else if (s_periph_skip_light_sleep_cb[i] == NULL) {
|
|
|
+ s_periph_skip_light_sleep_cb[i] = cb;
|
|
|
+ return ESP_OK;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ESP_ERR_NO_MEM;
|
|
|
+}
|
|
|
+
|
|
|
+esp_err_t esp_pm_unregister_skip_light_sleep_callback(skip_light_sleep_cb_t cb)
|
|
|
+{
|
|
|
+ for (int i = 0; i < PERIPH_SKIP_LIGHT_SLEEP_NO; i++) {
|
|
|
+ if (s_periph_skip_light_sleep_cb[i] == cb) {
|
|
|
+ s_periph_skip_light_sleep_cb[i] = NULL;
|
|
|
+ return ESP_OK;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ESP_ERR_INVALID_STATE;
|
|
|
+}
|
|
|
+
|
|
|
+static inline bool IRAM_ATTR periph_should_skip_light_sleep(void)
|
|
|
+{
|
|
|
+ for (int i = 0; i < PERIPH_SKIP_LIGHT_SLEEP_NO; i++) {
|
|
|
+ if (s_periph_skip_light_sleep_cb[i]) {
|
|
|
+ if (s_periph_skip_light_sleep_cb[i]() == true) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
static inline bool IRAM_ATTR should_skip_light_sleep(int core_id)
|
|
|
{
|
|
|
#if portNUM_PROCESSORS == 2
|
|
|
@@ -486,7 +527,7 @@ static inline bool IRAM_ATTR should_skip_light_sleep(int core_id)
|
|
|
return true;
|
|
|
}
|
|
|
#endif // portNUM_PROCESSORS == 2
|
|
|
- if (s_mode != PM_MODE_LIGHT_SLEEP || s_is_switching) {
|
|
|
+ if (s_mode != PM_MODE_LIGHT_SLEEP || s_is_switching || periph_should_skip_light_sleep()) {
|
|
|
s_skipped_light_sleep[core_id] = true;
|
|
|
} else {
|
|
|
s_skipped_light_sleep[core_id] = false;
|