check.c 1.0 KB

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