auto-sync

This commit is contained in:
rusEfi 2014-09-27 17:03:08 -05:00
parent 9ac09cdcf4
commit 6dc88483eb
10 changed files with 44 additions and 27 deletions

View File

@ -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);

View File

@ -24,6 +24,7 @@
#include "main.h"
#include "signal_executor.h"
#include "efiGpio.h"
#if EFI_WAVE_CHART
/**

View File

@ -28,6 +28,7 @@
#include "engine_configuration.h"
#include "pin_repository.h"
#include "ec2.h"
#include "efiGpio.h"
static Logging logger;

View File

@ -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);
}

View File

@ -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
}

View File

@ -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_ */

View File

@ -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_ */

View File

@ -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);

View File

@ -2310,6 +2310,12 @@
</group>
<group>
<name>system</name>
<file>
<name>$PROJ_DIR$\..\controllers\system\efiGpio.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\controllers\system\efiGpio.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\controllers\system\event_queue.cpp</name>
</file>
@ -2816,6 +2822,12 @@
<file>
<name>$PROJ_DIR$\..\chibios\os\hal\src\ext.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\chibios\os\hal\platforms\STM32\ext_lld.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\chibios\os\hal\platforms\STM32F4xx\ext_lld_isr.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\chibios\os\hal\src\gpt.c</name>
</file>

View File

@ -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;
}