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.

138 lines
3.8 KiB

12 months ago
12 months ago
12 months ago
3 weeks ago
12 months 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. void debug_light_ctrl() {
  27. static uint32_t lastcall = 0;
  28. static bool light_status = false;
  29. if (!gInitErrorFlag) {
  30. if (zhas_passedms(lastcall) > 300) {
  31. PublicBoard::ins()->toggleDebugLight();
  32. lastcall = zget_ticket();
  33. }
  34. } else {
  35. if (zhas_passedms(lastcall) > 30) {
  36. PublicBoard::ins()->toggleDebugLight();
  37. lastcall = zget_ticket();
  38. }
  39. }
  40. }
  41. #define REG_PROCESSER(processer) ProtocolProcesserMgr::ins()->regProcesser(processer);
  42. /* IWDG init function */
  43. void MX_IWDG_Init(void) {
  44. hiwdg.Instance = IWDG;
  45. hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
  46. hiwdg.Init.Reload = 501;
  47. if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
  48. Error_Handler();
  49. }
  50. }
  51. void umain() {
  52. gBoardFlagSetResetFlag();
  53. PORT::idtable_init();
  54. deviceInfo_init();
  55. // config_init();
  56. AppPeriodTaskMgr::ins()->initialize();
  57. PublicBoard::ins()->initialize();
  58. ZLOGI(TAG, "======================= boardinfo ==================== ");
  59. ZLOGI(TAG, "project : %s ", PROJECT);
  60. ZLOGI(TAG, "version : %d ", SOFTWARE_VERSION);
  61. ZLOGI(TAG, "pversion : %d", deviceInfo_getProtocolVersion());
  62. ZLOGI(TAG, "sn : %s", sn_get_str());
  63. ZLOGI(TAG, "boardTypeId : %s(%d)", BoardTypeId2Str(PublicBoard::ins()->getBoardTypeId()), PublicBoard::ins()->getBoardTypeId());
  64. ZLOGI(TAG, "boardId : %d", PublicBoard::ins()->getBoardId());
  65. ZLOGI(TAG, "=");
  66. zcanbus_init(PublicBoard::ins()->getBoardId());
  67. ProtocolProcesserMgr::ins()->initialize();
  68. PublicCmdProcesser::ins()->initialize();
  69. switch (PublicBoard::ins()->getBoardTypeId()) {
  70. case DT100N_LC_Board:
  71. case DT100N_PC_Board:
  72. // not suppport now
  73. gInitErrorFlag = true;
  74. break;
  75. case DT600N_LC_Board:
  76. case DT600N_PC_Board:
  77. case DT300N_LC_Board:
  78. case DT300N_PC_Board:
  79. case DT300W_LC_Board:
  80. case DT300W_PC_Board:
  81. case DT600B_LC_BOARD:
  82. case DT600B_PC_BOARD:
  83. DisinfectionApp::ins()->initialize();
  84. break;
  85. case DT100N_EXT_CH_SELECTOR:
  86. ExtChSelector::ins()->initialize();
  87. break;
  88. case EX_H2O2_SENSOR_BOARD:
  89. ExtH2O2Sensor::ins()->initialize();
  90. break;
  91. default:
  92. gInitErrorFlag = true;
  93. break;
  94. }
  95. ZLOGI(TAG, "======================= init processer ================ ");
  96. ProtocolProcesserMgr::ins()->startSchedule(PublicBoard::ins()->getBoardId());
  97. ZLOGI(TAG, "=");
  98. AppPeriodTaskMgr::ins()->startScheduler();
  99. ZLOGI(TAG, "======================= sysinfo ======================= ");
  100. SysMgr::ins()->initedFinished();
  101. SysMgr::ins()->dumpSysInfo();
  102. ZLOGI(TAG, "=");
  103. uint8_t resetReason = SysMgr::ins()->chipGetResetReason();
  104. zcanbus_send_report(kreport_device_reset, &resetReason, 1, 100);
  105. MX_IWDG_Init();
  106. // ZGPIO gpio;
  107. // DBDMPowerCtrlBoard::TIM8_CH1_INIT_AS_PWM_OUTPUT_PC6(false); //
  108. // DBDMPowerCtrlBoard::TIM8_CH1_SET_DUTY(80);
  109. // DBDMPowerCtrlBoard::TIM3_CH3_INIT_AS_PWM_OUTPUT_PC8(false); //
  110. // DBDMPowerCtrlBoard::TIM3_CH3_SET_DUTY(30);
  111. while (true) {
  112. osDelay(30);
  113. debug_light_ctrl();
  114. HAL_IWDG_Refresh(&hiwdg);
  115. }
  116. }