keil使用printf重定义方法

在usart.c文件底部添加一下代码

#include "stdio.h"

int fputc(int ch,FILE *f)
{
    HAL_UART_Transmit(&huart1,(uint8_t*)&ch,1,10);
    return(ch);
}

其中&huart1是你所使用的串口指针,添加代码后会报错FILE *f未定义,需要添加引用#include "stdio.h"

posted @ 2020-06-11 12:38  超强磁铁  阅读(1818)  评论(0)    收藏  举报