- 实现新的SPI同步帧格式,采用0xA5 0x5A起始符和CRC32校验,提升通信可靠性 - 添加GD32与ESP32间的握手机制,通过PB6开漏输出实现SPIready线与控制 - 实现异步OTA启动机制,将Flash操作延迟到主循环执行,避免SPI ISR阻塞 - 改进CAN反馈命令处理,提取通用payload构建函数支持主动推送模式 - 实现GD32主动按铃机制,循环推送CAN反馈数据到ESP32,减少轮询开销 - 添加SPI通信超时保护和死锁防护机制,确保系统稳定性
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#ifndef SYS_SYSTICK_H
|
|
#define SYS_SYSTICK_H
|
|
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief SysTick 时基模块。
|
|
* @note 负责 1ms 系统节拍维护与阻塞式毫秒延时。
|
|
*/
|
|
class SysTickTimer {
|
|
public:
|
|
/**
|
|
* @brief 初始化 SysTick 为 1ms 系统节拍。
|
|
* @param[in] 无。
|
|
* @param[out] 无。
|
|
* @retval 无返回值。
|
|
*/
|
|
static void initMs();
|
|
|
|
/**
|
|
* @brief 执行阻塞式毫秒延时。
|
|
* @param[in] ms 需要延时的毫秒数。
|
|
* @param[out] 无。
|
|
* @retval 无返回值。
|
|
* @note 基于 1ms 中断递增的节拍计数器实现轮询延时。
|
|
*/
|
|
static void delayMs(uint32_t ms);
|
|
|
|
/**
|
|
* @brief SysTick 中断处理入口。
|
|
* @param[in] 无。
|
|
* @param[out] 无。
|
|
* @retval 无返回值。
|
|
* @note 每毫秒递增内部节拍计数器。
|
|
*/
|
|
static void onInterrupt();
|
|
|
|
/**
|
|
* @brief 获取当前系统毫秒节拍数。
|
|
* @return 自启动以来的毫秒数(32 位回绕)。
|
|
* @note 用于超时判定(如 SPI 按铃看护)。读取 volatile 原子。
|
|
*/
|
|
static uint32_t getMs() { return s_ms; }
|
|
|
|
private:
|
|
static volatile uint32_t s_ms;
|
|
};
|
|
|
|
#endif /* SYS_SYSTICK_H */ |