stm32 uart 導向至 printf
讓stm32 可以使用 printf 輸出
stm32cubeMX安裝的套件包路徑
repository/stm32cube_fw-fw_v1.8.5/projects/stm32f103rb-nucleo/example/uart/uart_printf
可以找到範例
#ifdef __GNUC__ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif /* __GNUC__ */ PUTCHAR_PROTOTYPE { HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); return ch; }
還要記得加入 syscalls.c 到 core/src/ 路徑底下
修改 makefile C_SOURCES 加入 Core/Src/syscalls.c
留言
張貼留言