|
|
@ -52,7 +52,7 @@ ZCanBasicOrderModule m_basicOrderModule; |
|
|
|
ZCanHighPowerElectricalCtlModule m_highPowerElectricalCtlModule; |
|
|
|
|
|
|
|
void Main::onRceivePacket(CanPacketRxBuffer *rxbuf, uint8_t *packet, size_t len) { |
|
|
|
ZLOGI(TAG, "onRceivePacket from %d %d", rxbuf->id, len); |
|
|
|
printf("can rx from %d %d,", rxbuf->id, len); |
|
|
|
for (size_t i = 0; i < len; i++) { |
|
|
|
printf("%02X ", packet[i]); |
|
|
|
} |
|
|
@ -74,12 +74,31 @@ void Main::run() { |
|
|
|
m_canReceiver.init(cfg); |
|
|
|
m_canReceiver.registerListener(this); |
|
|
|
|
|
|
|
AirCompressorCtrl1.initAsOutput(PC2, ZGPIO::kMode_nopull, true, false); |
|
|
|
AirCompressorCtrl2.initAsOutput(PC3, ZGPIO::kMode_nopull, true, false); |
|
|
|
|
|
|
|
AirBlowerCtrl1.initAsOutput(PC4, ZGPIO::kMode_nopull, true, false); |
|
|
|
AirBlowerCtrl2.initAsOutput(PC5, ZGPIO::kMode_nopull, true, false); |
|
|
|
|
|
|
|
HeatingStripCtrl1.initAsOutput(PC6, ZGPIO::kMode_nopull, true, false); |
|
|
|
HeatingStripCtrl2.initAsOutput(PC7, ZGPIO::kMode_nopull, true, false); |
|
|
|
|
|
|
|
ZHAL_CORE_REG(3000, { |
|
|
|
AirCompressorCtrl1.toggleState(); |
|
|
|
AirCompressorCtrl2.toggleState(); |
|
|
|
AirBlowerCtrl1.toggleState(); |
|
|
|
AirBlowerCtrl2.toggleState(); |
|
|
|
HeatingStripCtrl1.toggleState(); |
|
|
|
HeatingStripCtrl2.toggleState(); |
|
|
|
}); |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 基础模块 |
|
|
|
*/ |
|
|
|
m_basicOrderModule.initialize(&m_canReceiver); |
|
|
|
m_basicOrderModule.regInputCtl([this](uint8_t id, bool &val) { return false; }); |
|
|
|
m_basicOrderModule.regOutCtl([this](uint8_t id, bool val) { |
|
|
|
ZLOGI(TAG, "set io %d %d", id, val); |
|
|
|
if (id == 0) { |
|
|
|
AirCompressorCtrl1.setState(val); |
|
|
|
return true; |
|
|
@ -88,44 +107,38 @@ void Main::run() { |
|
|
|
AirCompressorCtrl2.setState(val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (id == 2) { |
|
|
|
AirBlowerCtrl1.setState(val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (id == 3) { |
|
|
|
AirBlowerCtrl2.setState(val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (id == 4) { |
|
|
|
HeatingStripCtrl1.setState(val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (id == 5) { |
|
|
|
HeatingStripCtrl2.setState(val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
}); |
|
|
|
|
|
|
|
m_basicOrderModule.regReadAdcVal([this](uint8_t id, int32_t &val) { |
|
|
|
if (id == 0) { |
|
|
|
val = 0; |
|
|
|
val = 1; |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (id == 1) { |
|
|
|
val = 0; |
|
|
|
val = 2; |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (id == 2) { |
|
|
|
val = 0; |
|
|
|
val = 3; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
}); |
|
|
|
|
|
|
|