check.c 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "check.h"
  2. #include "api-hal-task.h"
  3. void __furi_abort(void);
  4. // TODO printf doesnt work in ISR context
  5. void __furi_check(void) {
  6. printf("assertion failed in release mode, switch to debug mode to see full assert info");
  7. __furi_abort();
  8. }
  9. // TODO printf doesnt work in ISR context
  10. void __furi_check_debug(const char* file, int line, const char* function, const char* condition) {
  11. printf(
  12. "assertion \"%s\" failed: file \"%s\", line %d%s%s",
  13. condition,
  14. file,
  15. line,
  16. function ? ", function: " : "",
  17. function ? function : "");
  18. if(task_is_isr_context()) {
  19. printf(" in [ISR] context");
  20. } else {
  21. FuriApp* app = find_task(xTaskGetCurrentTaskHandle());
  22. if(app == NULL) {
  23. printf(", in [main] context");
  24. } else {
  25. printf(", in [%s] app context", app->name);
  26. }
  27. }
  28. __furi_abort();
  29. }
  30. void __furi_abort(void) {
  31. taskDISABLE_INTERRUPTS();
  32. while(1) {
  33. }
  34. }