auto-sync

This commit is contained in:
rusEfi 2016-12-18 12:03:48 -05:00
parent 6d6f02036d
commit c869c21ba8
19 changed files with 20 additions and 95 deletions

View File

@ -26,8 +26,6 @@
#include "engine_controller.h"
extern engine_configuration2_s engineConfiguration2;
static void configureShaftPositionEmulatorShapeWhat(PwmConfig *state) {
/**
* One signal per cam shaft revolution

View File

@ -96,7 +96,6 @@ int AccelEnrichmemnt::getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_F) {
float AccelEnrichmemnt::getMaxDelta(DECLARE_ENGINE_PARAMETER_F) {
int index = getMaxDeltaIndex(PASS_ENGINE_PARAMETER_F);
FuelSchedule *fs = engine->engineConfiguration2->injectionEvents;
return (cb.get(index) - (cb.get(index - 1))) * CONFIG(specs.cylindersCount);
}
@ -136,7 +135,6 @@ floatms_t AccelEnrichmemnt::getTpsEnrichment(DECLARE_ENGINE_PARAMETER_F) {
float AccelEnrichmemnt::getEngineLoadEnrichment(DECLARE_ENGINE_PARAMETER_F) {
int index = getMaxDeltaIndex(PASS_ENGINE_PARAMETER_F);
FuelSchedule *fs = engine->engineConfiguration2->injectionEvents;
float d = (cb.get(index) - (cb.get(index - 1))) * CONFIG(specs.cylindersCount);
float result = 0;

View File

@ -96,7 +96,6 @@ void Engine::reset() {
isEngineChartEnabled = false;
sensorChartMode = SC_OFF;
actualLastInjection = 0;
fuelScheduleForThisEngineCycle = NULL;
isAlternatorControlEnabled = false;
wallFuelCorrection = 0;
/**
@ -111,7 +110,6 @@ void Engine::reset() {
isTestMode = false;
isSpinning = false;
adcToVoltageInputDividerCoefficient = NAN;
engineConfiguration2 = NULL;
engineState.iat = engineState.clt = NAN;
memset(&ignitionPin, 0, sizeof(ignitionPin));

View File

@ -46,8 +46,6 @@ public:
void addFuelEvents(DECLARE_ENGINE_PARAMETER_F);
void addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_S);
uint32_t usedAtEngineCycle;
InjectionEvent elements[MAX_INJECTION_OUTPUT_COUNT];
bool isReady;
@ -55,32 +53,6 @@ private:
void clear();
};
/**
* This structure is still separate from Engine simply because this goes into CCM memory and Engine is in main memory
* todo: re-arrange global variables to put something else into CCM so that this can go into main
* so that this could be mergeed into Engine
* todo: move these fields into Engine class, eliminate this class
*/
class engine_configuration2_s {
public:
engine_configuration2_s();
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
/**
* Lock-free multithreading: two instances, while one is being modified another one is used read-only
*/
FuelSchedule injectionEvents0;
/**
* this points at an instance we use to run the engine
*/
FuelSchedule *injectionEvents;
#endif
float fsioLastValue[LE_COMMAND_COUNT];
};
class ThermistorMath {
public:
ThermistorMath();
@ -249,15 +221,13 @@ public:
IgnitionEventList ignitionEvents;
WallFuel wallFuel;
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
FuelSchedule injectionEvents;
#endif /* EFI_ENGINE_CONTROL */
/**
* we have a background thread preparing new fuel schedule while engine is running using existing
* copy of fuel schedule. This pointer allows us to use the same schedule for the whole duration of an
* engine cycle.
*
*/
FuelSchedule *fuelScheduleForThisEngineCycle;
float fsioLastValue[LE_COMMAND_COUNT];
WallFuel wallFuel;
/**
* That's the list of pending spark firing events
@ -279,7 +249,6 @@ public:
RpmCalculator rpmCalculator;
persistent_config_s *config;
engine_configuration_s *engineConfiguration;
engine_configuration2_s *engineConfiguration2;
/**
* this is about 'stopengine' command

View File

@ -1004,18 +1004,12 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
#endif
}
engine_configuration2_s::engine_configuration2_s() {
injectionEvents = &injectionEvents0;
}
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "apply c");
scheduleMsg(logger, "applyNonPersistentConfiguration()");
#endif
// todo: this would require 'initThermistors() to re-establish a reference, todo: fix
// memset(engineConfiguration2, 0, sizeof(engine_configuration2_s));
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
engine->triggerShape.initializeTriggerShape(logger PASS_ENGINE_PARAMETER);
#endif
@ -1032,10 +1026,9 @@ void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
void prepareShapes(DECLARE_ENGINE_PARAMETER_F) {
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
engineConfiguration2->injectionEvents->addFuelEvents(PASS_ENGINE_PARAMETER_F);
engine->injectionEvents.addFuelEvents(PASS_ENGINE_PARAMETER_F);
}
#endif

View File

@ -245,9 +245,9 @@ static void handleFsio(Engine *engine, int index) {
warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(boardConfiguration->fsioPins[index]));
fvalue = NAN;
} else {
fvalue = calc.getValue2(engine->engineConfiguration2->fsioLastValue[index], fsioLogics[index], engine);
fvalue = calc.getValue2(engine->fsioLastValue[index], fsioLogics[index], engine);
}
engine->engineConfiguration2->fsioLastValue[index] = fvalue;
engine->fsioLastValue[index] = fvalue;
if (isPwmMode) {
fsioPwm[index].setSimplePwmDutyCycle(fvalue);
@ -378,7 +378,7 @@ static void showFsioInfo(void) {
*/
scheduleMsg(logger, "FSIO #%d [%s] at %s@%dHz value=%f", (i + 1), exp,
hwPortname(boardConfiguration->fsioPins[i]), boardConfiguration->fsioFrequency[i],
engineConfiguration2->fsioLastValue[i]);
engine->fsioLastValue[i]);
// scheduleMsg(logger, "user-defined #%d value=%f", i, engine->engineConfiguration2->fsioLastValue[i]);
showFsio(NULL, fsioLogics[i]);
}

View File

@ -90,11 +90,6 @@ static virtual_timer_t periodicFastTimer;
static LoggingWithStorage logger("Engine Controller");
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
static engine_configuration2_s ec2 CCM_OPTIONAL;
engine_configuration2_s * engineConfiguration2 = &ec2;
#endif /* EFI_ENGINE_CONTROL */
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
/**

View File

@ -99,7 +99,6 @@ FuelSchedule::FuelSchedule() {
void FuelSchedule::clear() {
isReady = false;
usedAtEngineCycle = 0;
}
void FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_S) {
@ -419,8 +418,6 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) {
getIgnition_mode_e(engineConfiguration->ignitionMode));
#endif
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
ENGINE(angleExtra[i])= ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);

View File

@ -222,7 +222,6 @@ static void testCltByR(float resistance) {
void initThermistors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) {
logger = sharedLogger;
efiAssertVoid(engine!=NULL, "e NULL initThermistors");
efiAssertVoid(engine->engineConfiguration2!=NULL, "e2 NULL initThermistors");
#if EFI_PROD_CODE
addConsoleActionF("test_clt_by_r", testCltByR);

View File

@ -75,7 +75,6 @@ void printSpiState(Logging *logger, board_configuration_s *boardConfiguration) {
extern board_configuration_s *boardConfiguration;
static void printOutputs(engine_configuration_s *engineConfiguration) {
// engine_configuration2_s *engineConfiguration2
scheduleMsg(&logger, "injectionPins: mode %s", getPin_output_mode_e(boardConfiguration->injectionPinMode));
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
brain_pin_e brainPin = boardConfiguration->injectionPins[i];

View File

@ -88,12 +88,11 @@ static void endSimultaniousInjection(InjectionEvent *event) {
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
Engine *engine = event->engine;
EXPAND_Engine;
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
#endif
for (int i = 0; i < engine->engineConfiguration->specs.cylindersCount; i++) {
turnPinLow(&enginePins.injectors[i]);
}
engineConfiguration2->injectionEvents->addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER);
engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER);
}
static void tempTurnPinHigh(InjectorOutputPin *output) {
@ -189,9 +188,8 @@ void seTurnPinLow(OutputSignalPair *pair) {
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
Engine *engine = pair->event->engine;
EXPAND_Engine;
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
#endif
engineConfiguration2->injectionEvents->addFuelEventsForCylinder(pair->event->ownIndex PASS_ENGINE_PARAMETER);
engine->injectionEvents.addFuelEventsForCylinder(pair->event->ownIndex PASS_ENGINE_PARAMETER);
}
static void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, OutputSignalPair *pair) {
@ -384,7 +382,7 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn
* Ignition events are defined by addFuelEvents() according to selected
* fueling strategy
*/
FuelSchedule *fs = engine->fuelScheduleForThisEngineCycle;
FuelSchedule *fs = &engine->injectionEvents;
if (!fs->isReady) {
fs->addFuelEvents(PASS_ENGINE_PARAMETER_F);
}
@ -484,13 +482,10 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
int revolutionIndex = ENGINE(rpmCalculator).getRevolutionCounter() % 2;
if (trgEventIndex == 0) {
// these two statements should be atomic, but in reality we should be fine, right?
engine->fuelScheduleForThisEngineCycle = ENGINE(engineConfiguration2)->injectionEvents;
engine->fuelScheduleForThisEngineCycle->usedAtEngineCycle = ENGINE(rpmCalculator).getRevolutionCounter();
if (triggerVersion.isOld()) {
engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule
engine->fuelScheduleForThisEngineCycle->isReady = false;
engine->injectionEvents.isReady = false;
// todo: move 'triggerIndexByAngle' change into trigger initialization, why is it invoked from here if it's only about trigger shape & optimization?
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
// we need this to apply new 'triggerIndexByAngle' values

View File

@ -92,7 +92,6 @@ typedef VirtualTimer virtual_timer_t;
extern persistent_config_container_s persistentState; \
extern Engine _engine; \
extern persistent_config_s *config; \
extern engine_configuration2_s * engineConfiguration2; \
extern EnginePins enginePins
#define DECLARE_ENGINE_PARAMETER_F void

View File

@ -183,11 +183,6 @@ void runRusEfi(void) {
msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
engine->engineConfiguration2 = engineConfiguration2;
#endif
prepareVoidConfiguration(&activeConfiguration);
/**

View File

@ -44,9 +44,6 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
setTableValue(config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE, 60, 1.03);
setTableValue(config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE, 70, 1.01);
engine.engineConfiguration2 = &ec2;
Engine *engine = &this->engine;
prepareFuelMap(PASS_ENGINE_PARAMETER_F);

View File

@ -22,12 +22,10 @@ public:
void fireTriggerEvents2(int count, int duration);
persistent_config_s persistentConfig;
engine_configuration2_s ec2;
Engine engine;
engine_configuration_s *ec;
engine_configuration_s *engineConfiguration;
};
#endif /* ENGINE_TEST_HELPER_H_ */

View File

@ -166,7 +166,7 @@ void testAngleResolver(void) {
EXPAND_EngineTestHelper;
engineConfiguration->globalTriggerAngleOffset = 175;
assertTrue(engine->engineConfiguration2!=NULL);
TriggerShape * ts = &engine->triggerShape;
ts->initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);

View File

@ -345,7 +345,7 @@ void testRpmCalculator(void) {
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
assertEqualsM("fuel #1", 4.5450, eth.engine.fuelMs);
InjectionEvent *ie0 = &eth.engine.engineConfiguration2->injectionEvents->elements[0];
InjectionEvent *ie0 = &eth.engine.injectionEvents.elements[0];
assertEqualsM("injection angle", 31.365, ie0->injectionStart.angleOffset);
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER);
@ -662,7 +662,7 @@ static void setTestBug299(EngineTestHelper *eth) {
assertInjectorDownEvent("1@3", 3, MS2US(20), 1);
assertEqualsM("exec#0", 0, schedulingQueue.executeAll(timeNow));
FuelSchedule * t = ENGINE(engineConfiguration2)->injectionEvents;
FuelSchedule * t = &ENGINE(injectionEvents);
assertInjectionEvent("#0", &t->elements[0], 0, 1, 153, false);
assertInjectionEvent("#1_i_@", &t->elements[1], 1, 1, 333, false);
@ -833,7 +833,7 @@ void testFuelSchedulerBug299smallAndMedium(void) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
t = ENGINE(engineConfiguration2)->injectionEvents;
t = &ENGINE(injectionEvents);
assertInjectionEvent("#0", &t->elements[0], 0, 0, 315, false);
assertInjectionEvent("#1__", &t->elements[1], 1, 1, 135, false);
@ -921,15 +921,13 @@ void testFuelSchedulerBug299smallAndMedium(void) {
timeNow += MS2US(20);
assertEqualsM("executeAll#4", 4, schedulingQueue.executeAll(timeNow));
t = ENGINE(engineConfiguration2)->injectionEvents;
t = &ENGINE(injectionEvents);
assertInjectionEvent("#0#", &t->elements[0], 0, 0, 315, false);
assertInjectionEvent("#1#", &t->elements[1], 1, 1, 135, false);
assertInjectionEvent("#2#", &t->elements[2], 0, 1, 315, true);
assertInjectionEvent("#3#", &t->elements[3], 1, 0, 45 + 90, false);
setArrayValues(fuelMap.pointers[engineLoadIndex], FUEL_RPM_COUNT, 35);
setArrayValues(fuelMap.pointers[engineLoadIndex + 1], FUEL_RPM_COUNT, 35);
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
@ -973,7 +971,7 @@ void testFuelSchedulerBug299smallAndMedium(void) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
t = ENGINE(engineConfiguration2)->injectionEvents;
t = &ENGINE(injectionEvents);
assertInjectionEvent("#00", &t->elements[0], 0, 0, 225, false); // 87.5 duty cycle
assertInjectionEvent("#10", &t->elements[1], 1, 1, 45, false);

View File

@ -102,7 +102,6 @@ void applyNewConfiguration(void);
extern board_configuration_s *boardConfiguration; \
extern persistent_config_s *config; \
extern persistent_config_container_s persistentState; \
extern engine_configuration2_s * engineConfiguration2; \
extern EnginePins enginePins
#define DECLARE_ENGINE_PARAMETER_F void

View File

@ -34,7 +34,6 @@
#define DEFAULT_SNIFFER_THR 2500
EXTERN_ENGINE;
extern engine_configuration2_s * engineConfiguration2;
extern WaveChart waveChart;
@ -66,7 +65,6 @@ void rusEfiFunctionalTest(void) {
initStatusLoop(engine);
initDataStructures(PASS_ENGINE_PARAMETER_F);
engine->engineConfiguration2 = engineConfiguration2;
// todo: reduce code duplication with initEngineContoller