From 96c29840ce22c6afb29379368f4ad4016af5683e Mon Sep 17 00:00:00 2001 From: rusefillc Date: Mon, 7 Dec 2020 20:42:47 -0500 Subject: [PATCH] basic hw in the loop - pwm self validation #2028 --- firmware/development/logic_analyzer.cpp | 2 +- firmware/hw_layer/digital_input/digital_input_icu.cpp | 2 +- firmware/hw_layer/drivers/can/can_hw.cpp | 1 + firmware/hw_layer/hardware.cpp | 10 ++++++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/firmware/development/logic_analyzer.cpp b/firmware/development/logic_analyzer.cpp index 2ed00dc6e9..0c1bc9bd49 100644 --- a/firmware/development/logic_analyzer.cpp +++ b/firmware/development/logic_analyzer.cpp @@ -233,7 +233,7 @@ void startLogicAnalyzerPins() { void stopLogicAnalyzerPins() { for (int index = 0; index < LOGIC_ANALYZER_CHANNEL_COUNT; index++) { - brain_pin_e brainPin = CONFIG(logicAnalyzerPins)[index]; + brain_pin_e brainPin = activeConfiguration.logicAnalyzerPins[index]; if (brainPin != GPIO_UNASSIGNED) { stopDigitalCapture("wave input", brainPin); diff --git a/firmware/hw_layer/digital_input/digital_input_icu.cpp b/firmware/hw_layer/digital_input/digital_input_icu.cpp index b261010325..1f7d0d545b 100644 --- a/firmware/hw_layer/digital_input/digital_input_icu.cpp +++ b/firmware/hw_layer/digital_input/digital_input_icu.cpp @@ -219,7 +219,7 @@ void stopDigitalCapture(const char *msg, brain_pin_e brainPin) { if (driver == NULL) { return; } - efiSetPadUnused(brainPin); + int regSize = registeredIcus.size; for (int i = 0; i < regSize; i++) { if (registeredIcus.elements[i].driver == driver) { diff --git a/firmware/hw_layer/drivers/can/can_hw.cpp b/firmware/hw_layer/drivers/can/can_hw.cpp index fca0e7ac74..40dd324543 100644 --- a/firmware/hw_layer/drivers/can/can_hw.cpp +++ b/firmware/hw_layer/drivers/can/can_hw.cpp @@ -151,6 +151,7 @@ void enableFrankensoCan(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->canReadEnabled = false; } +// todo: we usually use 'activeConfiguration' for 'stopPin' why this unusual code here? // this is related to #1375 static brain_pin_e currentTxPin = GPIO_UNASSIGNED; static brain_pin_e currentRxPin = GPIO_UNASSIGNED; diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index 211a354816..55bec4bc6e 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -304,8 +304,14 @@ void stopSpi(spi_device_e device) { */ void applyNewHardwareSettings(void) { - // all 'stop' methods need to go before we begin starting pins - + /** + * All 'stop' methods need to go before we begin starting pins. + * + * We take settings from 'activeConfiguration' not 'engineConfiguration' while stopping hardware. + * Some hardware is restart unconditionally on change of parameters while for some systems we make extra effort and restart only + * relevant settings were changes. + * + */ ButtonDebounce::stopConfigurationList(); #if EFI_SHAFT_POSITION_INPUT