stm32 IAR环境printf函数调用

来源:互联网 发布:java string byte数组 编辑:程序博客网 时间:2024/05/16 20:30

在串口都配置好的情况下,在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)
#endif

 

PUTCHAR_PROTOTYPE
{
 
 
  USART_SendData(EVAL_COM1, (uint8_t) ch);

 
  while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
  {}

  return ch;
}


 

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

0 0
原创粉丝点击