【记录】STM32在IAR中调用之printf函数的一个方法

来源:互联网 发布:java时间戳精确到秒 编辑:程序博客网 时间:2024/06/01 10:39

原文地址:http://blog.sina.com.cn/s/blog_668bcb8f01018ect.html
在串口都配置好的情况下,在main.c文件中加入

#include <stdio.h>#ifdef __GNUC__  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)#else  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)#endifPUTCHAR_PROTOTYPE{  USART_SendData(USART1, (u16) ch);  while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)  {}  return ch;}

之后如若编译出现identifier “FILE” is undefined,即将Options->GeneralOptions->Library Configuation中的Library选为full即可。

0 0