在代码调试过程中,经常使用 printf 函数输出调试信息。我们重定义 printf 函数,通过串口输出调试信息。
step1 main.c 文件中添加头文件
#include "stdio.h"
step2 重定义 fputc 函数,代码添加至 main.c
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar
STM32 HAL库实现printf串口调试
本文介绍了如何在STM32开发中利用HAL库重定向printf函数,通过串口进行调试信息的打印。步骤包括添加头文件、重定义printf函数,并展示了实际的输出示例。
在代码调试过程中,经常使用 printf 函数输出调试信息。我们重定义 printf 函数,通过串口输出调试信息。
step1 main.c 文件中添加头文件
#include "stdio.h"
step2 重定义 fputc 函数,代码添加至 main.c
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar
1703

被折叠的 条评论
为什么被折叠?