diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 9ba8815fab..3069fa258b 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -371,7 +371,7 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat * set_fsio_setting 0 0.11 */ engineConfiguration->bc.fsio_setting[0] = 0.2; -#if EFI_HIP_9011 || defined(__DOXYGEN__) +#if EFI_FSIO || defined(__DOXYGEN__) boardConfiguration->fsio_setting[0] = 0.55; setFsioExt(engineConfiguration, 0, GPIOE_5, "0 fsio_setting", 400); #endif diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 75904a0827..913d014291 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -61,6 +61,17 @@ Engine::Engine() { isRunningPwmTest = false; isTestMode = false; isSpinning = false; + adcToVoltageInputDividerCoefficient = NAN; + engineConfiguration = NULL; + engineConfiguration2 = NULL; + engineState.iat = engineState.clt = NAN; + memset(&ignitionPin, 0, sizeof(ignitionPin)); + + iat.config = NULL; + iat.channel = EFI_ADC_NONE; + + clt.config = NULL; + clt.channel = EFI_ADC_NONE; injectorLagMs = advance = dwellAngle = fuelMs = 0; clutchDownState = clutchUpState = false; diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 98f84a32cb..c3adf3b1ba 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -41,7 +41,8 @@ #include "accel_enrichment.h" #endif /* EFI_ACCEL_ENRICHMENT */ -EXTERN_ENGINE; +EXTERN_ENGINE +; static Map3D1616 fuelMap; static Map3D1616 fuelPhaseMap; @@ -52,6 +53,8 @@ extern Map3D1616 afrMap; * @return total duration of fuel injection per engine cycle, in milliseconds */ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_S) { + if (rpm == 0) + return 0; // duration of engine cycle, in hours float engineCycleDurationHr = 1.0 / 60 / rpm; @@ -102,18 +105,19 @@ static int getNumberOfInjections(engine_configuration_s const *engineConfigurati } } - /** * @returns Length of fuel injection, in milliseconds */ float getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S) { float theoreticalInjectionLength; if (isCrankingR(rpm)) { - theoreticalInjectionLength = getCrankingFuel(engine) / getNumberOfInjections(engineConfiguration, engineConfiguration->crankingInjectionMode); + theoreticalInjectionLength = getCrankingFuel(engine) + / getNumberOfInjections(engineConfiguration, engineConfiguration->crankingInjectionMode); } else { float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER); float fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER); - theoreticalInjectionLength = fuelPerCycle / getNumberOfInjections(engineConfiguration, engine->engineConfiguration->injectionMode); + theoreticalInjectionLength = fuelPerCycle + / getNumberOfInjections(engineConfiguration, engine->engineConfiguration->injectionMode); } return theoreticalInjectionLength + ENGINE(injectorLagMs); } @@ -187,8 +191,7 @@ float getBaseTableFuel(engine_configuration_s *engineConfiguration, int rpm, flo */ float getCrankingFuel(Engine *engine) { return getCrankingFuel3(engine->engineConfiguration, getCoolantTemperature(engine), - engine->rpmCalculator.getRevolutionCounterSinceStart() - ); + engine->rpmCalculator.getRevolutionCounterSinceStart()); } #endif @@ -198,12 +201,9 @@ float getCrankingFuel3(engine_configuration_s *engineConfiguration, float coolan float baseCrankingFuel = engineConfiguration->cranking.baseFuel; if (cisnan(coolantTemperature)) return baseCrankingFuel; - float durationCoef = interpolate2d(revolutionCounterSinceStart, - engineConfiguration->crankingCycleBins, + float durationCoef = interpolate2d(revolutionCounterSinceStart, engineConfiguration->crankingCycleBins, engineConfiguration->crankingCycleCoef, CRANKING_CURVE_SIZE); return interpolate2d(coolantTemperature, engineConfiguration->crankingFuelBins, - engineConfiguration->crankingFuelCoef, CRANKING_CURVE_SIZE) - * baseCrankingFuel - * durationCoef; + engineConfiguration->crankingFuelCoef, CRANKING_CURVE_SIZE) * baseCrankingFuel * durationCoef; } diff --git a/firmware/controllers/algo/idle_controller.cpp b/firmware/controllers/algo/idle_controller.cpp index cfa0be9fe8..d0efb044bf 100644 --- a/firmware/controllers/algo/idle_controller.cpp +++ b/firmware/controllers/algo/idle_controller.cpp @@ -27,6 +27,8 @@ EXTERN_ENGINE IdleValveState::IdleValveState() { value = DEFAULT_IDLE_DUTY; timeOfLastIdleChange = 0; + time = 0; + targetRpmRangeLeft = targetRpmRangeRight = 0; } void IdleValveState::init(DECLARE_ENGINE_PARAMETER_F) { diff --git a/firmware/controllers/algo/lcd_menu_tree.cpp b/firmware/controllers/algo/lcd_menu_tree.cpp index fab5fd2c3d..02cfedafc2 100644 --- a/firmware/controllers/algo/lcd_menu_tree.cpp +++ b/firmware/controllers/algo/lcd_menu_tree.cpp @@ -12,6 +12,8 @@ MenuTree::MenuTree(MenuItem *root) { this->root = root; current = NULL; + linesCount = 0; + topVisible = NULL; } void MenuTree::init(MenuItem *first, int linesCount) { @@ -45,38 +47,32 @@ void MenuTree::nextItem(void) { topVisible = topVisible->next; } -MenuItem::MenuItem(MenuItem * parent, const char *text, VoidCallback callback) { - lcdLine = LL_STRING; - this->text = text; - init(parent, callback); +MenuItem::MenuItem(MenuItem * parent, const char *text, VoidCallback callback) : MenuItem(parent, LL_STRING, text, callback) { } -MenuItem::MenuItem(MenuItem * parent, const char *text) { - lcdLine = LL_STRING; - this->text = text; - init(parent, NULL); +MenuItem::MenuItem(MenuItem * parent, const char *text) : MenuItem(parent, LL_STRING, text, NULL) { } -MenuItem::MenuItem(MenuItem * parent, lcd_line_e lcdLine) { - this->lcdLine = lcdLine; - text = NULL; - topOfTheList = NULL; - init(parent, NULL); +MenuItem::MenuItem(MenuItem * parent, lcd_line_e lcdLine) : MenuItem(parent, lcdLine, NULL, NULL) { } -void MenuItem::init(MenuItem * parent, VoidCallback callback) { +MenuItem::MenuItem(MenuItem * parent, lcd_line_e lcdLine, const char *text, VoidCallback callback) { this->parent = parent; + this->lcdLine = lcdLine; + this->text = text; + this->callback = callback; + firstChild = NULL; lastChild = NULL; + topOfTheList = NULL; next = NULL; - this->callback = callback; + index = 0; // root element has NULL parent if (parent != NULL) { if (parent->firstChild == NULL) { - parent->firstChild = this; - index = 0; topOfTheList = this; + parent->firstChild = this; } if (parent->lastChild != NULL) { index = parent->lastChild->index + 1; diff --git a/firmware/controllers/algo/lcd_menu_tree.h b/firmware/controllers/algo/lcd_menu_tree.h index 585f59ae96..4b782dd07a 100644 --- a/firmware/controllers/algo/lcd_menu_tree.h +++ b/firmware/controllers/algo/lcd_menu_tree.h @@ -42,6 +42,7 @@ typedef void (*VoidCallback)(void); class MenuItem { public: + MenuItem(MenuItem * parent, lcd_line_e lcdLine, const char *text, VoidCallback callback); MenuItem(MenuItem * parent, const char *text, VoidCallback callback); MenuItem(MenuItem * parent, const char *text); MenuItem(MenuItem * parent, lcd_line_e lcdLine); @@ -55,8 +56,6 @@ public: MenuItem *lastChild; MenuItem *next; VoidCallback callback; -private: - void init(MenuItem * parent, VoidCallback callback); }; class MenuTree { diff --git a/firmware/controllers/core/table_helper.h b/firmware/controllers/core/table_helper.h index 4714b374fa..662857d857 100644 --- a/firmware/controllers/core/table_helper.h +++ b/firmware/controllers/core/table_helper.h @@ -30,12 +30,19 @@ private: template class Table2D { public: + Table2D(); void preCalc(float *bin, float *values); float aTable[SIZE]; float bTable[SIZE]; float *bin; }; +template +Table2D::Table2D() { + bin = NULL; +} + + template void Table2D::preCalc(float *bin, float *values) { this->bin = bin; diff --git a/firmware/controllers/system/efiGpio.cpp b/firmware/controllers/system/efiGpio.cpp index 82ca0c96da..6ab35b050d 100644 --- a/firmware/controllers/system/efiGpio.cpp +++ b/firmware/controllers/system/efiGpio.cpp @@ -9,6 +9,9 @@ #if EFI_GPIO #include "efiGpio.h" #include "io_pins.h" +#if EFI_PROD_CODE || defined(__DOXYGEN__) +#include "gpio_helper.h" +#endif pin_output_mode_e OUTPUT_MODE_DEFAULT = OM_DEFAULT; @@ -16,11 +19,16 @@ pin_output_mode_e OUTPUT_MODE_DEFAULT = OM_DEFAULT; engine_pins_s enginePins; NamedOutputPin::NamedOutputPin() : OutputPin() { - + name = NULL; } OutputPin::OutputPin() { modePtr = &OUTPUT_MODE_DEFAULT; +#if EFI_PROD_CODE || defined(__DOXYGEN__) + port = NULL; + pin = 0; + currentLogicValue = INITIAL_PIN_STATE; +#endif } void OutputPin::setValue(int logicValue) { diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index da423c2568..813e394414 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -24,7 +24,7 @@ public: void setValue(int logicValue); void setDefaultPinState(pin_output_mode_e *defaultState); bool_t getLogicValue(); -#if EFI_PROD_CODE +#if EFI_PROD_CODE || defined(__DOXYGEN__) GPIO_TypeDef *port; int pin; #endif /* EFI_PROD_CODE */ diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index c6ca7ea39b..5da1e9644f 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -28,7 +28,7 @@ PwmConfig::PwmConfig() { memset(&safe, 0, sizeof(safe)); scheduling.name = "PwmConfig"; periodNt = NAN; -// todo outputPins = NULL; + memset(&outputPins, 0, sizeof(outputPins)); phaseCount = 0; cycleCallback = NULL; stateChangeCallback = NULL; diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 282c185f9b..38adc767ab 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -225,7 +225,8 @@ float getCrankshaftAngleNt(uint64_t timeNt DECLARE_ENGINE_PARAMETER_S) { * compiler is not smart enough to figure out that "A / ( B / C)" could be optimized into * "A * C / B" in order to replace a slower division with a faster multiplication. */ - return timeSinceZeroAngleNt / getOneDegreeTimeNt(engine->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F)); + int rpm = engine->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F); + return rpm == 0 ? NAN : timeSinceZeroAngleNt / getOneDegreeTimeNt(rpm); } void initRpmCalculator(Engine *engine) { diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index e73d5df256..8577c502ac 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -131,6 +131,11 @@ TriggerState::TriggerState() { totalRevolutionCounter = 0; totalTriggerErrorCounter = 0; orderingErrorCounter = 0; + currentDuration = 0; + curSignal = SHAFT_PRIMARY_DOWN; + prevSignal = SHAFT_PRIMARY_DOWN; + prevCycleDuration = 0; + startOfCycleNt = 0; resetRunningCounters(); clear(); diff --git a/firmware/development/wave_analyzer.cpp b/firmware/development/wave_analyzer.cpp index cc3283abe7..1f546642f5 100644 --- a/firmware/development/wave_analyzer.cpp +++ b/firmware/development/wave_analyzer.cpp @@ -225,7 +225,8 @@ static void reportWave(Logging *logging, int index) { appendPrintf(logging, "%s", DELIMETER); uint32_t offsetUs = getWaveOffset(index); - float oneDegreeUs = getOneDegreeTimeUs(getRpm()); + int rpm = getRpm(); + float oneDegreeUs = rpm == 0 ? NAN : getOneDegreeTimeUs(rpm); appendPrintf(logging, "advance%d%s", index, DELIMETER); float angle = (offsetUs / oneDegreeUs) - tdcPosition(); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index ff2a691cd7..4ecc2ef96f 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -274,9 +274,9 @@ static char UNUSED_RAM_SIZE[9999]; static char UNUSED_CCM_SIZE[4900] CCM_OPTIONAL; int getRusEfiVersion(void) { - if (UNUSED_RAM_SIZE == 0) + if (UNUSED_RAM_SIZE[0]== 0) return 1; // this is here to make the compiler happy about the unused array - if (UNUSED_CCM_SIZE == 0) + if (UNUSED_CCM_SIZE[0] == 0) return 1; // this is here to make the compiler happy about the unused array return 20150226; } diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index d1643287b7..63311ecded 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -388,12 +388,13 @@ void initIntermediateLoggingBuffer(void) { Logging::Logging() { name = NULL; - buffer = linePointer = NULL; + buffer = NULL; + linePointer = NULL; bufferSize = 0; isInitialized = false; } -Logging::Logging(char const *name, char *buffer, int bufferSize) { +Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging() { #if ! EFI_UNIT_TEST initLoggingExt(this, "settings control", buffer, bufferSize); #endif /* ! EFI_UNIT_TEST */ diff --git a/firmware/util/listener_array.cpp b/firmware/util/listener_array.cpp index e01dfec989..6011c6dd1a 100644 --- a/firmware/util/listener_array.cpp +++ b/firmware/util/listener_array.cpp @@ -10,6 +10,7 @@ IntListenerArray::IntListenerArray() { currentListenersCount = 0; + memset(&args, 0, sizeof(args)); } void IntListenerArray::registerCallback(VoidInt handler, void *arg) {