/** * @file app_freertos.h * @brief FreeRTOS 运行信息查看(任务/堆/CPU占用) * * 说明: * - 参考 `CCU601E_RUN/BSP/freertos/app_freertos.c` 的用途,在 Shell 中提供 `ps` 命令 * - 本工程接入任务看门狗统计,`wdtCount` 为各任务实时看门狗计数值 */ #ifndef APP_FREERTOS_H #define APP_FREERTOS_H #include "FreeRTOS.h" /* 单任务信息快照 */ typedef struct { char taskName[configMAX_TASK_NAME_LEN]; char state; unsigned int id; unsigned int priority; unsigned int cycle; /* 任务周期(ms) - 来自任务表 */ unsigned int allocatedStack; /* 分配堆栈大小(字节) - 来自任务表 */ unsigned int wdtCount; /* 看门狗计数(秒级累加,实时读取) */ unsigned int minFreeStack; /* 最小剩余堆栈(字节) */ unsigned int stackUsagePercentage; /* 堆栈使用百分比 */ unsigned int cpuUsagePercentage; /* CPU使用百分比 */ } TaskInfo_t; /* 系统信息快照 */ typedef struct { TaskInfo_t *tasks; /* 任务数组 */ unsigned int taskCount; /* 任务数量 */ unsigned int freeHeapSize; /* 当前剩余堆空间 */ unsigned int minEverFreeHeapSize; /* 历史最小剩余堆 */ unsigned int totalAllocatedStack; /* 已知分配任务空间(字节) */ unsigned int totalHeapSize; /* 总堆空间大小(字节) */ } SystemInfo_t; SystemInfo_t *getSystemInfo(void); void freeSystemInfo(SystemInfo_t *sysInfo); void printSystemInfo(void); #endif /* APP_FREERTOS_H */