furi_check - a new way to asserting (#204)
* 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>
This commit is contained in:
41
core/api-basic/check.c
Normal file
41
core/api-basic/check.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#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) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user