Skip to content

Commit

Permalink
esp32\modmachine.c: Add BROWNOUT_RESET.
Browse files Browse the repository at this point in the history
Signed-off-by: IhorNehrutsa <[email protected]>
  • Loading branch information
IhorNehrutsa committed Jan 20, 2025
1 parent b4f53a0 commit 6f52839
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/library/machine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Constants
machine.WDT_RESET
machine.DEEPSLEEP_RESET
machine.SOFT_RESET
machine.BROWNOUT_RESET - (ESP32 specific)

Reset causes.

Expand Down
10 changes: 8 additions & 2 deletions ports/esp32/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) }, \
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6f52839

Please sign in to comment.