#ifndef SYS_SYSTICK_H #define SYS_SYSTICK_H #include /** * @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 */