diff --git a/docs/library/machine.rst b/docs/library/machine.rst index 76d111f11ef3..a47de88fb266 100644 --- a/docs/library/machine.rst +++ b/docs/library/machine.rst @@ -241,6 +241,7 @@ Constants machine.WDT_RESET machine.DEEPSLEEP_RESET machine.SOFT_RESET + machine.BROWNOUT_RESET - (ESP32 specific) Reset causes. diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index 0c1b94d02d94..df2590b9128a 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -70,6 +70,7 @@ { MP_ROM_QSTR(MP_QSTR_WDT_RESET), MP_ROM_INT(MP_WDT_RESET) }, \ { MP_ROM_QSTR(MP_QSTR_DEEPSLEEP_RESET), MP_ROM_INT(MP_DEEPSLEEP_RESET) }, \ { MP_ROM_QSTR(MP_QSTR_SOFT_RESET), MP_ROM_INT(MP_SOFT_RESET) }, \ + { MP_ROM_QSTR(MP_QSTR_BROWNOUT_RESET), MP_ROM_INT(MP_BROWNOUT_RESET) }, \ \ /* Wake reasons */ \ { MP_ROM_QSTR(MP_QSTR_wake_reason), MP_ROM_PTR(&machine_wake_reason_obj) }, \ @@ -85,7 +86,8 @@ typedef enum { MP_HARD_RESET, MP_WDT_RESET, MP_DEEPSLEEP_RESET, - MP_SOFT_RESET + MP_SOFT_RESET, + MP_BROWNOUT_RESET } reset_reason_t; static bool is_soft_reset = 0; @@ -189,8 +191,12 @@ static mp_int_t mp_machine_reset_cause(void) { } switch (esp_reset_reason()) { case ESP_RST_POWERON: - case ESP_RST_BROWNOUT: return MP_PWRON_RESET; + break; + + case ESP_RST_BROWNOUT: + return MP_BROWNOUT_RESET; + break; case ESP_RST_INT_WDT: case ESP_RST_TASK_WDT: