- 添加SPI OTA同步协议,使用新的帧格式包含信用控制和CRC32校验 - 实现BOOT主动按铃功能,通过SPI Ready线通知ESP32读取数据 - 添加按铃超时保护机制,防止死锁情况发生 - 优化SPI中断处理,统一在CS释放时处理帧避免RX溢出错误 - 修改GPIO配置为开漏输出模式,实现硬件握手信号 - 添加同步帧解析功能,支持帧头偏移扫描和完整性校验 - 实现信用控制机制,当flash缓冲区满时阻止ESP32继续发送数据 - 修复BOOT命令响应逻辑,确保一致性处理裸字节和帧式命令 - 将OTA完成验证移到主循环处理,避免SPI ready线阻塞过久 - 添加详细的调试日志输出便于问题排查 refactor(SpiOta): 重构SPI OTA协议栈 - 使用CRC32替代CRC8进行帧校验,提高数据完整性 - 重命名帧相关常量以匹配新的同步协议格式 - 移除旧的帧处理方法,采用新的同步帧解析流程 - 添加大小端转换辅助函数用于数据编码解码 - 优化内存布局减少RAM使用 - 统一错误处理流程,添加帧校验失败日志记录
90 lines
1.8 KiB
C++
90 lines
1.8 KiB
C++
#ifndef SYSTICK_H
|
|
#define SYSTICK_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief Bootloader SysTick 时基模块。
|
|
*
|
|
* 负责提供毫秒节拍、阻塞延时与软复位能力。
|
|
*/
|
|
class SysTickTimer {
|
|
public:
|
|
/** @brief 初始化 1ms SysTick 节拍。 */
|
|
static void init();
|
|
/** @brief 毫秒阻塞延时。 */
|
|
static void delayMs(uint32_t count);
|
|
/** @brief 微秒级粗略阻塞延时。 */
|
|
static void delayUs(uint32_t count);
|
|
/** @brief 秒级阻塞延时。 */
|
|
static void delaySeconds(uint32_t count);
|
|
/** @brief 递减毫秒倒计时。 */
|
|
static void decrement();
|
|
/** @brief SysTick 中断实际处理逻辑。 */
|
|
static void onInterrupt();
|
|
/** @brief 触发软件复位。 */
|
|
static void softReset();
|
|
/** @brief 获取上电以来的毫秒数。
|
|
* @note 供按铃超时等非阻塞超时场景使用,不用于精确阻塞延时。 */
|
|
static uint32_t getMs();
|
|
|
|
private:
|
|
static volatile uint32_t s_delayCountdown;
|
|
static volatile uint32_t s_msTicks;
|
|
};
|
|
|
|
/**
|
|
* @brief 配置 SysTick 为 1ms 周期中断。
|
|
*
|
|
* @return 无。
|
|
*/
|
|
void systick_config(void);
|
|
|
|
/**
|
|
* @brief 执行毫秒级阻塞延时。
|
|
*
|
|
* @param count 延时毫秒数。
|
|
* @return 无。
|
|
*/
|
|
void delay_1ms(uint32_t count);
|
|
|
|
/**
|
|
* @brief 执行微秒级粗略阻塞延时。
|
|
*
|
|
* @param count 延时微秒数。
|
|
* @return 无。
|
|
*/
|
|
void delay_1us(uint32_t count);
|
|
|
|
/**
|
|
* @brief 执行秒级阻塞延时。
|
|
*
|
|
* @param count 延时秒数。
|
|
* @return 无。
|
|
*/
|
|
void delay_1s(uint32_t count);
|
|
|
|
/**
|
|
* @brief 递减 SysTick 维护的毫秒倒计时。
|
|
*
|
|
* @return 无。
|
|
*/
|
|
void delay_decrement(void);
|
|
|
|
/**
|
|
* @brief 触发 MCU 软件复位。
|
|
*
|
|
* @return 无。
|
|
*/
|
|
void system_soft_reset(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|