auto-sync

This commit is contained in:
rusEfi 2015-01-13 10:05:47 -06:00
parent 44f6a1dc65
commit 0975ec58e6
7 changed files with 32 additions and 33 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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