STM8 用printf代替uart方法
#ifdef__GNUC__
#definePUTCHAR_PROTOTYPEint__io_putchar(intch)
#else
#definePUTCHAR_PROTOTYPEintfputc(intch,FILE*f)
#endif
PUTCHAR_PROTOTYPE
{
//发送数据代码
returnch;
}
出现identifier "FILE" is undefined,工程option中,如下选折:
需要在 IAR的Options -> General Options ->Library Configuration里设置一下函数库,不然printf函数不对,将Library Configuration 中的Library 设置由"Normal"改为"Full"就可以了。
评论