|
|
@ -25,7 +25,7 @@ |
|
|
|
|
|
|
|
using namespace iflytop; |
|
|
|
using namespace transmit_disfection_protocol; |
|
|
|
#define TAG "LargeSpaceDmPowerCtrlBoard"
|
|
|
|
#define TAG "DMAPP"
|
|
|
|
|
|
|
|
DisinfectionApp* DisinfectionApp::ins() { |
|
|
|
static DisinfectionApp instance; |
|
|
@ -95,30 +95,22 @@ void DisinfectionApp::initialize() { |
|
|
|
if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard, kDrawBarDMPowerCtrlBoard)) { |
|
|
|
LargeSpaceDmPowerCtrlBoardHal::HUART3_INIT(19200, UART_STOPBITS_2); |
|
|
|
LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT(); |
|
|
|
h2o2Sensor.initialize(&huart3, &hadc1, ADC_CHANNEL_10); |
|
|
|
h2o2Sensor.initialize(&huart3, &hadc1, ADC_CHANNEL_3); |
|
|
|
bindH2o2Sensor(); |
|
|
|
} |
|
|
|
|
|
|
|
// 水浸传感器
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard)) { |
|
|
|
ZLOGI(TAG, "WaterSensor init"); |
|
|
|
evaporationBinWS.initAsInput(PC7, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/); |
|
|
|
deviceBottomWS.initAsInput(PC8, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/); |
|
|
|
bindDeviceBottomWS(); |
|
|
|
bindEvaporationBinWS(); |
|
|
|
} |
|
|
|
|
|
|
|
// TMC驱动
|
|
|
|
// kfn_pump_rotate = 100, // cmd: index rpm ack:none
|
|
|
|
// kfn_pump_stop = 101, // cmd: index rpm ack:none
|
|
|
|
// kfn_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
|
|
|
|
// kfn_pump_set_acc = 104, // cmd: index acc ack:none , delete
|
|
|
|
// kfn_pump_ping = 105, // cmd: index, ack:none
|
|
|
|
// kfn_pump_set_ramp = 106, // cmd: index,vs,a1,amx,v1 ack:none
|
|
|
|
// kfn_pump_set_tzw = 107, // cmd: index,timeZeroWait ack:none
|
|
|
|
// kfn_pump_set_subic_reg = 110, // cmd: index,val ack:none
|
|
|
|
// kfn_pump_get_subic_reg = 111, // cmd: index, ack:val
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) { |
|
|
|
// TMC电机初始化
|
|
|
|
ZLOGI(TAG, "TMCMotorGroup init"); |
|
|
|
LargeSpaceDMLiquidCtrlBoardHal::HSPI1_INIT(); |
|
|
|
tmcPowerGroup.initialize(PB2, {&hspi1, PC4 /*cs*/, PB13 /*en*/}, {&hspi1, PA4 /*cs*/, PB12 /*en*/}); |
|
|
|
bindTmcPowerGroup(); |
|
|
@ -127,12 +119,14 @@ void DisinfectionApp::initialize() { |
|
|
|
// 三色指示灯
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard)) { |
|
|
|
// 三色指示灯初始化
|
|
|
|
ZLOGI(TAG, "WarningLightDriver init"); |
|
|
|
wlDriver.initialize(PD8, PD7, PD9, PD10); |
|
|
|
bindWlDriver(); |
|
|
|
} |
|
|
|
|
|
|
|
// 压力传感器初始化
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) { |
|
|
|
ZLOGI(TAG, "PXXPSBus init"); |
|
|
|
osDelay(1500); // 等待传感器上电
|
|
|
|
LargeSpaceDMLiquidCtrlBoardHal::HUART3_INIT(9600, UART_STOPBITS_1); |
|
|
|
psBus.initialize(&huart3); |
|
|
@ -152,12 +146,12 @@ void DisinfectionApp::initialize() { |
|
|
|
airTightnessTestChGpio.initAsOutput(PD15, kxs_gpio_nopull, true, false); |
|
|
|
eValve.initAsOutput(PD14, kxs_gpio_nopull, false, true); |
|
|
|
|
|
|
|
REG_LAMADA_FN(kfn_air_tightness_test_close_ch, [&](ProcessContext* cxt) { |
|
|
|
REG_LAMADA_FN(kfn_air_tightness_test_close_off_ch, [&](ProcessContext* cxt) { |
|
|
|
airTightnessTestChGpio.write(1); // 内管路,气密性测试
|
|
|
|
eValve.write(0); // 电磁阀闭合
|
|
|
|
zcanbus_send_ack(cxt->packet, NULL, 0); |
|
|
|
}); |
|
|
|
REG_LAMADA_FN(kfn_air_tightness_test_open_ch, [&](ProcessContext* cxt) { |
|
|
|
REG_LAMADA_FN(kfn_air_tightness_test_release_ch, [&](ProcessContext* cxt) { |
|
|
|
airTightnessTestChGpio.write(0); // 连接空气
|
|
|
|
eValve.write(1); // 电磁阀打开
|
|
|
|
zcanbus_send_ack(cxt->packet, NULL, 0); |
|
|
@ -193,23 +187,23 @@ void DisinfectionApp::bindH2o2Sensor() { |
|
|
|
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_sub_ic_errorcode); |
|
|
|
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_sub_ic_reg); |
|
|
|
} |
|
|
|
void DisinfectionApp::bindWlDriver() { BIND_FN(WarningLightDriver, wlDriver, fn_triple_warning_light_ctl); } |
|
|
|
void DisinfectionApp::bindWlDriver() { BIND_FN(WarningLightDriver, &wlDriver, fn_triple_warning_light_ctl); } |
|
|
|
|
|
|
|
void DisinfectionApp::bindTmcPowerGroup() { |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_rotate); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_stop); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_ihold_irun_idelay); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_acc); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_ramp); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_tzw); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_subic_reg); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_get_subic_reg); |
|
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_ping); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_rotate); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_stop); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_set_ihold_irun_idelay); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_set_acc); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_set_ramp); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_set_tzw); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_set_subic_reg); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_get_subic_reg); |
|
|
|
BIND_FN(TmcMotorGroup, &tmcPowerGroup, fn_pump_ping); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionApp::bindPsBus() { |
|
|
|
BIND_FN(PXXPSBus, psBus, fn_psbus_read_data); |
|
|
|
BIND_FN(PXXPSBus, psBus, fn_psbus_scan); |
|
|
|
BIND_FN(PXXPSBus, &psBus, fn_psbus_read_data); |
|
|
|
BIND_FN(PXXPSBus, &psBus, fn_psbus_scan); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionApp::bindEvaporationBinWS() { |
|
|
|