stm32 printf 重定向

https://www.digikey.cn/zh/forum/t/topic/2855

#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif

PUTCHAR_PROTOTYPE
{
  HAL_UART_Transmit(&huart?, (uint8_t *)&ch, 1, HAL_MAX_DELAY); //? 为uart编号
  return ch;
}

 

posted @ 2024-10-06 15:07  微笑的''80  阅读(9)  评论(0)    收藏  举报