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.

129 lines
3.5 KiB

12 months ago
12 months ago
12 months ago
4 weeks ago
12 months ago
12 months ago
12 months ago
4 weeks ago
12 months ago
4 weeks ago
1 month ago
12 months ago
4 weeks ago
12 months ago
4 weeks ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
  1. #include <stddef.h>
  2. #include <stdio.h>
  3. //
  4. #include "base/appdep.hpp"
  5. //
  6. #include "app/dmapp.hpp"
  7. #include "app/ext_ch_selector_app.hpp"
  8. #include "app/exth2o2_sensor.hpp"
  9. //
  10. #include "board/public_board.hpp"
  11. //
  12. #include "base/protocol_processer_mgr.hpp"
  13. #include "protocol_processer_impl/public_cmd_processer.hpp"
  14. #include "version.hpp"
  15. //
  16. #define TAG "main"
  17. using namespace iflytop;
  18. extern void umain();
  19. extern "C" {
  20. void StartDefaultTask(void const* argument) { umain(); }
  21. }
  22. /*******************************************************************************
  23. * MAIN *
  24. *******************************************************************************/
  25. extern "C" {
  26. }
  27. void debug_light_ctrl() {
  28. static uint32_t lastcall = 0;
  29. static bool light_status = false;
  30. if (!gInitErrorFlag) {
  31. if (zhas_passedms(lastcall) > 300) {
  32. PublicBoard::ins()->toggleDebugLight();
  33. lastcall = zget_ticket();
  34. }
  35. } else {
  36. if (zhas_passedms(lastcall) > 30) {
  37. PublicBoard::ins()->toggleDebugLight();
  38. lastcall = zget_ticket();
  39. }
  40. }
  41. }
  42. #define REG_PROCESSER(processer) ProtocolProcesserMgr::ins()->regProcesser(processer);
  43. /* IWDG init function */
  44. void MX_IWDG_Init(void) {
  45. hiwdg.Instance = IWDG;
  46. hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
  47. hiwdg.Init.Reload = 501;
  48. if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
  49. Error_Handler();
  50. }
  51. }
  52. void umain() {
  53. gBoardFlagSetResetFlag();
  54. PORT::idtable_init();
  55. deviceInfo_init();
  56. // config_init();
  57. AppPeriodTaskMgr::ins()->initialize();
  58. PublicBoard::ins()->initialize();
  59. ZLOGI(TAG, "======================= boardinfo ==================== ");
  60. ZLOGI(TAG, "project : %s ", PROJECT);
  61. ZLOGI(TAG, "version : %d ", SOFTWARE_VERSION);
  62. ZLOGI(TAG, "pversion : %d", deviceInfo_getProtocolVersion());
  63. ZLOGI(TAG, "sn : %s", sn_get_str());
  64. ZLOGI(TAG, "boardTypeId : %s(%d)", BoardTypeId2Str(PublicBoard::ins()->getBoardTypeId()), PublicBoard::ins()->getBoardTypeId());
  65. ZLOGI(TAG, "boardId : %d", PublicBoard::ins()->getBoardId());
  66. ZLOGI(TAG, "=");
  67. zcanbus_init(PublicBoard::ins()->getBoardId());
  68. ProtocolProcesserMgr::ins()->initialize();
  69. PublicCmdProcesser::ins()->initialize();
  70. switch (PublicBoard::ins()->getBoardTypeId()) {
  71. case DT100N_LC_Board:
  72. case DT100N_PC_Board:
  73. // not suppport now
  74. gInitErrorFlag = true;
  75. break;
  76. case DT600N_LC_Board:
  77. case DT600N_PC_Board:
  78. case DT300N_LC_Board:
  79. case DT300N_PC_Board:
  80. case DT300W_LC_Board:
  81. case DT300W_PC_Board:
  82. case DT600B_LC_BOARD:
  83. case DT600B_PC_BOARD:
  84. DisinfectionApp::ins()->initialize();
  85. break;
  86. case DT100N_EXT_CH_SELECTOR:
  87. ExtChSelector::ins()->initialize();
  88. break;
  89. case EX_H2O2_SENSOR_BOARD:
  90. ExtH2O2Sensor::ins()->initialize();
  91. break;
  92. default:
  93. gInitErrorFlag = true;
  94. break;
  95. }
  96. ZLOGI(TAG, "======================= init processer ================ ");
  97. ProtocolProcesserMgr::ins()->startSchedule(PublicBoard::ins()->getBoardId());
  98. ZLOGI(TAG, "=");
  99. AppPeriodTaskMgr::ins()->startScheduler();
  100. ZLOGI(TAG, "======================= sysinfo ======================= ");
  101. SysMgr::ins()->initedFinished();
  102. SysMgr::ins()->dumpSysInfo();
  103. ZLOGI(TAG, "=");
  104. uint8_t resetReason = SysMgr::ins()->chipGetResetReason();
  105. zcanbus_send_report(kreport_device_reset, &resetReason, 1, 100);
  106. MX_IWDG_Init();
  107. while (true) {
  108. osDelay(30);
  109. debug_light_ctrl();
  110. HAL_IWDG_Refresh(&hiwdg);
  111. }
  112. }