|
@@ -1,9 +1,10 @@
|
|
|
#include "check.h"
|
|
#include "check.h"
|
|
|
#include "furi-hal-task.h"
|
|
#include "furi-hal-task.h"
|
|
|
#include <furi-hal-console.h>
|
|
#include <furi-hal-console.h>
|
|
|
|
|
+#include <furi-hal-rtc.h>
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
-void __furi_print_name(void) {
|
|
|
|
|
|
|
+__attribute__((always_inline)) inline static void __furi_print_name() {
|
|
|
if(task_is_isr_context()) {
|
|
if(task_is_isr_context()) {
|
|
|
furi_hal_console_puts("[ISR] ");
|
|
furi_hal_console_puts("[ISR] ");
|
|
|
} else {
|
|
} else {
|
|
@@ -18,18 +19,34 @@ void __furi_print_name(void) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void __furi_abort(void) {
|
|
|
|
|
- __disable_irq();
|
|
|
|
|
- asm("bkpt 1");
|
|
|
|
|
- while(1) {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+__attribute__((always_inline)) inline static void __furi_halt() {
|
|
|
|
|
+ asm volatile("bkpt 0x00 \n"
|
|
|
|
|
+ "loop: \n"
|
|
|
|
|
+ "wfi \n"
|
|
|
|
|
+ "b loop \n"
|
|
|
|
|
+ :
|
|
|
|
|
+ :
|
|
|
|
|
+ : "memory");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void furi_crash(const char* message) {
|
|
void furi_crash(const char* message) {
|
|
|
|
|
+ __disable_irq();
|
|
|
|
|
+
|
|
|
|
|
+ if(message == NULL) {
|
|
|
|
|
+ message = "Fatal Error";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
furi_hal_console_puts("\r\n\033[0;31m[CRASH]");
|
|
furi_hal_console_puts("\r\n\033[0;31m[CRASH]");
|
|
|
__furi_print_name();
|
|
__furi_print_name();
|
|
|
- furi_hal_console_puts(message ? message : "Programming Error");
|
|
|
|
|
|
|
+ furi_hal_console_puts(message);
|
|
|
|
|
+#ifdef FURI_DEBUG
|
|
|
furi_hal_console_puts("\r\nSystem halted. Connect debugger for more info\r\n");
|
|
furi_hal_console_puts("\r\nSystem halted. Connect debugger for more info\r\n");
|
|
|
furi_hal_console_puts("\033[0m\r\n");
|
|
furi_hal_console_puts("\033[0m\r\n");
|
|
|
- __furi_abort();
|
|
|
|
|
|
|
+ __furi_halt();
|
|
|
|
|
+#else
|
|
|
|
|
+ furi_hal_rtc_set_fault_data((uint32_t)message);
|
|
|
|
|
+ furi_hal_console_puts("\r\nRebooting system.\r\n");
|
|
|
|
|
+ furi_hal_console_puts("\033[0m\r\n");
|
|
|
|
|
+ NVIC_SystemReset();
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|