summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHosted Weblate <hosted@weblate.org>2021-02-09 15:03:46 +0100
committerHosted Weblate <hosted@weblate.org>2021-02-09 15:03:46 +0100
commitc53155c9d6f655c45ba7eb97099663286d3591e8 (patch)
tree7091a369ef65ff4dca4e3618afb0ebf321bad0a5
parentfd3f5708dc300914e082e4ada3901a1c4c915369 (diff)
parent5ba28e9861b0b4101198a834953fcbd5f3e7b0f3 (diff)
Merge remote-tracking branch 'origin/main' into main
-rw-r--r--ports/esp32s2/common-hal/alarm/__init__.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c
index 1cec5d4ae..be435e210 100644
--- a/ports/esp32s2/common-hal/alarm/__init__.c
+++ b/ports/esp32s2/common-hal/alarm/__init__.c
@@ -150,6 +150,14 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala
void NORETURN alarm_enter_deep_sleep(void) {
alarm_pin_pinalarm_prepare_for_deep_sleep();
alarm_touch_touchalarm_prepare_for_deep_sleep();
+
+ // Disable brownout detection, which appears to be triggered sometimes when
+ // waking from deep sleep.
+ // See https://www.esp32.com/viewtopic.php?f=13&t=19208#p71084
+ // and https://github.com/adafruit/circuitpython/issues/4025#issuecomment-771027606
+ // TODO: We can remove this workaround when ESP-IDF handles this.
+ CLEAR_PERI_REG_MASK(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_RST_ENA);
+
// The ESP-IDF caches the deep sleep settings and applies them before sleep.
// We don't need to worry about resetting them in the interim.
esp_deep_sleep_start();