方法2--不使用微库(那么就要强调不使用半主机(no semihosting)模式)
1、在调用printf的文件中#include "stdio.h"2、重写fputc,但需要先加点东西:
#include"stdio.h"#pragmaimport(__use_no_semihosting)struct__FILE{int handle;};
FILE __stdout;
FILE __stdin;//int _sys_exit(int x)void_sys_exit(int x){
x = x;}intfputc(int ch, FILE *f){/* Place your implementation of fputc here *//* e.g. write a character to the USART */USART_SendData(Open_USART,(uint8_t) ch);/* Loop until the end of transmission */while(USART_GetFlagStatus(Open_USART, USART_FLAG_TC)== RESET){}return ch;}
这样,就完成了,同样可以使用printf语句了~