unleashed-firmware/core/api-basic/check.c
DrZlo13 8aeafd8179
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>
2020-10-29 09:27:17 +03:00

41 lines
No EOL
1,000 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) {
}
}