diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input.cpp index b7bae3a208..ebe5ad7c80 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input.cpp +++ b/firmware/hw_layer/digital_input/trigger/trigger_input.cpp @@ -138,17 +138,11 @@ void stopTriggerInputPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (isConfigurationChanged(triggerInputPins[i])) { turnOffTriggerInputPin(i, true); } - if (isConfigurationChanged(triggerInputDebugPins[i])) { - efiSetPadUnused(CONFIG(triggerInputDebugPins[i])); - } } for (int i = 0; i < CAM_INPUTS_COUNT; i++) { if (isConfigurationChanged(camInputs[i])) { turnOffTriggerInputPin(i, false); } - if (isConfigurationChanged(camInputsDebug[i])) { - efiSetPadUnused(CONFIG(camInputsDebug[i])); - } } } @@ -158,18 +152,12 @@ void startTriggerInputPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { const char * msg = (i == 0 ? "Trigger #1" : (i == 1 ? "Trigger #2" : "Trigger #3")); turnOnTriggerInputPin(msg, i, true); } - if (isConfigurationChanged(triggerInputDebugPins[i])) { - efiSetPadMode("trigger debug", CONFIG(triggerInputDebugPins[i]), PAL_MODE_OUTPUT_PUSHPULL); - } } for (int i = 0; i < CAM_INPUTS_COUNT; i++) { if (isConfigurationChanged(camInputs[i])) { turnOnTriggerInputPin("Cam", i, false); } - if (isConfigurationChanged(camInputsDebug[i])) { - efiSetPadMode("cam debug", CONFIG(camInputsDebug[i]), PAL_MODE_OUTPUT_PUSHPULL); - } } } @@ -178,11 +166,38 @@ void turnOnTriggerInputPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { icuTriggerTurnOnInputPins(); extiTriggerTurnOnInputPins(); - applyNewTriggerInputPins(); + applyNewTriggerInputPins(PASS_ENGINE_PARAMETER_SIGNATURE); } #endif /* (HAL_USE_ICU == TRUE) || (HAL_TRIGGER_USE_PAL == TRUE) */ + +void stopTriggerDebugPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + for (int i = 0; i < TRIGGER_INPUT_PIN_COUNT; i++) { + if (isConfigurationChanged(triggerInputDebugPins[i])) { + efiSetPadUnused(CONFIG(triggerInputDebugPins[i])); + } + } + for (int i = 0; i < CAM_INPUTS_COUNT; i++) { + if (isConfigurationChanged(camInputsDebug[i])) { + efiSetPadUnused(CONFIG(camInputsDebug[i])); + } + } +} + +void startTriggerDebugPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + for (int i = 0; i < TRIGGER_INPUT_PIN_COUNT; i++) { + if (isConfigurationChanged(triggerInputDebugPins[i])) { + efiSetPadMode("trigger debug", CONFIG(triggerInputDebugPins[i]), PAL_MODE_OUTPUT_PUSHPULL); + } + } + for (int i = 0; i < CAM_INPUTS_COUNT; i++) { + if (isConfigurationChanged(camInputsDebug[i])) { + efiSetPadMode("cam debug", CONFIG(camInputsDebug[i]), PAL_MODE_OUTPUT_PUSHPULL); + } + } +} + void applyNewTriggerInputPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_PROD_CODE // first we will turn off all the changed pins diff --git a/unit_tests/chibios-mock/mock-threads.h b/unit_tests/chibios-mock/mock-threads.h index ee6a05780c..4f7f3ef4a0 100644 --- a/unit_tests/chibios-mock/mock-threads.h +++ b/unit_tests/chibios-mock/mock-threads.h @@ -21,3 +21,5 @@ systime_t chThdSleepUntilWindowed(systime_t prev, systime_t next); thread_t *chThdCreateStatic(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg); + +#define PAL_MODE_OUTPUT_PUSHPULL 0