2、重定义函数
你要输出信息,肯定要有路径才行啊,是UART,还是CAN,所以就需要重定义函数才行。
以UART串口为例,最常见一种方式:
- #include <stdio.h>
- int fputc(int ch, FILE *f)
- {
- DEBUG_SendByte((uint8_t)ch);
- return ch;
- }
- int fgetc(FILE *f)
- {
- while(USART_GetFlagStatus(DEBUG_COM, USART_FLAG_RXNE) == RESET);
- return (int)USART_ReceiveData(DEBUG_COM);
- }
当然,串口里面具体的实现方式,与你底层有关。
有以上配置,就可以直接使用printf函数了。
|