2017-04-17 09:07:34 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2017-10-26 21:01:22 -07:00
|
|
|
#include <unistd.h>
|
2017-04-17 09:07:34 -07:00
|
|
|
|
|
|
|
#include "common.h"
|
2017-12-07 06:31:23 -08:00
|
|
|
#include "display.h"
|
|
|
|
|
|
|
|
void __shutdown(void)
|
|
|
|
{
|
|
|
|
printf("SHUTDOWN\n");
|
|
|
|
exit(3);
|
|
|
|
}
|
2017-04-17 09:07:34 -07:00
|
|
|
|
2017-10-11 15:32:46 -07:00
|
|
|
void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func)
|
|
|
|
{
|
2017-12-07 06:31:23 -08:00
|
|
|
display_orientation(0);
|
|
|
|
display_backlight(255);
|
|
|
|
display_print_color(COLOR_WHITE, COLOR_RED128);
|
|
|
|
display_printf("\nFATAL ERROR:\n");
|
2017-10-11 15:32:46 -07:00
|
|
|
printf("\nFATAL ERROR:\n");
|
|
|
|
if (expr) {
|
2017-12-07 06:31:23 -08:00
|
|
|
display_printf("expr: %s\n", expr);
|
2017-10-11 15:32:46 -07:00
|
|
|
printf("expr: %s\n", expr);
|
|
|
|
}
|
|
|
|
if (msg) {
|
2017-12-07 06:31:23 -08:00
|
|
|
display_printf("msg : %s\n", msg);
|
2017-10-11 15:32:46 -07:00
|
|
|
printf("msg : %s\n", msg);
|
|
|
|
}
|
2017-04-28 06:39:22 -07:00
|
|
|
if (file) {
|
2017-12-07 06:31:23 -08:00
|
|
|
display_printf("file: %s:%d\n", file, line);
|
2017-10-11 15:32:46 -07:00
|
|
|
printf("file: %s:%d\n", file, line);
|
2017-04-28 06:39:22 -07:00
|
|
|
}
|
|
|
|
if (func) {
|
2017-12-07 06:31:23 -08:00
|
|
|
display_printf("func: %s\n", func);
|
2017-10-11 15:32:46 -07:00
|
|
|
printf("func: %s\n", func);
|
2017-04-28 06:39:22 -07:00
|
|
|
}
|
2017-10-12 07:02:40 -07:00
|
|
|
#ifdef GITREV
|
|
|
|
#define XSTR(s) STR(s)
|
|
|
|
#define STR(s) #s
|
2017-12-07 06:31:23 -08:00
|
|
|
display_printf("rev : %s\n", XSTR(GITREV));
|
2017-10-12 07:02:40 -07:00
|
|
|
printf("rev : %s\n", XSTR(GITREV));
|
|
|
|
#endif
|
2017-12-07 06:31:23 -08:00
|
|
|
hal_delay(3000);
|
|
|
|
__shutdown();
|
|
|
|
for (;;);
|
2017-04-17 09:07:34 -07:00
|
|
|
}
|
2017-10-26 21:01:22 -07:00
|
|
|
|
|
|
|
void hal_delay(uint32_t ms)
|
|
|
|
{
|
|
|
|
usleep(1000 * ms);
|
|
|
|
}
|