auto-sync
This commit is contained in:
parent
f980820f6d
commit
b4bcc7f891
|
@ -88,7 +88,8 @@ static void endSimultaniousInjection(Engine *engine) {
|
|||
}
|
||||
|
||||
// todo: make these macro? kind of a penny optimization if compiler is not smart to inline
|
||||
void seTurnPinHigh(InjectorOutputPin *output) {
|
||||
void seTurnPinHigh(OutputSignalPair *pair) {
|
||||
InjectorOutputPin *output = pair->output;
|
||||
// output->overlappingCounter++;
|
||||
|
||||
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
||||
|
@ -125,7 +126,8 @@ void seTurnPinHigh(InjectorOutputPin *output) {
|
|||
turnPinHigh(output);
|
||||
}
|
||||
|
||||
void seTurnPinLow(InjectorOutputPin *output) {
|
||||
void seTurnPinLow(OutputSignalPair *pair) {
|
||||
InjectorOutputPin *output = pair->output;
|
||||
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
||||
printf("seTurnPinLow %s %d %d\r\n", output->name, output->overlappingCounter, (int)getTimeNowUs());
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
|
@ -168,7 +170,8 @@ void seTurnPinLow(InjectorOutputPin *output) {
|
|||
turnPinLow(output);
|
||||
}
|
||||
|
||||
void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, NamedOutputPin *param) {
|
||||
static void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, OutputSignalPair *pair) {
|
||||
InjectorOutputPin *param = pair->output;
|
||||
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
||||
scheduleMsg(&sharedLogger, "schX %s %x %d", prefix, scheduling, time);
|
||||
scheduleMsg(&sharedLogger, "schX %s", param->name);
|
||||
|
@ -179,7 +182,7 @@ void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t
|
|||
printf("seScheduleByTime %s %s %d sch=%d\r\n", direction, param->name, (int)time, (int)scheduling);
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING || EFI_UNIT_TEST */
|
||||
|
||||
scheduleByTime(prefix, scheduling, time, callback, param);
|
||||
scheduleByTime(prefix, scheduling, time, callback, pair);
|
||||
}
|
||||
|
||||
static void scheduleFuelInjection(int rpm, int injEventIndex, OutputSignal *signal, efitimeus_t nowUs, floatus_t delayUs, floatus_t durationUs, InjectorOutputPin *output DECLARE_ENGINE_PARAMETER_S) {
|
||||
|
@ -198,8 +201,10 @@ static void scheduleFuelInjection(int rpm, int injEventIndex, OutputSignal *sign
|
|||
|
||||
efiAssertVoid(signal!=NULL, "signal is NULL");
|
||||
int index = getRevolutionCounter() % 2;
|
||||
scheduling_s * sUp = &signal->signalPair[index].signalTimerUp;
|
||||
scheduling_s * sDown = &signal->signalPair[index].signalTimerDown;
|
||||
OutputSignalPair *pair = &signal->signalPair[index];
|
||||
pair->output = output;
|
||||
scheduling_s * sUp = &pair->signalTimerUp;
|
||||
scheduling_s * sDown = &pair->signalTimerDown;
|
||||
|
||||
efitimeus_t turnOnTime = nowUs + (int) delayUs;
|
||||
bool isSecondaryOverlapping = turnOnTime < output->overlappingScheduleOffTime;
|
||||
|
@ -210,10 +215,10 @@ static void scheduleFuelInjection(int rpm, int injEventIndex, OutputSignal *sign
|
|||
printf("please cancel %s %d %d\r\n", output->name, (int)getTimeNowUs(), output->overlappingCounter);
|
||||
#endif /* EFI_UNIT_TEST || EFI_SIMULATOR */
|
||||
} else {
|
||||
seScheduleByTime("out up", sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, output);
|
||||
seScheduleByTime("out up", sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, pair);
|
||||
}
|
||||
efitimeus_t turnOffTime = nowUs + (int) (delayUs + durationUs);
|
||||
seScheduleByTime("out down", sDown, turnOffTime, (schfunc_t) &seTurnPinLow, output);
|
||||
seScheduleByTime("out down", sDown, turnOffTime, (schfunc_t) &seTurnPinLow, pair);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionEvent *event,
|
||||
|
@ -324,10 +329,11 @@ static void scheduleOutput2(OutputSignalPair *pair, efitimeus_t nowUs, float del
|
|||
scheduling_s *sUp = &pair->signalTimerUp;
|
||||
scheduling_s *sDown = &pair->signalTimerDown;
|
||||
|
||||
seScheduleByTime("out up", sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, output);
|
||||
pair->output = output;
|
||||
seScheduleByTime("out up", sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, pair);
|
||||
efitimeus_t turnOffTime = nowUs + (int) (delayUs + durationUs);
|
||||
|
||||
seScheduleByTime("out down", sDown, turnOffTime, (schfunc_t) &seTurnPinLow, output);
|
||||
seScheduleByTime("out down", sDown, turnOffTime, (schfunc_t) &seTurnPinLow, pair);
|
||||
#endif /* EFI_GPIO */
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ int isIgnitionTimingError(void);
|
|||
|
||||
void showMainHistogram(void);
|
||||
|
||||
void seTurnPinHigh(InjectorOutputPin *output);
|
||||
void seTurnPinLow(InjectorOutputPin *output);
|
||||
void seTurnPinHigh(OutputSignalPair *pair);
|
||||
void seTurnPinLow(OutputSignalPair *pair);
|
||||
|
||||
float getFuel(int rpm, float key);
|
||||
#endif /* MAIN_LOOP_H_ */
|
||||
|
|
|
@ -288,6 +288,11 @@ static void assertREqualsM(const char *msg, void *expected, void *actual) {
|
|||
extern bool_t debugSignalExecutor;
|
||||
extern engine_pins_s enginePins;
|
||||
|
||||
// todo: move method body here after merge
|
||||
void assertEvent(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param);
|
||||
void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex);
|
||||
void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex);
|
||||
|
||||
void testRpmCalculator(void) {
|
||||
printf("*************************************************** testRpmCalculator\r\n");
|
||||
timeNow = 0;
|
||||
|
@ -405,17 +410,9 @@ void testRpmCalculator(void) {
|
|||
assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle);
|
||||
assertEqualsM("fuel #3", 4.5450, eth.engine.fuelMs);
|
||||
assertEquals(1500, eth.engine.rpmCalculator.rpmValue);
|
||||
{
|
||||
scheduling_s *ev0 = schedulingQueue.getForUnitText(0);
|
||||
|
||||
assertREqualsM("turnHigh", (void*)ev0->callback, (void*)seTurnPinHigh);
|
||||
assertEqualsM("ev 0/2", st + 26666 - 1515, ev0->momentX);
|
||||
assertEqualsLM("o 0/2", (long)&enginePins.injectors[2], (long)ev0->param);
|
||||
|
||||
scheduling_s *ev1 = schedulingQueue.getForUnitText(1);
|
||||
assertEqualsM("ev 1/2", st + 26666 - 1515, ev1->momentX);
|
||||
assertEqualsLM("o 1/2", (long)&enginePins.injectors[5], (long)ev1->param);
|
||||
}
|
||||
assertInjectorUpEvent("ev 0/2", 0, -4849, 2);
|
||||
assertInjectorUpEvent("ev 1/2", 1, -4849, 5);
|
||||
|
||||
assertEqualsM("index #4", 6, eth.engine.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
||||
|
@ -579,19 +576,20 @@ void testTriggerDecoder(void) {
|
|||
|
||||
extern fuel_Map3D_t fuelMap;
|
||||
|
||||
static void assertEvent(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param) {
|
||||
void assertEvent(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param) {
|
||||
assertTrueM(msg, schedulingQueue.size() > index);
|
||||
scheduling_s *ev = schedulingQueue.getForUnitText(index);
|
||||
assertEqualsM4(msg, "up/down", (void*)ev->callback == (void*) callback, 1);
|
||||
assertEqualsM(msg, momentX, ev->momentX - start);
|
||||
assertEqualsLM(msg, param, (long)ev->param);
|
||||
OutputSignalPair *pair = (OutputSignalPair *)ev->param;
|
||||
assertEqualsLM(msg, param, (long)pair->output);
|
||||
}
|
||||
|
||||
static void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||
void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||
assertEvent(msg, eventIndex, (void*)seTurnPinHigh, timeNow, momentX, (long)&enginePins.injectors[injectorIndex]);
|
||||
}
|
||||
|
||||
static void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||
void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||
assertEvent(msg, eventIndex, (void*)seTurnPinLow, timeNow, momentX, (long)&enginePins.injectors[injectorIndex]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue