mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
d2a790bd0c
commit
a3ed8d4d8f
|
@ -180,7 +180,7 @@ void Engine::preCalculate() {
|
|||
}
|
||||
}
|
||||
|
||||
void Engine::init() {
|
||||
void Engine::init(persistent_config_s *config) {
|
||||
}
|
||||
|
||||
static bool stopPin(NamedOutputPin *output) {
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
void addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
InjectionEventList injectionEvents;
|
||||
|
||||
/**
|
||||
* This is a performance optimization for https://sourceforge.net/p/rusefi/tickets/64/
|
||||
* TODO: better data structure? better algorithm?
|
||||
|
@ -69,10 +70,11 @@ public:
|
|||
engine_configuration2_s();
|
||||
|
||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||
FuelSchedule crankingInjectionEvents;
|
||||
FuelSchedule injectionEvents;
|
||||
#endif
|
||||
|
||||
OutputSignal fuelActuators[MAX_INJECTION_OUTPUT_COUNT];
|
||||
|
||||
float fsioLastValue[LE_COMMAND_COUNT];
|
||||
|
||||
/**
|
||||
|
@ -210,7 +212,7 @@ typedef void (*configuration_callback_t)(Engine*);
|
|||
class Engine {
|
||||
public:
|
||||
Engine(persistent_config_s *config);
|
||||
void init();
|
||||
void init(persistent_config_s *config);
|
||||
RpmCalculator rpmCalculator;
|
||||
persistent_config_s *config;
|
||||
engine_configuration_s *engineConfiguration;
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "signal_executor.h"
|
||||
#include "fl_stack.h"
|
||||
|
||||
#define MAX_EVENT_COUNT 80
|
||||
|
||||
/**
|
||||
* This structure defines an angle position within the trigger
|
||||
*/
|
||||
|
@ -34,14 +32,15 @@ public:
|
|||
class InjectionEvent {
|
||||
public:
|
||||
InjectionEvent();
|
||||
event_trigger_position_s injectionStart;
|
||||
OutputSignal actuator;
|
||||
int injectorIndex;
|
||||
/**
|
||||
* This is a performance optimization - it's more efficient to handle all
|
||||
* injectors together if that's the case
|
||||
*/
|
||||
bool isSimultanious;
|
||||
NamedOutputPin *output;
|
||||
int injectorIndex;
|
||||
|
||||
event_trigger_position_s injectionStart;
|
||||
};
|
||||
|
||||
class IgnitionEvent {
|
||||
|
@ -57,10 +56,11 @@ public:
|
|||
char *name;
|
||||
};
|
||||
|
||||
#define OUTPUT_SIGNAL_MAX_SIZE2 45
|
||||
#define MAX_INJECTION_OUTPUT_COUNT 45
|
||||
#define MAX_IGNITION_EVENT_COUNT 80
|
||||
|
||||
typedef ArrayList<InjectionEvent, OUTPUT_SIGNAL_MAX_SIZE2> InjectionEventList;
|
||||
typedef ArrayList<InjectionEvent, MAX_INJECTION_OUTPUT_COUNT> InjectionEventList;
|
||||
|
||||
typedef ArrayList<IgnitionEvent, MAX_EVENT_COUNT> IgnitionEventList;
|
||||
typedef ArrayList<IgnitionEvent, MAX_IGNITION_EVENT_COUNT> IgnitionEventList;
|
||||
|
||||
#endif /* EVENT_REGISTRY_H_ */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
#if EFI_ENGINE_SNIFFER
|
||||
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
|
||||
#include "engine_sniffer.h"
|
||||
extern WaveChart waveChart;
|
||||
#endif
|
||||
|
@ -59,22 +59,19 @@ void initSignalExecutor(void) {
|
|||
}
|
||||
}
|
||||
|
||||
//uint32_t dbgStart;
|
||||
//uint32_t dbgDurr;
|
||||
|
||||
void turnPinHigh(NamedOutputPin *output) {
|
||||
efiAssertVoid(output!=NULL, "NULL @ turnPinHigh");
|
||||
#if EFI_DEFAILED_LOGGING
|
||||
#if EFI_DEFAILED_LOGGING || defined(__DOXYGEN__)
|
||||
// signal->hi_time = hTimeNow();
|
||||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
|
||||
#if EFI_GPIO
|
||||
#if EFI_GPIO || defined(__DOXYGEN__)
|
||||
// turn the output level ACTIVE
|
||||
// todo: this XOR should go inside the setOutputPinValue method
|
||||
doSetOutputPinValue2(output, true);
|
||||
// sleep for the needed duration
|
||||
#endif
|
||||
#if EFI_ENGINE_SNIFFER
|
||||
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
|
||||
// explicit check here is a performance optimization to speed up no-chart mode
|
||||
if (CONFIG(isEngineChartEnabled)) {
|
||||
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
|
||||
|
@ -83,31 +80,31 @@ void turnPinHigh(NamedOutputPin *output) {
|
|||
|
||||
addWaveChartEvent(pinName, WC_UP);
|
||||
}
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
// dbgDurr = hal_lld_get_counter_value() - dbgStart;
|
||||
}
|
||||
|
||||
void turnPinLow(NamedOutputPin *output) {
|
||||
efiAssertVoid(output!=NULL, "NULL turnPinLow");
|
||||
#if EFI_GPIO
|
||||
#if EFI_GPIO || defined(__DOXYGEN__)
|
||||
// turn off the output
|
||||
doSetOutputPinValue2(output, false);
|
||||
#endif
|
||||
#endif /* EFI_GPIO */
|
||||
|
||||
#if EFI_DEFAILED_LOGGING
|
||||
#if EFI_DEFAILED_LOGGING || defined(__DOXYGEN__)
|
||||
systime_t after = hTimeNow();
|
||||
debugInt(&signal->logging, "a_time", after - signal->hi_time);
|
||||
scheduleLogging(&signal->logging);
|
||||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
|
||||
#if EFI_ENGINE_SNIFFER
|
||||
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
|
||||
if (CONFIG(isEngineChartEnabled)) {
|
||||
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
|
||||
const char *pinName = output->name;
|
||||
|
||||
addWaveChartEvent(pinName, WC_DOWN);
|
||||
}
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
}
|
||||
|
||||
int getRevolutionCounter(void);
|
||||
|
@ -119,7 +116,7 @@ int getRevolutionCounter(void);
|
|||
* @param dwell the number of ticks of output duration
|
||||
*
|
||||
*/
|
||||
void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayUs, float durationUs) {
|
||||
void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayUs, float durationUs, NamedOutputPin *output) {
|
||||
#if EFI_GPIO
|
||||
if (durationUs < 0) {
|
||||
warning(OBD_PCM_Processor_Fault, "duration cannot be negative: %d", durationUs);
|
||||
|
@ -135,7 +132,7 @@ void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayUs, floa
|
|||
scheduling_s * sUp = &signal->signalTimerUp[index];
|
||||
scheduling_s * sDown = &signal->signalTimerDown[index];
|
||||
|
||||
scheduleByTime("out up", sUp, nowUs + (int) delayUs, (schfunc_t) &turnPinHigh, signal->output);
|
||||
scheduleByTime("out down", sDown, nowUs + (int) (delayUs + durationUs), (schfunc_t) &turnPinLow, signal->output);
|
||||
scheduleByTime("out up", sUp, nowUs + (int) delayUs, (schfunc_t) &turnPinHigh, output);
|
||||
scheduleByTime("out down", sDown, nowUs + (int) (delayUs + durationUs), (schfunc_t) &turnPinLow, output);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
*/
|
||||
typedef struct OutputSignal_struct OutputSignal;
|
||||
struct OutputSignal_struct {
|
||||
NamedOutputPin *output;
|
||||
|
||||
/**
|
||||
* We are alternating instances so that events which extend into next revolution are not reused while
|
||||
|
@ -39,7 +38,7 @@ struct OutputSignal_struct {
|
|||
scheduling_s signalTimerDown[2];
|
||||
};
|
||||
|
||||
void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayUs, float durationUs);
|
||||
void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayUs, float durationUs, NamedOutputPin *output);
|
||||
void initSignalExecutor(void);
|
||||
|
||||
void initSignalExecutorImpl(void);
|
||||
|
|
|
@ -98,6 +98,7 @@ engine_configuration2_s * engineConfiguration2 = &ec2;
|
|||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||
|
||||
/**
|
||||
* todo: eliminate constructor parameter so that _engine could be moved to CCM_OPTIONAL
|
||||
* todo: this should probably become 'static', i.e. private, and propagated around explicitly?
|
||||
*/
|
||||
Engine _engine(&persistentState.persistentConfiguration);
|
||||
|
|
|
@ -149,7 +149,7 @@ void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle,
|
|||
}
|
||||
|
||||
ev->injectorIndex = injectorIndex;
|
||||
ev->actuator.output = output;
|
||||
ev->output = output;
|
||||
|
||||
ev->isSimultanious = isSimultanious;
|
||||
|
||||
|
@ -396,10 +396,7 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) {
|
|||
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
||||
ENGINE(angleExtra[i])= ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
|
||||
|
||||
|
||||
|
||||
ENGINE(ignitionPin[i]) = getIgnitionPinForIndex(i PASS_ENGINE_PARAMETER);
|
||||
|
||||
}
|
||||
|
||||
int engineCycleInt = (int) ENGINE(engineCycle);
|
||||
|
@ -410,10 +407,8 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) {
|
|||
TRIGGER_SHAPE(triggerIndexByAngle[angle]) = triggerShapeIndex;
|
||||
}
|
||||
|
||||
engineConfiguration2->crankingInjectionEvents.addFuelEvents(
|
||||
engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER);
|
||||
engineConfiguration2->injectionEvents.addFuelEvents(
|
||||
engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@ class scheduling_s {
|
|||
public:
|
||||
scheduling_s();
|
||||
|
||||
#if EFI_SIGNAL_EXECUTOR_SLEEP
|
||||
#if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__)
|
||||
VirtualTimer timer;
|
||||
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ static void endSimultaniousInjection(Engine *engine) {
|
|||
|
||||
extern WallFuel wallFuel;
|
||||
|
||||
static ALWAYS_INLINE void handleFuelInjectionEvent(bool limitedFuel, InjectionEvent *event,
|
||||
static ALWAYS_INLINE void handleFuelInjectionEvent(int eventIndex, bool limitedFuel, InjectionEvent *event,
|
||||
int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
if (limitedFuel)
|
||||
return; // todo: move this check up
|
||||
|
@ -130,6 +130,8 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(bool limitedFuel, InjectionEv
|
|||
|
||||
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffset;
|
||||
|
||||
OutputSignal *signal = &ENGINE(engineConfiguration2)->fuelActuators[eventIndex];
|
||||
|
||||
if (event->isSimultanious) {
|
||||
if (injectionDuration < 0) {
|
||||
firmwareError("duration cannot be negative: %d", injectionDuration);
|
||||
|
@ -144,7 +146,6 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(bool limitedFuel, InjectionEv
|
|||
* '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;
|
||||
efiAssertVoid(signal!=NULL, "signal is NULL");
|
||||
int index = getRevolutionCounter() % 2;
|
||||
scheduling_s * sUp = &signal->signalTimerUp[index];
|
||||
|
@ -155,7 +156,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(bool limitedFuel, InjectionEv
|
|||
(schfunc_t) &endSimultaniousInjection, engine);
|
||||
|
||||
} else {
|
||||
scheduleOutput(&event->actuator, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration));
|
||||
scheduleOutput(signal, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration), event->output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,9 +170,7 @@ static ALWAYS_INLINE void handleFuel(bool limitedFuel, uint32_t eventIndex, int
|
|||
* Ignition events are defined by addFuelEvents() according to selected
|
||||
* fueling strategy
|
||||
*/
|
||||
FuelSchedule *fs =
|
||||
isCrankingR(rpm) ?
|
||||
&ENGINE(engineConfiguration2)->crankingInjectionEvents : &ENGINE(engineConfiguration2)->injectionEvents;
|
||||
FuelSchedule *fs = &ENGINE(engineConfiguration2)->injectionEvents;
|
||||
|
||||
InjectionEventList *source = &fs->injectionEvents;
|
||||
|
||||
|
@ -187,7 +186,7 @@ static ALWAYS_INLINE void handleFuel(bool limitedFuel, uint32_t eventIndex, int
|
|||
InjectionEvent *event = &source->elements[i];
|
||||
if (event->injectionStart.eventIndex != eventIndex)
|
||||
continue;
|
||||
handleFuelInjectionEvent(limitedFuel, event, rpm PASS_ENGINE_PARAMETER);
|
||||
handleFuelInjectionEvent(i, limitedFuel, event, rpm PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,13 +362,10 @@ static ALWAYS_INLINE void scheduleIgnitionAndFuelEvents(int rpm, int revolutionI
|
|||
|
||||
ENGINE(m.beforeInjectonSch) = GET_TIMESTAMP();
|
||||
|
||||
if (isCrankingR(rpm)) {
|
||||
ENGINE(engineConfiguration2)->crankingInjectionEvents.addFuelEvents(
|
||||
engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER);
|
||||
} else {
|
||||
ENGINE(engineConfiguration2)->injectionEvents.addFuelEvents(
|
||||
CONFIG(injectionMode) PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
injection_mode_e mode = isCrankingR(rpm) ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
|
||||
|
||||
ENGINE(engineConfiguration2)->injectionEvents.addFuelEvents(
|
||||
mode PASS_ENGINE_PARAMETER);
|
||||
ENGINE(m.injectonSchTime) = GET_TIMESTAMP() - ENGINE(m.beforeInjectonSch);
|
||||
}
|
||||
|
||||
|
|
|
@ -523,7 +523,6 @@ void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMET
|
|||
|
||||
default:
|
||||
firmwareError("initializeTriggerShape() not implemented: %d", triggerConfig->type);
|
||||
;
|
||||
return;
|
||||
}
|
||||
wave.checkSwitchTimes(getSize());
|
||||
|
|
|
@ -275,5 +275,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 20160123;
|
||||
return 20160125;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue