Skip to content

Commit 717e2b1

Browse files
committed
espulp: Enable gpio power domain during deep sleep
1 parent 874d496 commit 717e2b1

File tree

1 file changed

+9
-6
lines changed
  • ports/espressif/common-hal/espulp

1 file changed

+9
-6
lines changed

ports/espressif/common-hal/espulp/ULP.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "py/runtime.h"
3131
#include "shared-bindings/microcontroller/Pin.h"
3232

33+
#include "esp_sleep.h"
34+
3335
#if defined(CONFIG_IDF_TARGET_ESP32)
3436
#include "esp32/ulp.h"
3537
#define ULP_COPROC_RESERVE_MEM (CONFIG_ESP32_ULP_COPROC_RESERVE_MEM)
@@ -46,12 +48,6 @@
4648
// To-do idf v5.0: remove following include
4749
#include "soc/rtc_cntl_reg.h"
4850

49-
#ifndef CONFIG_ULP_COPROC_TYPE_FSM
50-
#warning "Have no FSM"
51-
#endif
52-
// #ifndef CONFIG_ULP_COPROC_TYPE_RISCV
53-
// #warning "Have no RISCV"
54-
// #endif
5551

5652
STATIC bool ulp_used = false;
5753
STATIC uint32_t pins_used = 0;
@@ -101,6 +97,13 @@ void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t
10197
}
10298
pins_used = pin_mask;
10399

100+
// Main purpose of ULP is to run while main cpu is in deep sleep, so
101+
// ensure GPIO Power Domain remains enabled during deep sleep,
102+
// if any GPIO were supplied here.
103+
if (pins_used > 0){
104+
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
105+
}
106+
104107
int _errno;
105108
switch (self->arch) {
106109
#ifdef CONFIG_ULP_COPROC_TYPE_FSM

0 commit comments

Comments
 (0)