From 18aaa5110e551ce186f9481e76ba06dd2cf369d3 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 15 Nov 2014 08:03:49 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/algo/auto_generated_enums.cpp | 2 ++ firmware/controllers/algo/engine_configuration.cpp | 2 ++ firmware/controllers/algo/engine_configuration.h | 8 +++++++- firmware/controllers/algo/io_pins.h | 2 ++ firmware/controllers/trigger/trigger_decoder.cpp | 4 +++- firmware/controllers/trigger/trigger_decoder.h | 4 ++++ firmware/hw_layer/io_pins.c | 14 +++++--------- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 4a5d177f86..eebfc6b25c 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -95,6 +95,8 @@ case O2_HEATER: return "O2_HEATER"; case LED_RUNNING: return "LED_RUNNING"; +case LED_TRIGGER_ERROR: + return "LED_TRIGGER_ERROR"; case TRIGGER_EMULATOR_3RD: return "TRIGGER_EMULATOR_3RD"; case INJECTOR_10_OUTPUT: diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index e37b23c0fc..7b262f7383 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -322,6 +322,8 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ */ boardConfiguration->triggerSimulatorFrequency = 1200; + boardConfiguration->triggerErrorPin = GPIO_UNASSIGNED; + boardConfiguration->max31855spiDevice = SPI_NONE; for (int i = 0; i < MAX31855_CS_COUNT; i++) { boardConfiguration->max31855_cs[i] = GPIO_UNASSIGNED; diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index 80e01cac5b..626e269eb5 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -223,7 +223,13 @@ typedef struct { brain_pin_e joystickPins[JOYSTICK_PIN_COUNT]; - int unusedbs[54]; + /** + * This pin is used for debugging - snap a logic analyzer on it and see if it's ever high + */ + brain_pin_e triggerErrorPin; + pin_output_mode_e triggerErrorPinMode; + + int unusedbs[52]; le_formula_t le_formulas[LE_COMMAND_COUNT]; diff --git a/firmware/controllers/algo/io_pins.h b/firmware/controllers/algo/io_pins.h index ed2dbb4aea..87ec86dcbb 100644 --- a/firmware/controllers/algo/io_pins.h +++ b/firmware/controllers/algo/io_pins.h @@ -27,6 +27,8 @@ typedef enum { LED_DEBUG, LED_EMULATOR, + LED_TRIGGER_ERROR, + /** * see board_configuration_s->idleValvePin */ diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 74f3981a91..fd86219caa 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -29,6 +29,7 @@ #include "trigger_mitsubishi.h" #include "trigger_structure.h" +#include "efiGpio.h" // todo: better name for this constant #define HELPER_PERIOD 100000 @@ -126,7 +127,7 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge return; } - int64_t currentDuration = getCurrentGapDuration(nowNt); + currentDuration = getCurrentGapDuration(nowNt); isFirstEvent = false; efiAssertVoid(currentDuration >= 0, "decode: negative duration?"); @@ -150,6 +151,7 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge || eventCount[1] != triggerShape->expectedEventCount[1] || eventCount[2] != triggerShape->expectedEventCount[2]; + setOutputPinValue(LED_TRIGGER_ERROR, isDecodingError); if (isDecodingError) { totalTriggerErrorCounter++; } diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 37cf75045f..4cd01f9b6d 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -36,6 +36,10 @@ public: bool shaft_is_synchronized; uint64_t toothed_previous_duration; + /** + * this could be a local variable, but it's better for debugging to have it as a field + */ + int64_t currentDuration; uint64_t toothed_previous_time; /** diff --git a/firmware/hw_layer/io_pins.c b/firmware/hw_layer/io_pins.c index d5594423d8..5c916f37ca 100644 --- a/firmware/hw_layer/io_pins.c +++ b/firmware/hw_layer/io_pins.c @@ -141,8 +141,7 @@ void initOutputPins(void) { // outputPinRegister("ext led 2", LED_EXT_2, EXTRA_LED_2_PORT, EXTRA_LED_2_PIN); // outputPinRegister("ext led 3", LED_EXT_3, EXTRA_LED_2_PORT, EXTRA_LED_3_PIN); // outputPinRegister("alive1", LED_DEBUG, GPIOD, 6); - outputPinRegister("MalfunctionIndicator", LED_CHECK_ENGINE, getHwPort(boardConfiguration->malfunctionIndicatorPin), - getHwPin(boardConfiguration->malfunctionIndicatorPin)); + outputPinRegisterExt2("MalfunctionIndicator", LED_CHECK_ENGINE, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT); // todo: are these needed here? todo: make configurable // outputPinRegister("spi CS1", SPI_CS_1, SPI_CS1_PORT, SPI_CS1_PIN); @@ -152,14 +151,11 @@ void initOutputPins(void) { outputPinRegister("spi CS5", SPI_CS_SD_MODULE, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN); // todo: should we move this code closer to the fuel pump logic? - outputPinRegister("fuel pump relay", FUEL_PUMP_RELAY, getHwPort(boardConfiguration->fuelPumpPin), - getHwPin(boardConfiguration->fuelPumpPin)); + outputPinRegisterExt2("fuel pump relay", FUEL_PUMP_RELAY, boardConfiguration->fuelPumpPin, &DEFAULT_OUTPUT); - outputPinRegister("fan relay", FAN_RELAY, getHwPort(boardConfiguration->fanPin), - getHwPin(boardConfiguration->fanPin)); - - outputPinRegister("o2 heater", O2_HEATER, getHwPort(boardConfiguration->o2heaterPin), - getHwPin(boardConfiguration->o2heaterPin)); + outputPinRegisterExt2("fan relay", FAN_RELAY, boardConfiguration->fanPin, &DEFAULT_OUTPUT); + outputPinRegisterExt2("o2 heater", O2_HEATER, boardConfiguration->o2heaterPin, &DEFAULT_OUTPUT); + outputPinRegisterExt2("trg_err", LED_TRIGGER_ERROR, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode); initialLedsBlink();