Print last reset reason example (#458)
This commit is contained in:
parent
7811668fb1
commit
023a32bc12
47
libraries/ESP32/examples/ResetReason/ResetReason.ino
Normal file
47
libraries/ESP32/examples/ResetReason/ResetReason.ino
Normal file
@ -0,0 +1,47 @@
|
||||
/* Print last reset reason of ESP32
|
||||
* by Evandro Luis Copercini - 2017
|
||||
* Public Domain License.
|
||||
*/
|
||||
|
||||
#include <rom/rtc.h>
|
||||
|
||||
void print_reset_reason(RESET_REASON reason)
|
||||
{
|
||||
switch ( reason)
|
||||
{
|
||||
case 1 : Serial.println ("POWERON_RESET");break; /**<1, Vbat power on reset*/
|
||||
case 3 : Serial.println ("SW_RESET");break; /**<3, Software reset digital core*/
|
||||
case 4 : Serial.println ("OWDT_RESET");break; /**<4, Legacy watch dog reset digital core*/
|
||||
case 5 : Serial.println ("DEEPSLEEP_RESET");break; /**<5, Deep Sleep reset digital core*/
|
||||
case 6 : Serial.println ("SDIO_RESET");break; /**<6, Reset by SLC module, reset digital core*/
|
||||
case 7 : Serial.println ("TG0WDT_SYS_RESET");break; /**<7, Timer Group0 Watch dog reset digital core*/
|
||||
case 8 : Serial.println ("TG1WDT_SYS_RESET");break; /**<8, Timer Group1 Watch dog reset digital core*/
|
||||
case 9 : Serial.println ("RTCWDT_SYS_RESET");break; /**<9, RTC Watch dog Reset digital core*/
|
||||
case 10 : Serial.println ("INTRUSION_RESET");break; /**<10, Instrusion tested to reset CPU*/
|
||||
case 11 : Serial.println ("TGWDT_CPU_RESET");break; /**<11, Time Group reset CPU*/
|
||||
case 12 : Serial.println ("SW_CPU_RESET");break; /**<12, Software reset CPU*/
|
||||
case 13 : Serial.println ("RTCWDT_CPU_RESET");break; /**<13, RTC Watch dog Reset CPU*/
|
||||
case 14 : Serial.println ("EXT_CPU_RESET");break; /**<14, for APP CPU, reseted by PRO CPU*/
|
||||
case 15 : Serial.println ("RTCWDT_BROWN_OUT_RESET");break;/**<15, Reset when the vdd voltage is not stable*/
|
||||
case 16 : Serial.println ("RTCWDT_RTC_RESET");break; /**<16, RTC Watch dog reset digital core and rtc module*/
|
||||
default : Serial.println ("NO_MEAN");
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("CPU0 reset reason: ");
|
||||
print_reset_reason(rtc_get_reset_reason(0));
|
||||
|
||||
Serial.println("CPU1 reset reason: ");
|
||||
print_reset_reason(rtc_get_reset_reason(1));
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user