使用环境HAL+UCOSIII
- USATRT.C中添加#include "stdio.h"
/* Includes ------------------------------------------------------------------*/ #include "usart.h" /* USER CODE BEGIN 0 */ #include "stdio.h" /* USER CODE END 0 */
- USATRT.C中添加如下代码
//重写printf
/* USER CODE BEGIN 1 */
int fputc(int ch,FILE *f){
HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,0xffff);
return ch;
}
/* USER CODE END 1 */
/* USER CODE END 1 */
3.MAIN.C中添加测试