Log fatal errors to file

This commit is contained in:
iabdalkader 2015-08-08 00:31:59 +02:00
parent 4376e87609
commit fa12a1a704

View File

@ -105,8 +105,14 @@ void flash_error(int n) {
} }
void __fatal_error(const char *msg) { void __fatal_error(const char *msg) {
printf("\nFATAL ERROR:\n"); FIL fp;
printf(msg); if (f_open(&fp, "ERROR.LOG",
FA_WRITE|FA_CREATE_ALWAYS) == FR_OK) {
f_printf(&fp, "\nFATAL ERROR:\n%s\n", msg);
}
f_close(&fp);
storage_flush();
for (uint i = 0;;) { for (uint i = 0;;) {
led_toggle(((i++) & 3)); led_toggle(((i++) & 3));
for (volatile uint delay = 0; delay < 500000; delay++) { for (volatile uint delay = 0; delay < 500000; delay++) {