Files
DCU_APP/GD32E508_DCU_APP/sys/task_manager.h
T
cbb 76da7a3dd6 Refactor and clean up codebase
- Removed unused constants and type aliases in app_spi_command_defs.h and temp_sensor.h.
- Simplified ISpiCommandHandler destructor to default.
- Eliminated redundant methods and comments in temp_sensor and usart0 files.
- Consolidated writeU32Le function to app_spi_command_defs.h for reuse.
- Updated comments for clarity and accuracy in task_manager.h and task_runner.cpp.
- Removed hardfault.h as it contained no declarations.
- Cleaned up CANFD and watchdog implementations by removing dead code and unnecessary comments.
- Updated version numbers in config.h to reflect recent changes.
- Enhanced error handling and diagnostics in hardfault handling.
2026-07-15 02:49:37 +08:00

60 lines
1.8 KiB
C++

#ifndef SYS_TASK_MANAGER_H
#define SYS_TASK_MANAGER_H
#include <stdint.h>
#include "main.h"
/**
* @brief 任务调度管理器。
* @note 负责维护各类节拍计数器与待执行任务位图,由定时器中断与主循环共享访问。
*/
class TaskManager {
public:
/**
* @brief 初始化调度器内部状态。
* @param[in] 无。
* @param[out] 无。
* @retval 无返回值。
* @note 将所有节拍计数器和任务标志位清零。
*/
static void init();
/**
* @brief 推进一次 100us 调度节拍。
* @param[in] 无。
* @param[out] 无。
* @retval 无返回值。
* @note 由 TIMER2 ISR 调用;按周期分档置位 ADC/CAN/LED/心跳/诊断等任务标志。
*/
static void tick100us();
/**
* @brief 原子地取出当前所有待执行任务位图并清零。
* @param[in] 无。
* @param[out] 无。
* @retval uint32_t 返回当前待执行任务位图。
* @note 内部通过关中断保证原子性,供 TaskRunner 消费。
*/
static uint32_t takePending();
/**
* @brief 置位一个或多个待执行任务标志。
* @param[in] taskMask 待置位的任务位图掩码。
* @param[out] 无。
* @retval 无返回值。
* @note 内部通过 BASEPRI 临界区(RT_CRITICAL_SAVE/RESTORE)保证可由主循环与 ISR 共享调用。
*/
static void set(uint32_t taskMask);
/**
* @brief 获取全局调度器状态对象引用。
* @param[in] 无。
* @param[out] 无。
* @retval task_scheduler_t& 全局调度器状态对象的引用。
* @note 提供外部模块对调度状态的可观型访问。
*/
static task_scheduler_t &state();
};
#endif /* SYS_TASK_MANAGER_H */