Skip to content

Commit 023a32b

Browse files
copercinime-no-dev
authored andcommitted
Print last reset reason example (espressif#458)
1 parent 7811668 commit 023a32b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* Print last reset reason of ESP32
2+
* by Evandro Luis Copercini - 2017
3+
* Public Domain License.
4+
*/
5+
6+
#include <rom/rtc.h>
7+
8+
void print_reset_reason(RESET_REASON reason)
9+
{
10+
switch ( reason)
11+
{
12+
case 1 : Serial.println ("POWERON_RESET");break; /**<1, Vbat power on reset*/
13+
case 3 : Serial.println ("SW_RESET");break; /**<3, Software reset digital core*/
14+
case 4 : Serial.println ("OWDT_RESET");break; /**<4, Legacy watch dog reset digital core*/
15+
case 5 : Serial.println ("DEEPSLEEP_RESET");break; /**<5, Deep Sleep reset digital core*/
16+
case 6 : Serial.println ("SDIO_RESET");break; /**<6, Reset by SLC module, reset digital core*/
17+
case 7 : Serial.println ("TG0WDT_SYS_RESET");break; /**<7, Timer Group0 Watch dog reset digital core*/
18+
case 8 : Serial.println ("TG1WDT_SYS_RESET");break; /**<8, Timer Group1 Watch dog reset digital core*/
19+
case 9 : Serial.println ("RTCWDT_SYS_RESET");break; /**<9, RTC Watch dog Reset digital core*/
20+
case 10 : Serial.println ("INTRUSION_RESET");break; /**<10, Instrusion tested to reset CPU*/
21+
case 11 : Serial.println ("TGWDT_CPU_RESET");break; /**<11, Time Group reset CPU*/
22+
case 12 : Serial.println ("SW_CPU_RESET");break; /**<12, Software reset CPU*/
23+
case 13 : Serial.println ("RTCWDT_CPU_RESET");break; /**<13, RTC Watch dog Reset CPU*/
24+
case 14 : Serial.println ("EXT_CPU_RESET");break; /**<14, for APP CPU, reseted by PRO CPU*/
25+
case 15 : Serial.println ("RTCWDT_BROWN_OUT_RESET");break;/**<15, Reset when the vdd voltage is not stable*/
26+
case 16 : Serial.println ("RTCWDT_RTC_RESET");break; /**<16, RTC Watch dog reset digital core and rtc module*/
27+
default : Serial.println ("NO_MEAN");
28+
}
29+
}
30+
31+
void setup() {
32+
// put your setup code here, to run once:
33+
Serial.begin(115200);
34+
delay(2000);
35+
36+
Serial.println("CPU0 reset reason: ");
37+
print_reset_reason(rtc_get_reset_reason(0));
38+
39+
Serial.println("CPU1 reset reason: ");
40+
print_reset_reason(rtc_get_reset_reason(1));
41+
42+
}
43+
44+
void loop() {
45+
// put your main code here, to run repeatedly:
46+
47+
}

0 commit comments

Comments
 (0)