3.27_433:添加UART2调试打印、IO监控、指令解析和继电器控制模块。

能够接收UART2指令控制继电器开关,或向UART2发送四路IO输入状态,并使用轮询方式检测IO状态进行及时反馈。
This commit is contained in:
2026-03-27 10:09:13 +08:00
parent f548593c59
commit 71027ebc46
76 changed files with 6789 additions and 1803 deletions

99
Core/Inc/uart2_print.h Normal file
View File

@ -0,0 +1,99 @@
/**
******************************************************************************
* @file uart2_print.h
* @brief UART2调试打印模块头文件
* @author Application Layer
* @version 1.0
******************************************************************************
* @attention
* 本模块提供基于环形缓冲区的非阻塞调试信息输出功能
* 支持printf风格的格式化输出
* 支持中断安全调用
******************************************************************************
*/
#ifndef __UART2_PRINT_H
#define __UART2_PRINT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
#define UART2_TX_BUFFER_SIZE 256
/**
* @brief 初始化UART2打印模块
* @note 清空发送缓冲区,重置状态标志
* @param 无
* @retval 无
*/
void UART2_Print_Init(void);
/**
* @brief 发送原始数据到UART2
* @note 数据写入环形缓冲区,非阻塞返回
* @param data: 待发送的数据指针
* @param len: 数据长度
* @retval 无
*/
void UART2_Print_Send(const uint8_t *data, uint16_t len);
/**
* @brief 发送字符串到UART2
* @note 自动计算字符串长度
* @param str: 待发送的字符串指针
* @retval 无
*/
void UART2_Print_String(const char *str);
/**
* @brief 格式化打印到UART2
* @note 支持printf风格的格式化输出
* @param fmt: 格式化字符串
* @param ...: 可变参数
* @retval 无
*/
void UART2_Print_Printf(const char *fmt, ...);
/**
* @brief UART2打印任务处理函数
* @note 在主循环中调用,处理发送缓冲区中的数据
* 每次调用发送一个字节(中断方式)
* @param 无
* @retval 无
*/
void UART2_Print_Task(void);
/**
* @brief 检查UART2是否正在发送
* @note 用于查询当前发送状态
* @param 无
* @retval true: 正在发送, false: 空闲
*/
bool UART2_Print_IsBusy(void);
/**
* @brief 获取发送缓冲区剩余空间
* @note 用于检测缓冲区是否即将溢出
* @param 无
* @retval 剩余空间字节数
*/
uint16_t UART2_Print_Available(void);
/**
* @brief UART2发送完成中断回调
* @note 由HAL库调用不应由用户直接调用
* @param huart: UART句柄指针
* @retval 无
*/
void UART2_Print_TxCpltCallback(void);
#ifdef __cplusplus
}
#endif
#endif