网址:https://blog.csdn.net/qq_36075612/article/details/96851644
一、添加printf打印输出
1、在使用STM32Cubde 生成好代码中usart.c中添加,如下的代码即可:
/* USER CODE BEGIN 1 */
#include "stdio.h"
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t*)&ch, 1, HAL_MAX_DELAY);
return ch;
}
#endif
/* USER CODE END 1 */
2、配置下载器连接
image
image
3、打印结果:
image
4、支持float类型打印,配置
image
image
5、main.c文件
image
6、float类型打印结果:
image
二、添加自定义的文件夹
image
2.1、添加h文件
image
image
image
image
image
image
image
记得要点击窗口右下角的Apply and Close按钮,接着最后一步需要验证,刚刚的添加进来的文件是否到工程项目中来了。
image