From a228108f17d21f58b0376917cb2f75091013ede4 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 30 Apr 2015 09:10:01 -0400 Subject: [PATCH] auto-sync --- firmware/config/engines/bmw_e34.cpp | 1 + firmware/controllers/algo/engine.h | 8 ++---- firmware/controllers/algo/event_registry.h | 6 +++-- firmware/controllers/math/engine_math.cpp | 27 ++++++++----------- firmware/controllers/settings.cpp | 5 +++- .../trigger/main_trigger_callback.cpp | 11 +++----- firmware/hw_layer/adc_inputs.cpp | 24 ++++++++++------- firmware/rusefi.cpp | 2 +- unit_tests/test_fuel_map.cpp | 2 -- 9 files changed, 41 insertions(+), 45 deletions(-) diff --git a/firmware/config/engines/bmw_e34.cpp b/firmware/config/engines/bmw_e34.cpp index 1cca88f7f1..3c3cd04943 100644 --- a/firmware/config/engines/bmw_e34.cpp +++ b/firmware/config/engines/bmw_e34.cpp @@ -82,6 +82,7 @@ void setBmwE34(DECLARE_ENGINE_PARAMETER_F) { // Inputs configuration engineConfiguration->analogInputDividerCoefficient = 1.52; engineConfiguration->vbattDividerCoeff = 5.33; + engineConfiguration->vbattAdcChannel = EFI_ADC_15; // PC5 boardConfiguration->triggerInputPins[0] = GPIOA_5; boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index be0bb3dfb4..b1c0188476 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -19,10 +19,6 @@ #include "listener_array.h" #include "accel_enrichment.h" -#define OUTPUT_SIGNAL_MAX_SIZE 45 - -typedef ArrayList OutputSignalList; - /** * This class knows about when to inject fuel */ @@ -34,7 +30,7 @@ public: /** * this method schedules all fuel events for an engine cycle */ - void addFuelEvents(OutputSignalList *sourceList, injection_mode_e mode DECLARE_ENGINE_PARAMETER_S); + void addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S); /** * This is a performance optimization for https://sourceforge.net/p/rusefi/tickets/64/ @@ -47,7 +43,7 @@ public: int eventsCount; private: void clear(); - void registerInjectionEvent(OutputSignalList *sourceList, NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S); + void registerInjectionEvent(NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S); }; /** diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index 93036cf41a..0625d321b7 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -33,7 +33,7 @@ public: class InjectionEvent { public: event_trigger_position_s injectionStart; - OutputSignal *actuator; + OutputSignal actuator; /** * This is a performance optimization - it's more efficient to handle all * injectors together if that's the case @@ -54,7 +54,9 @@ public: char *name; }; -typedef ArrayList ActuatorEventList; +#define OUTPUT_SIGNAL_MAX_SIZE2 45 + +typedef ArrayList ActuatorEventList; typedef ArrayList IgnitionEventList; diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index a2d338b3bb..7c42cf5145 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -84,8 +84,6 @@ void setSingleCoilDwell(engine_configuration_s *engineConfiguration) { } #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) -OutputSignalList runningInjectonSignals CCM_OPTIONAL; -OutputSignalList crankingInjectonSignals CCM_OPTIONAL; void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) { @@ -110,7 +108,7 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, } } -void FuelSchedule::registerInjectionEvent(OutputSignalList *sourceList, NamedOutputPin *output, float angle, +void FuelSchedule::registerInjectionEvent(NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S) { if (!isSimultanious && !isPinAssigned(output)) { // todo: extact method for this index math @@ -123,15 +121,12 @@ void FuelSchedule::registerInjectionEvent(OutputSignalList *sourceList, NamedOut return; } - OutputSignal *actuator = sourceList->add(); - actuator->output = output; + ev->actuator.output = output; ev->isSimultanious = isSimultanious; efiAssertVoid(TRIGGER_SHAPE(getSize()) > 0, "uninitialized TriggerShape"); - ev->actuator = actuator; - findTriggerPosition(&ev->injectionStart, angle PASS_ENGINE_PARAMETER); if (!hasEvents[ev->injectionStart.eventIndex]) { hasEvents[ev->injectionStart.eventIndex] = true; @@ -148,9 +143,9 @@ void FuelSchedule::clear() { eventsCount = 0; } -void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { +void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { clear(); // this method is relatively heavy - sourceList->reset(); +// sourceList->reset(); events.reset(); @@ -174,7 +169,7 @@ void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e int index = getCylinderId(engineConfiguration->specs.firingOrder, i) - 1; float angle = baseAngle + (float) CONFIG(engineCycle) * i / engineConfiguration->specs.cylindersCount; - registerInjectionEvent(sourceList, &enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); + registerInjectionEvent(&enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); } break; case IM_SIMULTANEOUS: @@ -184,9 +179,9 @@ void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e /** * We do not need injector pin here because we will control all injectors - * simultaniously + * simultaneously */ - registerInjectionEvent(sourceList, NULL, angle, true PASS_ENGINE_PARAMETER); + registerInjectionEvent(NULL, angle, true PASS_ENGINE_PARAMETER); } break; case IM_BATCH: @@ -194,7 +189,7 @@ void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e int index = i % (engineConfiguration->specs.cylindersCount / 2); float angle = baseAngle + i * (float) CONFIG(engineCycle) / engineConfiguration->specs.cylindersCount; - registerInjectionEvent(sourceList, &enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); + registerInjectionEvent(&enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); if (CONFIG(twoWireBatch)) { @@ -202,7 +197,7 @@ void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e * also fire the 2nd half of the injectors so that we can implement a batch mode on individual wires */ index = index + (CONFIG(specs.cylindersCount) / 2); - registerInjectionEvent(sourceList, &enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); + registerInjectionEvent(&enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); } } break; @@ -376,9 +371,9 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) { TRIGGER_SHAPE(triggerIndexByAngle[angle]) = triggerShapeIndex; } - engineConfiguration2->crankingInjectionEvents.addFuelEvents(&crankingInjectonSignals, + engineConfiguration2->crankingInjectionEvents.addFuelEvents( engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER); - engineConfiguration2->injectionEvents.addFuelEvents(&runningInjectonSignals, + engineConfiguration2->injectionEvents.addFuelEvents( engineConfiguration->injectionMode PASS_ENGINE_PARAMETER); } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index d34e9a63ba..a861dfd9d4 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -383,7 +383,10 @@ static void printThermistor(const char *msg, Thermistor *thermistor) { #if EFI_PROD_CODE || defined(__DOXYGEN__) static void printMAPInfo(void) { #if EFI_ANALOG_SENSORS || defined(__DOXYGEN__) - scheduleMsg(&logger, "map type=%d raw=%f MAP=%f", engineConfiguration->map.sensor.type, getRawMap(), getMap()); + scheduleMsg(&logger, "map type=%d/%s raw=%f MAP=%f", engineConfiguration->map.sensor.type, + getAir_pressure_sensor_type_e(engineConfiguration->map.sensor.type), + + getRawMap(), getMap()); if (engineConfiguration->map.sensor.type == MT_CUSTOM) { scheduleMsg(&logger, "at0=%f at5=%f", engineConfiguration->map.sensor.valueAt0, engineConfiguration->map.sensor.valueAt5); diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 3fc5331718..a16c9e750c 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -128,7 +128,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(InjectionEvent *event, int rp * 'scheduleOutput' is currently only used for injection, so maybe it should be * changed into 'scheduleInjection' and unified? todo: think about it. */ - OutputSignal *signal = event->actuator; + OutputSignal *signal = &event->actuator; efiAssertVoid(signal!=NULL, "signal is NULL"); int index = getRevolutionCounter() % 2; scheduling_s * sUp = &signal->signalTimerUp[index]; @@ -138,7 +138,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(InjectionEvent *event, int rp scheduleTask("out down", sDown, (int) injectionStartDelayUs + MS2US(injectionDuration), (schfunc_t) &endSimultaniousInjection, engine); } else { - scheduleOutput(event->actuator, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration)); + scheduleOutput(&event->actuator, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration)); } } @@ -293,9 +293,6 @@ static void ignitionCalc(int rpm DECLARE_ENGINE_PARAMETER_S) { engine->advance = -ENGINE(engineState.timingAdvance); } -extern OutputSignalList runningInjectonSignals CCM_OPTIONAL; -extern OutputSignalList crankingInjectonSignals CCM_OPTIONAL; - /** * This is the main trigger event handler. * Both injection and ignition are controlled from this method. @@ -394,10 +391,10 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL engine->m.beforeInjectonSch = GET_TIMESTAMP(); if (isCrankingR(rpm)) { - ENGINE(engineConfiguration2)->crankingInjectionEvents.addFuelEvents(&crankingInjectonSignals, + ENGINE(engineConfiguration2)->crankingInjectionEvents.addFuelEvents( engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER); } else { - ENGINE(engineConfiguration2)->injectionEvents.addFuelEvents(&runningInjectonSignals, + ENGINE(engineConfiguration2)->injectionEvents.addFuelEvents( engineConfiguration->injectionMode PASS_ENGINE_PARAMETER); } engine->m.injectonSchTime = GET_TIMESTAMP() - engine->m.beforeInjectonSch; diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index cadf266e58..fbcee923ef 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -465,26 +465,30 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) { } } -static void addChannel(adc_channel_e setting, adc_channel_mode_e mode) { +static void addChannel(const char *name, adc_channel_e setting, adc_channel_mode_e mode) { if (setting == EFI_ADC_NONE) { return; } + if (adcHwChannelEnabled[setting] != ADC_OFF) { + firmwareError("ADC mapping error: input for %s already used?", name); + } + adcHwChannelEnabled[setting] = mode; } static void configureInputs(void) { memset(adcHwChannelEnabled, 0, sizeof(adcHwChannelEnabled)); - addChannel(engineConfiguration->tpsAdcChannel, ADC_FAST); - addChannel(engineConfiguration->map.sensor.hwChannel, ADC_FAST); - addChannel(engineConfiguration->mafAdcChannel, ADC_FAST); - addChannel(engineConfiguration->hipOutputChannel, ADC_FAST); + addChannel("TPS", engineConfiguration->tpsAdcChannel, ADC_FAST); + addChannel("MAP", engineConfiguration->map.sensor.hwChannel, ADC_FAST); + addChannel("MAF", engineConfiguration->mafAdcChannel, ADC_FAST); + addChannel("hip", engineConfiguration->hipOutputChannel, ADC_FAST); - addChannel(engineConfiguration->vbattAdcChannel, ADC_SLOW); - addChannel(engineConfiguration->cltAdcChannel, ADC_SLOW); - addChannel(engineConfiguration->iatAdcChannel, ADC_SLOW); - addChannel(engineConfiguration->afr.hwChannel, ADC_SLOW); - addChannel(engineConfiguration->acSwitchAdc, ADC_SLOW); + addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW); + addChannel("CLT", engineConfiguration->cltAdcChannel, ADC_SLOW); + addChannel("IAT", engineConfiguration->iatAdcChannel, ADC_SLOW); + addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW); + addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW); } void initAdcInputs(bool boardTestMode) { diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 868d089ca5..2ca5d8e726 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -290,5 +290,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20150428; + return 20150430; } diff --git a/unit_tests/test_fuel_map.cpp b/unit_tests/test_fuel_map.cpp index 778643ba94..1e445de4b3 100644 --- a/unit_tests/test_fuel_map.cpp +++ b/unit_tests/test_fuel_map.cpp @@ -186,8 +186,6 @@ void testAngleResolver(void) { assertEqualsM("shape size", 10, ts->getSize()); - OutputSignalList list; - ae.reset(); printf("*************************************************** testAngleResolver 0\r\n"); findTriggerPosition(&ae.add()->injectionStart, -122 PASS_ENGINE_PARAMETER);