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