打印
[其他ST产品]

SW4STM32下使用printf发送消息,将消息用串口助手接收

[复制链接]
116|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
麻花油条|  楼主 | 2023-1-12 10:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
问题描述:
在keil环境下正常使用printf功能,但是在SW4STM32下使用不了,下面是添加到uart.c里面的重定向语句
#ifdef __GNUC__
  /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/**
  * @brief  Retargets the C library printf function to the USART.
  * @param  None
  * @retval None
  */
PUTCHAR_PROTOTYPE
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
  HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);

  return ch;
}
如何才能正常使用printf呢?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

262

主题

1384

帖子

2

粉丝