From 6d19633fee2b11c2e0f0c9d52d858579254f9e05 Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Tue, 11 Feb 2025 21:32:02 +0300 Subject: [PATCH] io_pins: remove more Inverted flags for input pins --- firmware/controllers/algo/antilag_system.cpp | 2 +- firmware/controllers/algo/engine.cpp | 4 ++-- firmware/controllers/algo/launch_control.cpp | 2 +- firmware/controllers/algo/nitrous_controller.cpp | 3 ++- .../algo/shift_torque_reduction_controller.cpp | 9 +++------ firmware/integration/rusefi_config.txt | 12 ++++++------ firmware/tunerstudio/tunerstudio.template.ini | 8 -------- 7 files changed, 15 insertions(+), 25 deletions(-) diff --git a/firmware/controllers/algo/antilag_system.cpp b/firmware/controllers/algo/antilag_system.cpp index 35efd4578e..8036b9e752 100644 --- a/firmware/controllers/algo/antilag_system.cpp +++ b/firmware/controllers/algo/antilag_system.cpp @@ -18,7 +18,7 @@ bool AntilagSystemBase::isInsideALSSwitchCondition() { if (isALSSwitchActivated) { if (isBrainPinValid(engineConfiguration->ALSActivatePin)) { #if EFI_PROD_CODE - ALSActivatePinState = engineConfiguration->ALSActivateInverted ^ efiReadPin(engineConfiguration->ALSActivatePin); + ALSActivatePinState = efiReadPin(engineConfiguration->ALSActivatePin, engineConfiguration->ALSActivatePinMode); #else ALSActivatePinState = false; #endif diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 12383901f3..d4a0683333 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -218,7 +218,7 @@ bool getClutchDownState() { static bool getClutchUpState() { #if EFI_GPIO_HARDWARE if (isBrainPinValid(engineConfiguration->clutchUpPin)) { - return engineConfiguration->clutchUpPinInverted ^ efiReadPin(engineConfiguration->clutchUpPin); + return efiReadPin(engineConfiguration->clutchUpPin, engineConfiguration->clutchUpPinMode); } #endif // EFI_GPIO_HARDWARE // todo: boolean sensors should leverage sensor framework #6342 @@ -228,7 +228,7 @@ static bool getClutchUpState() { bool getBrakePedalState() { #if EFI_GPIO_HARDWARE if (isBrainPinValid(engineConfiguration->brakePedalPin)) { - return engineConfiguration->brakePedalPinInverted ^ efiReadPin(engineConfiguration->brakePedalPin); + return efiReadPin(engineConfiguration->brakePedalPin, engineConfiguration->brakePedalPinMode); } #endif // EFI_GPIO_HARDWARE // todo: boolean sensors should leverage sensor framework #6342 diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index 8404545106..0916ea8a90 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -26,7 +26,7 @@ bool LaunchControlBase::isInsideSwitchCondition() { if (isSwitchActivated) { #if !EFI_SIMULATOR if (isBrainPinValid(engineConfiguration->launchActivatePin)) { - launchActivatePinState = engineConfiguration->launchActivateInverted ^ efiReadPin(engineConfiguration->launchActivatePin); + launchActivatePinState = efiReadPin(engineConfiguration->launchActivatePin, engineConfiguration->launchActivatePinMode); } #endif // EFI_PROD_CODE return launchActivatePinState; diff --git a/firmware/controllers/algo/nitrous_controller.cpp b/firmware/controllers/algo/nitrous_controller.cpp index a41c02e7cd..1258edef49 100644 --- a/firmware/controllers/algo/nitrous_controller.cpp +++ b/firmware/controllers/algo/nitrous_controller.cpp @@ -127,8 +127,9 @@ bool NitrousController::checkTriggerPinState() const { bool result = false; #if !EFI_SIMULATOR const switch_input_pin_e triggerPin = engineConfiguration->nitrousControlTriggerPin; + const pin_input_mode_e triggerPinMode = engineConfiguration->nitrousControlTriggerPinMode; if (isBrainPinValid(triggerPin)) { - result = engineConfiguration->nitrousControlTriggerPinInverted ^ efiReadPin(triggerPin); + result = efiReadPin(triggerPin, triggerPinMode); } #endif // !EFI_SIMULATOR return result; diff --git a/firmware/controllers/algo/shift_torque_reduction_controller.cpp b/firmware/controllers/algo/shift_torque_reduction_controller.cpp index 9a5c0761ab..7ad13eb9a8 100644 --- a/firmware/controllers/algo/shift_torque_reduction_controller.cpp +++ b/firmware/controllers/algo/shift_torque_reduction_controller.cpp @@ -38,8 +38,7 @@ void ShiftTorqueReductionController::updateTriggerPinState() { case TORQUE_REDUCTION_BUTTON: { updateTriggerPinState( engineConfiguration->torqueReductionTriggerPin, - // hack until Inverted merged into Mode - engineConfiguration->torqueReductionTriggerPinInverted ? PI_INVERTED_DEFAULT : PI_DEFAULT, + engineConfiguration->torqueReductionTriggerPinMode, engine->engineState.lua.torqueReductionState ); break; @@ -47,8 +46,7 @@ void ShiftTorqueReductionController::updateTriggerPinState() { case LAUNCH_BUTTON: { updateTriggerPinState( engineConfiguration->launchActivatePin, - // hack until Inverted merged into Mode - engineConfiguration->launchActivateInverted ? PI_INVERTED_DEFAULT : PI_DEFAULT, + engineConfiguration->launchActivatePinMode, false ); break; @@ -64,8 +62,7 @@ void ShiftTorqueReductionController::updateTriggerPinState() { case TORQUE_REDUCTION_CLUTCH_UP_SWITCH: { updateTriggerPinState( engineConfiguration->clutchUpPin, - // hack until Inverted merged into Mode - engineConfiguration->clutchUpPinInverted ? PI_INVERTED_DEFAULT : PI_DEFAULT, + engineConfiguration->clutchUpPinMode, engine->engineState.lua.clutchUpState ); break; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 4933e349fb..3fecdcb66a 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -943,7 +943,7 @@ custom maf_sensor_type_e 1 bits, S08, @OFFSET@, [0:1], @@maf_sensor_type_e_enum@ custom vehicle_info_t @@VEHICLE_INFO_SIZE@@ string, ASCII, @OFFSET@, @@VEHICLE_INFO_SIZE@@ custom gppwm_note_t @@GPPWM_NOTE_SIZE@@ string, ASCII, @OFFSET@, @@GPPWM_NOTE_SIZE@@ - bit clutchUpPinInverted,"Inverted","Normal" + bit dead003 bit dead000 bit useHbridgesToDriveIdleStepper;If enabled we use two H-bridges to drive stepper idle air valve bit multisparkEnable @@ -1068,11 +1068,11 @@ bit cutSparkOnHardLimit,"yes","no";Be careful enabling this: some engines are kn bit launchFuelCutEnable bit launchSparkCutEnable;This is the Cut Mode normally used bit torqueReductionEnabled - bit torqueReductionTriggerPinInverted + bit dead001 bit limitTorqueReductionTime bit verboseIsoTp;Are you a developer troubleshooting TS over CAN ISO/TP? bit engineSnifferFocusOnInputs -bit launchActivateInverted +bit dead002 bit twoStroke,"Two Stroke","Four Stroke" bit skippedWheelOnCam,"On camshaft","On crankshaft";Where is your primary skipped wheel located? @@ -1113,7 +1113,7 @@ bit invertVvtControlIntake,"retard","advance";If increased VVT duty cycle increa bit invertVvtControlExhaust,"retard","advance";If increased VVT duty cycle increases the indicated VVT angle, set this to 'advance'. If it decreases, set this to 'retard'. Most intake cams use 'advance', and most exhaust cams use 'retard'. bit useBiQuadOnAuxSpeedSensors bit sdTriggerLog,"trigger","normal";'Trigger' mode will write a high speed log of trigger events (warning: uses lots of space!). 'Normal' mode will write a standard MLG of sensors, engine function, etc. similar to the one captured in TunerStudio. -bit ALSActivateInverted +bit dead005 bit stepper_dc_use_two_wires bit watchOutForLinearTime @@ -1199,7 +1199,7 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ bit enableAemXSeriesEgt;AEM X-Series EGT gauge kit or rusEFI EGT sensor from Wideband controller bit startRequestPinInverted,"Inverted","Normal" bit tcu_rangeSensorPulldown - bit brakePedalPinInverted,"Inverted","Normal" + bit devBit01 bit devBit0 bit devBit1 bit devBit2 @@ -1717,7 +1717,7 @@ uint8_t autoscale knockFuelTrim;Fuel trim when knock, max 30%;"%", 1, 0, 0, 30, SentFuelHighPressureType FuelHighPressureSentType;If you have SENT High Pressure Fuel Sensor please select type. For analog TPS leave None bit nitrousControlEnabled - bit nitrousControlTriggerPinInverted + bit unusedFancy2 bit unusedFancy3 bit unusedFancy4 bit unusedFancy5 diff --git a/firmware/tunerstudio/tunerstudio.template.ini b/firmware/tunerstudio/tunerstudio.template.ini index 6e9956fd75..6e671c66b1 100644 --- a/firmware/tunerstudio/tunerstudio.template.ini +++ b/firmware/tunerstudio/tunerstudio.template.ini @@ -3240,10 +3240,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_ field = "Clutch Down mode", clutchDownPinMode@@if_ts_show_clutch_down_pin field = "Clutch Up", clutchUpPin@@if_ts_show_clutch_up_pin - field = "Clutch Up signal", clutchUpPinInverted@@if_ts_show_clutch_up_pin field = "Clutch Up mode", clutchUpPinMode@@if_ts_show_clutch_up_pin field = "Brake Pedal", brakePedalPin@@if_ts_show_brake_pedal_pin - field = "Brake Pedal signal", brakePedalPinInverted@@if_ts_show_brake_pedal_pin field = "Brake Pedal Mode", brakePedalPinMode@@if_ts_show_brake_pedal_pin field = "Turbo Speed Sensor", turboSpeedSensorInputPin field = "Turbo Speed Multiplier", turboSpeedSensorMultiplier, { turboSpeedSensorInputPin } @@ -5082,7 +5080,6 @@ dialog = tcuControls, "Transmission Settings" field = "Activation Mode", launchActivationMode, {launchControlEnabled == 1} field = "Launch Button", launchActivatePin, {launchControlEnabled == 1 && (launchActivatePin != 0 || (launchActivationMode == @@launchActivationMode_e_SWITCH_INPUT_LAUNCH@@))} - field = "Launch Button inverted", launchActivateInverted, {launchControlEnabled == 1 && launchActivationMode == @@launchActivationMode_e_SWITCH_INPUT_LAUNCH@@} field = "Launch Button mode", launchActivatePinMode, {launchControlEnabled == 1 && launchActivationMode == @@launchActivationMode_e_SWITCH_INPUT_LAUNCH@@} field = "Clutch Down", clutchDownPin, {launchControlEnabled == 1 && (clutchDownPin != 0 || (launchActivationMode == @@launchActivationMode_e_CLUTCH_INPUT_LAUNCH@@))}@@if_ts_show_clutch_down_pin @@ -5108,11 +5105,9 @@ dialog = tcuControls, "Transmission Settings" dialog = TorqueReductionButtonDialog, "Torque Reduction Button" field = "Torque Reduction Button", torqueReductionTriggerPin - field = "Torque Reduction Inverted", torqueReductionTriggerPinInverted, {torqueReductionTriggerPin != 0} dialog = LaunchButtonDialog, "Launch Button" field = "Launch Button", launchActivatePin - field = "Launch Button Inverted", launchActivateInverted, {launchActivatePin != 0} dialog = ClutchDownDialog, "Clutch Down" field = "Clutch Down", clutchDownPin @@ -5120,7 +5115,6 @@ dialog = tcuControls, "Transmission Settings" dialog = ClutchUpDialog, "Clutch Up" field = "Clutch Up", clutchUpPin - field = "Clutch Up Inverted", clutchUpPinInverted, {clutchUpPin != 0} field = "Clutch Up Mode", clutchUpPinMode, {clutchUpPin != 0} dialog = TorqueReductionActivationModeDialog, "Activation", yAxis @@ -5149,7 +5143,6 @@ dialog = tcuControls, "Transmission Settings" dialog = NitrousControlButtonDialog, "Digital Switch Input" field = "Nitrous Control Button", nitrousControlTriggerPin - field = "Nitrous Control Inverted", nitrousControlTriggerPinInverted, {nitrousControlTriggerPin != 0} field = "Nitrous Control Mode", nitrousControlTriggerPinMode, {nitrousControlTriggerPin != 0} dialog = NitrousControlLuaGaugeDialog, "Lua Gauge" @@ -5193,7 +5186,6 @@ dialog = tcuControls, "Transmission Settings" field = "Enable AntiLag", antiLagEnabled field = "Activation Mode", antiLagActivationMode field = "Switch Input", ALSActivatePin, {antiLagActivationMode == @@antiLagActivationMode_e_SWITCH_INPUT_ANTILAG@@ && antiLagEnabled == 1} - field = "ALS Button inverted", ALSActivateInverted, {antiLagActivationMode == @@antiLagActivationMode_e_SWITCH_INPUT_ANTILAG@@ && antiLagEnabled == 1} field = "ALS Button mode", ALSActivatePinMode, {antiLagActivationMode == @@antiLagActivationMode_e_SWITCH_INPUT_ANTILAG@@ && antiLagEnabled == 1} field = "ALS timeout", ALSMaxDuration, {antiLagEnabled == 1} field = "Max TPS", ALSMaxTPS, {antiLagEnabled == 1}