全司美特-单片机程序
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.

156 lines
6.0 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #include "dmapp.hpp"
  2. /**
  3. * @brief
  4. *
  5. *
  6. *
  7. *
  8. *
  9. * -----
  10. *
  11. * :
  12. * 1.
  13. * 2.
  14. *
  15. * :
  16. * 1. ()
  17. *
  18. * ------
  19. *
  20. *
  21. *
  22. *
  23. */
  24. using namespace iflytop;
  25. using namespace transmit_disfection_protocol;
  26. #define TAG "DMAPP"
  27. DisinfectionApp* DisinfectionApp::ins() {
  28. static DisinfectionApp instance;
  29. return &instance;
  30. }
  31. const char* DisinfectionApp::getName() { return "DisinfectionApp"; }
  32. void DisinfectionApp::initialize() {
  33. int btid = PublicBoard::ins()->getBoardTypeId();
  34. //
  35. // 加热片
  36. if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard)) {
  37. LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
  38. heaterCtrler.initialize(PC7, &hadc1, ADC_CHANNEL_2, &hadc1, ADC_CHANNEL_8);
  39. } else if (isBoardType(kDrawBarDMPowerCtrlBoard)) {
  40. LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
  41. heaterCtrler.initialize(PC7, NULL, 0, &hadc1, ADC_CHANNEL_1);
  42. }
  43. // 风机
  44. if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard)) {
  45. LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
  46. blowerCtrler.initialize(PC5, &hadc1, ADC_CHANNEL_1);
  47. } else if (isBoardType(kPipeDMPowerCtrlBoard)) {
  48. LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
  49. LargeSpaceDmPowerCtrlBoardHal::HUART2_INIT(9600, UART_STOPBITS_1);
  50. blowerCtrler.initializeAsHighPowerUartBlower(&huart2, &hadc1, ADC_CHANNEL_1);
  51. } else if (isBoardType(kDrawBarDMPowerCtrlBoard)) {
  52. DBDMPowerCtrlBoard::HTIM3_INIT();
  53. blowerCtrler.initializeAsMiniPwmBlower(&htim3, TIM_CHANNEL_3, PC6 /*en*/, PC9 /*fb*/);
  54. }
  55. // 空压机
  56. if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard)) {
  57. LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
  58. airComCtrler.initialize(PC3, &hadc1, ADC_CHANNEL_0);
  59. } else if (isBoardType(kDrawBarDMLiquidCtrlBoard)) {
  60. airComCtrler.initialize(PD14, NULL, 0);
  61. }
  62. // 气密性测试空压机
  63. // kfn_air_tightness_test_ac_ctrl
  64. if (isBoardType(kPipeDMPowerCtrlBoard)) {
  65. REG_LAMADA_FN(kfn_air_tightness_test_ac_ctrl, [&](ProcessContext* cxt) {
  66. airComCtrler.open(GET_PARAM(0));
  67. zcanbus_send_ack(cxt->packet, NULL, 0);
  68. });
  69. } else if (isBoardType(kDrawBarDMLiquidCtrlBoard)) {
  70. static ZGPIO airCompressorCtrlGpio;
  71. airCompressorCtrlGpio.initAsOutput(PD15, kxs_gpio_nopull, true, false);
  72. REG_LAMADA_FN(kfn_air_tightness_test_ac_ctrl, [&](ProcessContext* cxt) {
  73. airCompressorCtrlGpio.write(GET_PARAM(0));
  74. zcanbus_send_ack(cxt->packet, NULL, 0);
  75. });
  76. }
  77. // H2O2传感器
  78. if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard, kDrawBarDMPowerCtrlBoard)) {
  79. LargeSpaceDmPowerCtrlBoardHal::HUART3_INIT(19200, UART_STOPBITS_2);
  80. LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
  81. h2o2Sensor.initialize(&huart3, &hadc1, ADC_CHANNEL_3);
  82. }
  83. // 水浸传感器
  84. if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard)) {
  85. ZLOGI(TAG, "WaterSensor init");
  86. evaporationBinWS.initAsInput(PC7, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
  87. deviceBottomWS.initAsInput(PC8, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
  88. REG_LAMADA_FN(kfn_device_bottom_water_sensor_read_state, [&](ProcessContext* cxt) { zcanbus_send_ack(cxt->packet, deviceBottomWS.read()); });
  89. REG_LAMADA_FN(kfn_evaporation_tank_water_sensor_read_state, [&](ProcessContext* cxt) { zcanbus_send_ack(cxt->packet, evaporationBinWS.read()); });
  90. }
  91. if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) {
  92. // TMC电机初始化
  93. ZLOGI(TAG, "TMCMotorGroup init");
  94. LargeSpaceDMLiquidCtrlBoardHal::HSPI1_INIT();
  95. tmcPowerGroup.initialize(PB2, {&hspi1, PC4 /*cs*/, PB13 /*en*/}, {&hspi1, PA4 /*cs*/, PB12 /*en*/});
  96. }
  97. // 三色指示灯
  98. if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard)) {
  99. // 三色指示灯初始化
  100. ZLOGI(TAG, "WarningLightDriver init");
  101. wlDriver.initialize(PD8, PD7, PD9, PD10);
  102. }
  103. // 压力传感器初始化
  104. if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) {
  105. ZLOGI(TAG, "PXXPSBus init");
  106. osDelay(1500); // 等待传感器上电
  107. LargeSpaceDMLiquidCtrlBoardHal::HUART3_INIT(9600, UART_STOPBITS_1);
  108. psBus.initialize(&huart3);
  109. }
  110. // 比例阀初始化
  111. if (isBoardType(kPipeDMLiquidCtrlBoard)) {
  112. ZLOGI(TAG, "ProportionalValveCtrl init");
  113. LargeSpaceDMLiquidCtrlBoardHal::HUART2_INIT(9600);
  114. proportionalValveCtrl.initialize(&huart2);
  115. }
  116. // 气密性测试通道
  117. if (isBoardType(kPipeDMLiquidCtrlBoard)) {
  118. static ZGPIO airTightnessTestChGpio;
  119. static ZGPIO eValve;
  120. airTightnessTestChGpio.initAsOutput(PD15, kxs_gpio_nopull, true, false);
  121. eValve.initAsOutput(PD14, kxs_gpio_nopull, false, true);
  122. REG_LAMADA_FN(kfn_air_tightness_test_close_off_ch, [&](ProcessContext* cxt) {
  123. airTightnessTestChGpio.write(1); // 内管路,气密性测试
  124. eValve.write(0); // 电磁阀闭合
  125. zcanbus_send_ack(cxt->packet, NULL, 0);
  126. });
  127. REG_LAMADA_FN(kfn_air_tightness_test_release_ch, [&](ProcessContext* cxt) {
  128. airTightnessTestChGpio.write(0); // 连接空气
  129. eValve.write(1); // 电磁阀打开
  130. zcanbus_send_ack(cxt->packet, NULL, 0);
  131. });
  132. }
  133. }
  134. /***********************************************************************************************************************
  135. * PROTOCOL_BIND *
  136. ***********************************************************************************************************************/