你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32 fprint的使用问题

[复制链接]
hbzjt2012 提问时间:2015-4-30 11:22 /
我知道在stm32的程序中包含标准的stdio.h文件,对fprint函数重写,就可以使用fprint函数打印串口输出内容,具体是怎么实现的呢?
收藏 评论4 发布时间:2015-4-30 11:22

举报

4个回答
小蚂蚁快溜跑 回答时间:2015-4-30 12:05:58
添加Retarget.c文件,修改fputc函数
stary666 回答时间:2015-4-30 12:43:23
自己添加就行
hbzjt2012 回答时间:2015-4-30 13:11:07
小蚂蚁快溜跑 发表于 2015-4-30 12:05
添加Retarget.c文件,修改fputc函数

  1. #ifdef __GNUC__
  2. // With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar()
  3. #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
  4. #else
  5. #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
  6. #endif /* __GNUC__ */

  7. PUTCHAR_PROTOTYPE
  8. {
  9. #ifdef Gokit
  10.         //Place your implementation of fputc here , e.g. write a character to the USART
  11.         USART_SendData(USART1,(u8)ch);
  12.         //Loop until the end of transmission
  13.         while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
  14. #endif       
  15.        
  16. #ifdef STUNO
  17.         //Place your implementation of fputc here , e.g. write a character to the USART
  18.         USART_SendData(USART1,(u8)ch);
  19.         //Loop until the end of transmission
  20.         while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
  21. #endif
  22.        
  23. #ifdef Xnucleo
  24.         //Place your implementation of fputc here , e.g. write a character to the USART
  25.         USART_SendData(USART3,(u8)ch);
  26.         //Loop until the end of transmission
  27.         while (USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);       
  28. #endif
复制代码
是这样。
小蚂蚁快溜跑 回答时间:2015-5-2 21:18:03

无返回值啊

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版