refactoring
This commit is contained in:
parent
ba59ef00e7
commit
f189bbab04
|
@ -37,11 +37,17 @@ class IgnitionEvent {
|
|||
public:
|
||||
IgnitionEvent();
|
||||
IgnitionOutputPin *outputs[MAX_OUTPUTS_FOR_IGNITION];
|
||||
scheduling_s signalTimerUp;
|
||||
scheduling_s dwellStartTimer;
|
||||
scheduling_s signalTimerDown;
|
||||
/**
|
||||
* Desired timing advance
|
||||
*/
|
||||
angle_t advance = NAN;
|
||||
floatms_t sparkDwell;
|
||||
uint32_t startOfDwell;
|
||||
/**
|
||||
* this timestamp allows us to measure actual dwell time
|
||||
*/
|
||||
uint32_t actualStartOfDwellNt;
|
||||
event_trigger_position_s dwellPosition;
|
||||
event_trigger_position_s sparkPosition;
|
||||
/**
|
||||
|
@ -49,7 +55,7 @@ public:
|
|||
*/
|
||||
IgnitionEvent *next = nullptr;
|
||||
/**
|
||||
* Sequential number of all spark events
|
||||
* Sequential number of currently processed spark event
|
||||
* @see globalSparkIdCounter
|
||||
*/
|
||||
int sparkId = 0;
|
||||
|
@ -68,7 +74,6 @@ public:
|
|||
|
||||
class IgnitionEventList {
|
||||
public:
|
||||
IgnitionEventList();
|
||||
IgnitionEvent elements[MAX_IGNITION_EVENT_COUNT];
|
||||
bool isReady;
|
||||
bool isReady = false;
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ class InjectionSignalPair {
|
|||
public:
|
||||
InjectionSignalPair();
|
||||
scheduling_s signalTimerUp;
|
||||
scheduling_s signalTimerDown;
|
||||
scheduling_s endOfInjectionEvent;
|
||||
|
||||
/**
|
||||
* we need atomic flag so that we do not schedule a new pair of up/down before previous down was executed.
|
||||
|
|
|
@ -282,7 +282,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
|||
|
||||
scheduling_s * sUp = &pair->signalTimerUp;
|
||||
// todo: sequential need this logic as well, just do not forget to clear flag pair->isScheduled = true;
|
||||
scheduling_s * sDown = &pair->signalTimerDown;
|
||||
scheduling_s * sDown = &pair->endOfInjectionEvent;
|
||||
|
||||
engine->executor.scheduleForLater(sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, engine);
|
||||
engine->executor.scheduleForLater(sDown, (int) injectionStartDelayUs + durationUs,
|
||||
|
@ -323,7 +323,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
|||
pair->outputs[0] = output;
|
||||
pair->outputs[1] = event->outputs[1];
|
||||
scheduling_s * sUp = &pair->signalTimerUp;
|
||||
scheduling_s * sDown = &pair->signalTimerDown;
|
||||
scheduling_s * sDown = &pair->endOfInjectionEvent;
|
||||
|
||||
pair->isScheduled = true;
|
||||
pair->event = event;
|
||||
|
@ -582,7 +582,7 @@ void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
primeInjEvent.ownIndex = 0;
|
||||
primeInjEvent.isSimultanious = true;
|
||||
|
||||
scheduling_s *sDown = &ENGINE(fuelActuators[0]).signalTimerDown;
|
||||
scheduling_s *sDown = &ENGINE(fuelActuators[0]).endOfInjectionEvent;
|
||||
// When the engine is hot, basically we don't need prime inj.pulse, so we use an interpolation over temperature (falloff).
|
||||
// If 'primeInjFalloffTemperature' is not specified (by default), we have a prime pulse deactivation at zero celsius degrees, which is okay.
|
||||
const float maxPrimeInjAtTemperature = -40.0f; // at this temperature the pulse is maximal.
|
||||
|
|
|
@ -27,10 +27,6 @@ static Logging *logger;
|
|||
|
||||
static const char *prevSparkName = nullptr;
|
||||
|
||||
IgnitionEventList::IgnitionEventList() {
|
||||
isReady = false;
|
||||
}
|
||||
|
||||
int isInjectionEnabled(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
// todo: is this worth a method? should this be inlined?
|
||||
return CONFIG(isInjectionEnabled);
|
||||
|
@ -129,7 +125,7 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
|
|||
}
|
||||
#if !EFI_UNIT_TEST
|
||||
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
|
||||
uint32_t actualDwellDurationNt = getTimeNowLowerNt() - event->startOfDwell;
|
||||
uint32_t actualDwellDurationNt = getTimeNowLowerNt() - event->actualStartOfDwellNt;
|
||||
/**
|
||||
* ratio of desired dwell duration to actual dwell duration gives us some idea of how good is input trigger jitter
|
||||
*/
|
||||
|
@ -201,7 +197,7 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
|
|||
}
|
||||
|
||||
void turnSparkPinHigh(IgnitionEvent *event) {
|
||||
event->startOfDwell = getTimeNowLowerNt();
|
||||
event->actualStartOfDwellNt = getTimeNowLowerNt();
|
||||
for (int i = 0; i< MAX_OUTPUTS_FOR_IGNITION;i++) {
|
||||
IgnitionOutputPin *output = event->outputs[i];
|
||||
if (output != NULL) {
|
||||
|
@ -241,7 +237,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
|
|||
* We are alternating two event lists in order to avoid a potential issue around revolution boundary
|
||||
* when an event is scheduled within the next revolution.
|
||||
*/
|
||||
scheduling_s * sUp = &iEvent->signalTimerUp;
|
||||
scheduling_s * sUp = &iEvent->dwellStartTimer;
|
||||
scheduling_s * sDown = &iEvent->signalTimerDown;
|
||||
|
||||
|
||||
|
@ -348,7 +344,7 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(DECLARE_ENGINE_PARAMETER_SIGNA
|
|||
engine->m.beforeIgnitionSch = getTimeNowLowerNt();
|
||||
/**
|
||||
* TODO: warning. there is a bit of a hack here, todo: improve.
|
||||
* currently output signals/times signalTimerUp from the previous revolutions could be
|
||||
* currently output signals/times dwellStartTimer from the previous revolutions could be
|
||||
* still used because they have crossed the revolution boundary
|
||||
* but we are already re-purposing the output signals, but everything works because we
|
||||
* are not affecting that space in memory. todo: use two instances of 'ignitionSignals'
|
||||
|
|
Loading…
Reference in New Issue