Implement ITM debug via ST-Link

- Enable Instrumentation Trace Macroblock
- Remove PB3 initialization conflict with ITM
- Add a bunch of debug prints
This commit is contained in:
2026-06-17 18:04:48 +02:00
parent d69cb0231b
commit 84ea393dd6
2 changed files with 42 additions and 9 deletions
+18
View File
@@ -24,6 +24,24 @@
extern "C" {
#endif
#define DEBUG
#ifdef DEBUG
static inline void ITM_Print(const char *str) {
while (*str) {
uint32_t timeout = 1000;
while ((ITM->PORT[0].u32 == 0) && (timeout-- > 0));
if (timeout > 0) {
ITM->PORT[0].u8 = (uint8_t)(*str);
}
str++;
}
}
#define DEBUG_PRINT(x) ITM_Print(x)
#else
#define DEBUG_PRINT(x)
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
#include "canlog.h"