- 添加watchdog组件用于系统监控 - 在system_gd32e50x.c中增加USART0诊断输出,在IRC8M和PLL配置后 发送"APP"和"CLK"标识 - 优化AppSpiCommand类中的日志处理机制,使用临界区保护 - 添加对全0xFF数据包的过滤处理,避免无效命令处理 - 将OTA重启延时从滴答计数改为毫秒级延时,提高响应速度 - 移除温度传感器相关文件,添加看门狗相关文件到项目配置 - 更新FWDGT API调用方式,使用新的配置函数 - 增加详细的启动日志输出,便于调试和追踪初始化过程
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#ifndef DEVICE_APP_SPI_COMMAND_H
|
||
#define DEVICE_APP_SPI_COMMAND_H
|
||
|
||
#include <stdint.h>
|
||
|
||
/**
|
||
* @brief APP 运行期 SPI 命令从机模块。
|
||
*
|
||
* 复用 BOOT 的 SpiOta 协议帧格式(SOF+TYPE+LEN+PAYLOAD+CRC):
|
||
* - TYPE=0xB0 → 请求进入 Bootloader,回复 ACK 帧
|
||
* - TYPE=0x01/0x02/0x03(OTA 命令)→ 回复 WAIT 帧(不在 BOOT 模式)
|
||
* - 旧式单字节 0xB0 命令仍兼容
|
||
*
|
||
* 调试日志采用延迟输出:processCommand() 只写缓冲+置标志,
|
||
* poll() 中再 printf,避免在帧处理路径上耗时。
|
||
*/
|
||
class AppSpiCommand {
|
||
public:
|
||
/** @brief 初始化 SPI0 从机命令通道。 */
|
||
static void init();
|
||
|
||
/** @brief 主循环轮询:打印延迟日志。 */
|
||
static void poll();
|
||
|
||
/** @brief SPI0 中断处理入口。 */
|
||
static void onInterrupt();
|
||
|
||
/** @brief CS 边沿中断处理入口。 */
|
||
static void onCsExtiInterrupt();
|
||
|
||
private:
|
||
static constexpr uint16_t kRxBufSize = 128U;
|
||
static constexpr uint16_t kTxBufSize = 64U;
|
||
static constexpr uint16_t kLogBufSize = 128U;
|
||
|
||
static volatile bool s_csActive;
|
||
static volatile uint8_t s_rxLen;
|
||
static volatile uint8_t s_txLen;
|
||
static volatile uint8_t s_txPos;
|
||
static volatile bool s_logPending;
|
||
static uint8_t s_rxBuf[kRxBufSize];
|
||
static uint8_t s_txBuf[kTxBufSize];
|
||
static char s_logBuf[kLogBufSize];
|
||
|
||
static void configureGpio();
|
||
static void configureSpi0();
|
||
static void configureExti();
|
||
static void onCsAssert();
|
||
static void onCsRelease();
|
||
static void processCommand();
|
||
static void logDeferred(const char *msg);
|
||
static void logDeferredFmt(const char *fmt, uint8_t val);
|
||
};
|
||
|
||
#endif /* DEVICE_APP_SPI_COMMAND_H */
|