utility.c 685 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "FreeRTOS.h"
  2. #include "task.h"
  3. #include "queue.h"
  4. #include "semphr.h"
  5. #include "utility.h"
  6. #include "at32f403a_407_int.h"
  7. #include <stdio.h>
  8. #if 1
  9. // OS stack overflow hook
  10. #if (configCHECK_FOR_STACK_OVERFLOW > 0)
  11. void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
  12. {
  13. NVIC_SystemReset();
  14. }
  15. #endif
  16. #endif
  17. // OS malloc failed hook
  18. #if (configUSE_MALLOC_FAILED_HOOK > 0)
  19. void vApplicationMallocFailedHook(void)
  20. {
  21. NVIC_SystemReset();
  22. while(1);
  23. }
  24. #endif
  25. //
  26. void print_binary_byte(uint8_t val)
  27. {
  28. for (int i = 7; i >= 0; i--)
  29. {
  30. if (val & (1 << i))
  31. printf("1");
  32. else
  33. printf("0");
  34. }
  35. }