You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.5 KiB

12 months ago
12 months ago
12 months ago
12 months ago
  1. #pragma once
  2. #include "cmsis_os.h"
  3. #include "stm32basic/stm32basic.hpp"
  4. namespace iflytop {
  5. class ZTaskInfo {
  6. public:
  7. osThreadId Id;
  8. };
  9. typedef enum {
  10. kreset_reason_pinrst = 1, // NRST引脚复位
  11. kreset_reason_porrst = 2, // 上电掉电复位
  12. kreset_reason_sftrst = 3, // 软件复位
  13. kreset_reason_iwdgrst = 4, // 独立看门狗复位
  14. kreset_reason_wwdgrst = 5, // 窗口看门狗复位
  15. kreset_reason_lpwrrst = 6, // 低功耗复位
  16. kreset_reason_unkown = 7, //
  17. } reset_reason_t;
  18. class SysMgr {
  19. private:
  20. /* data */
  21. public:
  22. ZTaskInfo m_task[30] = {0};
  23. int m_ntask = 0;
  24. reset_reason_t m_reset_reason = kreset_reason_unkown;
  25. static SysMgr* ins();
  26. void initedFinished();
  27. void dumpSysInfo();
  28. size_t osGetSysRunTime();
  29. /***********************************************************************************************************************
  30. * HeapMgr *
  31. ***********************************************************************************************************************/
  32. size_t osGetMinimumEverFreeHeapSize();
  33. size_t osGetFreeHeapSize();
  34. size_t osGetTotalHeapSize();
  35. size_t osGetFreeSysHeapSize();
  36. /***********************************************************************************************************************
  37. * TaskInfo *
  38. ***********************************************************************************************************************/
  39. osThreadId osGetId(int offset);
  40. uint32_t osTaskStackRemainingSize(osThreadId id);
  41. const char* osTaskName(osThreadId id);
  42. void osTaskName(osThreadId id, char* name, int bufsize);
  43. void osTaskStackRemainingSize(osThreadId id, uint16_t* remainsize);
  44. void osTaskPriority(osThreadId id, uint16_t* priority);
  45. void osTaskGetState(osThreadId id, char* state);
  46. int32_t getTaskNum();
  47. /***********************************************************************************************************************
  48. * CHIP *
  49. ***********************************************************************************************************************/
  50. reset_reason_t chipGetResetReason() { return m_reset_reason; }
  51. private:
  52. void checkRst(void);
  53. };
  54. } // namespace iflytop