From 6dc88483eba52bac9e7936129847217bd3c9609f Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 27 Sep 2014 17:03:08 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/algo/io_pins.h | 1 - firmware/controllers/algo/signal_executor.c | 1 + firmware/controllers/injector_central.cpp | 1 + firmware/controllers/system/efiGpio.cpp | 26 ++++++++++++++++++++- firmware/controllers/system/efiGpio.h | 2 ++ firmware/hw_layer/gpio_helper.c | 11 --------- firmware/hw_layer/gpio_helper.h | 1 - firmware/hw_layer/io_pins.c | 13 +---------- firmware/iar/ch.ewp | 12 ++++++++++ firmware/rusefi.cpp | 3 ++- 10 files changed, 44 insertions(+), 27 deletions(-) diff --git a/firmware/controllers/algo/io_pins.h b/firmware/controllers/algo/io_pins.h index 87bd49d226..15bd66fe8b 100644 --- a/firmware/controllers/algo/io_pins.h +++ b/firmware/controllers/algo/io_pins.h @@ -132,7 +132,6 @@ const char *getPinName(io_pin_e io_pin); io_pin_e getPinByName(const char *name); void turnOutputPinOn(io_pin_e pin); void turnOutputPinOff(io_pin_e pin); -void setOutputPinValue(io_pin_e pin, int logicValue); void setDefaultPinState(io_pin_e pin, pin_output_mode_e *defaultState); void outputPinRegisterExt2(const char *msg, io_pin_e ioPin, brain_pin_e brainPin, pin_output_mode_e *outputMode); diff --git a/firmware/controllers/algo/signal_executor.c b/firmware/controllers/algo/signal_executor.c index 4afa4840ac..b1df099a24 100644 --- a/firmware/controllers/algo/signal_executor.c +++ b/firmware/controllers/algo/signal_executor.c @@ -24,6 +24,7 @@ #include "main.h" #include "signal_executor.h" +#include "efiGpio.h" #if EFI_WAVE_CHART /** diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 1f492072dc..6db76ce5ac 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -28,6 +28,7 @@ #include "engine_configuration.h" #include "pin_repository.h" #include "ec2.h" +#include "efiGpio.h" static Logging logger; diff --git a/firmware/controllers/system/efiGpio.cpp b/firmware/controllers/system/efiGpio.cpp index c91656e7dd..adbe29ce72 100644 --- a/firmware/controllers/system/efiGpio.cpp +++ b/firmware/controllers/system/efiGpio.cpp @@ -11,6 +11,7 @@ // todo: clean this mess, this should become 'static'/private OutputPin outputs[IO_PIN_COUNT]; +pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; int getOutputPinValue(io_pin_e pin) { return getLogicPinValue(&outputs[pin]); @@ -35,10 +36,33 @@ inline static int getElectricalValue1(pin_output_mode_e mode) { return mode == OM_DEFAULT || mode == OM_OPENDRAIN; } -// todo: this method is here for unit test visibility. todo: move to a bette place! int getElectricalValue(int logicalValue, pin_output_mode_e mode) { efiAssert(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e", -1); return logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode); } +/** + * Set's the value of the pin. On this layer the value is assigned as is, without any conversion. + */ +void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue) { + if (getLogicPinValue(outputPin) == logicValue) + return; + +#if EFI_PROD_CODE + palWritePad(outputPin->port, outputPin->pin, electricalValue); +#endif + outputPin->currentLogicValue = logicValue; +} + +/** + * @brief Sets the value according to current electrical settings + */ +void setOutputPinValue(io_pin_e pin, int logicValue) { + if (outputs[pin].port == GPIO_NULL) + return; + efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized"); + pin_output_mode_e mode = *pinDefaultState[pin]; + setPinValue(&outputs[pin], getElectricalValue(logicValue, mode), logicValue); +} + diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index e2e97dc242..9f42062603 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -33,6 +33,8 @@ extern "C" int getLogicPinValue(OutputPin * outputPin); int getOutputPinValue(io_pin_e pin); int getElectricalValue(int logicalValue, pin_output_mode_e mode); +void setOutputPinValue(io_pin_e pin, int logicValue); +void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue); #ifdef __cplusplus } diff --git a/firmware/hw_layer/gpio_helper.c b/firmware/hw_layer/gpio_helper.c index 7c4d7df8a2..bd685bb59f 100644 --- a/firmware/hw_layer/gpio_helper.c +++ b/firmware/hw_layer/gpio_helper.c @@ -47,15 +47,4 @@ void initOutputPin(const char *msg, OutputPin *outputPin, GPIO_TypeDef *port, ui initOutputPinExt(msg, outputPin, port, pinNumber, PAL_MODE_OUTPUT_PUSHPULL); } -/** - * Set's the value of the pin. On this layer the value is assigned as is, without any conversion. - */ -void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue) { - if (getLogicPinValue(outputPin) == logicValue) - return; - - palWritePad(outputPin->port, outputPin->pin, electricalValue); - outputPin->currentLogicValue = logicValue; -} - #endif /* GPIO_HELPER_C_ */ diff --git a/firmware/hw_layer/gpio_helper.h b/firmware/hw_layer/gpio_helper.h index 5a9e6ac42a..34a61375fc 100644 --- a/firmware/hw_layer/gpio_helper.h +++ b/firmware/hw_layer/gpio_helper.h @@ -15,6 +15,5 @@ void initOutputPin(const char *msg, OutputPin *outputPin, GPIO_TypeDef *port, uint32_t pinNumber); void initOutputPinExt(const char *msg, OutputPin *outputPin, GPIO_TypeDef *port, uint32_t pinNumber, iomode_t mode); -void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue); #endif /* GPIO_HELPER_H_ */ diff --git a/firmware/hw_layer/io_pins.c b/firmware/hw_layer/io_pins.c index e6d2d8a194..07663081fd 100644 --- a/firmware/hw_layer/io_pins.c +++ b/firmware/hw_layer/io_pins.c @@ -25,7 +25,7 @@ extern board_configuration_s *boardConfiguration; static Logging logger; -static pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; +extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; extern OutputPin outputs[IO_PIN_COUNT]; static io_pin_e leds[] = { LED_WARNING, LED_RUNNING, LED_ERROR, LED_COMMUNICATION_1, LED_DEBUG, LED_EXT_1, LED_CHECK_ENGINE }; @@ -57,17 +57,6 @@ inline static void assertOMode(pin_output_mode_e mode) { efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); } -/** - * @brief Sets the value according to current electrical settings - */ -void setOutputPinValue(io_pin_e pin, int logicValue) { - if (outputs[pin].port == GPIO_NULL) - return; - efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized"); - pin_output_mode_e mode = *pinDefaultState[pin]; - setPinValue(&outputs[pin], getElectricalValue(logicValue, mode), logicValue); -} - void setDefaultPinState(io_pin_e pin, pin_output_mode_e *outputMode) { pin_output_mode_e mode = *outputMode; assertOMode(mode); diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp index 24be2b8ab0..be63708b17 100644 --- a/firmware/iar/ch.ewp +++ b/firmware/iar/ch.ewp @@ -2310,6 +2310,12 @@ system + + $PROJ_DIR$\..\controllers\system\efiGpio.cpp + + + $PROJ_DIR$\..\controllers\system\efiGpio.h + $PROJ_DIR$\..\controllers\system\event_queue.cpp @@ -2816,6 +2822,12 @@ $PROJ_DIR$\..\chibios\os\hal\src\ext.c + + $PROJ_DIR$\..\chibios\os\hal\platforms\STM32\ext_lld.c + + + $PROJ_DIR$\..\chibios\os\hal\platforms\STM32F4xx\ext_lld_isr.c + $PROJ_DIR$\..\chibios\os\hal\src\gpt.c diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 8c65311847..737fce515f 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -91,6 +91,7 @@ #include "ec2.h" #include "hardware.h" #include "engine_controller.h" +#include "efiGpio.h" #include "global.h" extern "C" { @@ -240,5 +241,5 @@ void firmwareError(const char *fmt, ...) { } int getRusEfiVersion(void) { - return 20140926; + return 20140927; }