1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-23 19:21:59 +03:00

Add the ability to be called back when the device is about to reset

Caveats:
- You have to be very careful in your callback.
- On Adafruit Huzzah, I only actually get called for Exceptions and Soft
   WDT resets.
This commit is contained in:
Carl Pacey
2015-11-13 12:47:57 -05:00
parent 81e3ebef7a
commit baa13f8c84

View File

@ -37,6 +37,11 @@ static void uart1_write_char_d(char c);
static void print_stack(uint32_t start, uint32_t end);
//static void print_pcs(uint32_t start, uint32_t end);
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
}
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
void __wrap_system_restart_local() {
register uint32_t sp asm("a1");
@ -92,6 +97,9 @@ void __wrap_system_restart_local() {
// print_pcs(sp + offset, stack_end);
print_stack(sp + offset, stack_end);
custom_crash_callback( &rst_info, sp + offset, stack_end );
delayMicroseconds(10000);
__real_system_restart_local();
}