From 0975ec58e6b6618b54f608c96215a18fb8c94140 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Tue, 13 Jan 2015 10:05:47 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/algo/engine.cpp | 5 ++-- firmware/controllers/algo/io_pins.h | 17 ++++++++++++++ firmware/controllers/algo/signal_executor.cpp | 4 ++-- firmware/controllers/math/engine_math.cpp | 4 ++-- firmware/controllers/system/efiGpio.cpp | 9 -------- firmware/controllers/system/efiGpio.h | 23 +++++-------------- firmware/hw_layer/io_pins.cpp | 3 ++- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index b1a57bb61b..092999502a 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -58,8 +58,9 @@ void Engine::init() { } static bool stopPin(io_pin_e pin) { - if (outputs[(int)pin].getLogicValue()) { - setOutputPinValue(pin, 0); + OutputPin *output = &outputs[(int)pin]; + if (output->getLogicValue()) { + doSetOutputPinValue2(output, false); scheduleMsg(&logger, "turning off %s", getPinName(pin)); return true; } diff --git a/firmware/controllers/algo/io_pins.h b/firmware/controllers/algo/io_pins.h index ff4e1a433e..4dc6a25a39 100644 --- a/firmware/controllers/algo/io_pins.h +++ b/firmware/controllers/algo/io_pins.h @@ -14,6 +14,23 @@ #define NAMED_PIN_COUNT 24 +typedef enum { + INJECTOR_1, + INJECTOR_2, + INJECTOR_3, + INJECTOR_4, + INJECTOR_5, + INJECTOR_6, + INJECTOR_7, + INJECTOR_8, + INJECTOR_9_, + INJECTOR_10, + INJECTOR_11, + INJECTOR_12, + + INJECTOR_NONE, +} injector_channel_e; + /** * Logical pins. See brain_pin_e for physical pins. */ diff --git a/firmware/controllers/algo/signal_executor.cpp b/firmware/controllers/algo/signal_executor.cpp index e2f89f3cd4..b52ab5d95a 100644 --- a/firmware/controllers/algo/signal_executor.cpp +++ b/firmware/controllers/algo/signal_executor.cpp @@ -65,7 +65,7 @@ void turnPinHigh(io_pin_e pin) { #if EFI_GPIO // turn the output level ACTIVE // todo: this XOR should go inside the setOutputPinValue method - doSetOutputPinValue(pin, true); + doSetOutputPinValue2((&outputs[pin]), true); // sleep for the needed duration #endif #if EFI_WAVE_CHART @@ -84,7 +84,7 @@ void turnPinHigh(io_pin_e pin) { void turnPinLow(io_pin_e pin) { #if EFI_GPIO // turn off the output - doSetOutputPinValue(pin, false); + doSetOutputPinValue2((&outputs[pin]), false); #endif #if EFI_DEFAILED_LOGGING diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 73f55e7003..f4a18930a2 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -107,7 +107,7 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, IgnitionEven IgnitionEvent *event = list->add(); - if (!isPinAssigned(pin)) { + if (!isPinAssigned(&outputs[(pin)])) { // todo: extact method for this index math warning(OBD_PCM_Processor_Fault, "no_pin_cl #%d", (int) pin - (int) SPARKOUT_1_OUTPUT + 1); } @@ -119,7 +119,7 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, IgnitionEven } void FuelSchedule::registerInjectionEvent(io_pin_e pin, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S) { - if (!isSimultanious && !isPinAssigned(pin)) { + if (!isSimultanious && !isPinAssigned(&outputs[(pin)])) { // todo: extact method for this index math warning(OBD_PCM_Processor_Fault, "no_pin_inj #%d", (int) pin - (int) INJECTOR_1_OUTPUT + 1); } diff --git a/firmware/controllers/system/efiGpio.cpp b/firmware/controllers/system/efiGpio.cpp index 5f6eb56537..d4e6058d85 100644 --- a/firmware/controllers/system/efiGpio.cpp +++ b/firmware/controllers/system/efiGpio.cpp @@ -75,13 +75,4 @@ void OutputPin::setDefaultPinState(pin_output_mode_e *outputMode) { setValue(false); // initial state } -/** - * @brief Sets the value according to current electrical settings - * - * This method costs about 85 ticks - */ -void setOutputPinValue(io_pin_e pin, int logicValue) { - doSetOutputPinValue(pin, logicValue); -} - #endif /* EFI_GPIO */ diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index 610cf47143..40506252d5 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -81,26 +81,18 @@ typedef struct { } #endif /* EFI_PROD_CODE */ -#define turnOutputPinOn(pin) setOutputPinValue((pin), true) -#define turnOutputPinOff(pin) setOutputPinValue((pin), false) - #define getElectricalValue(logicalValue, mode) \ (logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode)) -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -void setOutputPinValue(io_pin_e pin, int logicValue); -const char *getPinName(io_pin_e io_pin); - #if EFI_PROD_CODE - #define isPinAssigned(pin) (outputs[(pin)].port != GPIO_NULL) + #define isPinAssigned(output) ((output)->port != GPIO_NULL) #else - #define isPinAssigned(pin) (true) + #define isPinAssigned(output) (true) #endif +#define doSetOutputPinValue(pin, logicValue) doSetOutputPinValue2((&outputs[pin]), logicValue) + + #if EFI_PROD_CODE #define doSetOutputPinValue2(output, logicValue) { \ if (output->port != GPIO_NULL) { \ @@ -119,11 +111,8 @@ const char *getPinName(io_pin_e io_pin); } #endif -#define doSetOutputPinValue(pin, logicValue) doSetOutputPinValue2((&outputs[pin]), logicValue) void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +const char *getPinName(io_pin_e io_pin); #endif /* EFIGPIO_H_ */ diff --git a/firmware/hw_layer/io_pins.cpp b/firmware/hw_layer/io_pins.cpp index cbb509e143..9701a80b62 100644 --- a/firmware/hw_layer/io_pins.cpp +++ b/firmware/hw_layer/io_pins.cpp @@ -191,7 +191,8 @@ static io_pin_e TO_BE_TURNED_OFF_ON_ERROR[] = { SPARKOUT_1_OUTPUT, SPARKOUT_2_OU void turnAllPinsOff(void) { int l = sizeof(TO_BE_TURNED_OFF_ON_ERROR) / sizeof(io_pin_e); for (int i = 0; i < l; i++) { - turnOutputPinOff(TO_BE_TURNED_OFF_ON_ERROR[l]); + OutputPin *output = &outputs[TO_BE_TURNED_OFF_ON_ERROR[l]]; + output->setValue(false); } } #endif