STM32串口使用Printf()函数问题.pdfVIP

  • 4
  • 0
  • 约 2页
  • 2017-07-01 发布于天津
  • 举报
STM32串口使用Printf()函数问题.pdf

标准库函数的默认输出设备是显示器,要实现在串口或 LCD 输出,必须重定义标准库函数里调用的与输出 设备相关的函数. 例如:printf 输出到串口,需要将 fputc 里面的输出指向串口(重定向),方法如下: 只要自己添加一个 int fputc(int ch, FILE *f)函数,能够输出字符就可以了 #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__ */ PUTCHAR_PROTOTYPE { /* Place your implementation of fputc here */ /* e.g. write a cha

文档评论(0)

1亿VIP精品文档

相关文档