8aeafd8179
* hal-related task_is_isr_context function * furi_check implementation * change application to use furi_check * add second level of assertion * add TODO about ISR context * Applications: refactor furi_check and furi_assert. * Apploader: propwer widget usage. Menu: check on furi resource request. * refactor furi_check Co-authored-by: Aleksandr Kutuzov <aku@plooks.com> Co-authored-by: coreglitch <mail@s3f.ru>
41 lines
1000 B
C
41 lines
1000 B
C
#include "check.h"
|
|
#include "api-hal-task.h"
|
|
|
|
void __furi_abort(void);
|
|
|
|
// TODO printf doesnt work in ISR context
|
|
void __furi_check(void) {
|
|
printf("assertion failed in release mode, switch to debug mode to see full assert info");
|
|
__furi_abort();
|
|
}
|
|
|
|
// TODO printf doesnt work in ISR context
|
|
void __furi_check_debug(const char* file, int line, const char* function, const char* condition) {
|
|
printf(
|
|
"assertion \"%s\" failed: file \"%s\", line %d%s%s",
|
|
condition,
|
|
file,
|
|
line,
|
|
function ? ", function: " : "",
|
|
function ? function : "");
|
|
|
|
if(task_is_isr_context()) {
|
|
printf(" in [ISR] context");
|
|
} else {
|
|
FuriApp* app = find_task(xTaskGetCurrentTaskHandle());
|
|
|
|
if(app == NULL) {
|
|
printf(", in [main] context");
|
|
} else {
|
|
printf(", in [%s] app context", app->name);
|
|
}
|
|
}
|
|
|
|
__furi_abort();
|
|
}
|
|
|
|
void __furi_abort(void) {
|
|
taskDISABLE_INTERRUPTS();
|
|
while(1) {
|
|
}
|
|
} |