debug.c 797 B

1234567891011121314151617181920
  1. #include <stdio.h>
  2. /*
  3. #define ITM_PORT8(n) (*(volatile unsigned char *)(0xe0000000 + 4*(n)))
  4. #define ITM_PORT16(n) (*(volatile unsigned short *)(0xe0000000 + 4*(n)))
  5. #define ITM_PORT32(n) (*(volatile unsigned long *)(0xe0000000 + 4*(n)))
  6. #define DEMCR (*(volatile unsigned long *)(0xE000EDFC))
  7. #define TRCENA 0X01000000
  8. int fputc(int ch, FILE *f)
  9. {
  10. if(DEMCR & TRCENA)
  11. {
  12. while(ITM_PORT32(0) == 0);
  13. ITM_PORT8(0) = ch;
  14. }
  15. return ch;
  16. }
  17. */