minor perf tweaks (#1946)
* only start PWM if needed * put important stuff first * use conversion * this broke the logic
This commit is contained in:
parent
7cba09b3fa
commit
2f4294ac4d
|
@ -52,35 +52,44 @@ public:
|
|||
|
||||
// Configure the disable pin first - ensure things are in a safe state
|
||||
m_disablePin.initPin("ETB Disable", pinDisable);
|
||||
m_disablePin.setValue(0);
|
||||
|
||||
// Clamp to >100hz
|
||||
int clampedFrequency = maxI(100, frequency);
|
||||
|
||||
// no need to complicate event queue with ETB PWM in unit tests
|
||||
#if ! EFI_UNIT_TEST
|
||||
startSimplePwmHard(&m_pwmEnable, "ETB Enable",
|
||||
executor,
|
||||
pinEnable,
|
||||
&m_pinEnable,
|
||||
clampedFrequency,
|
||||
0
|
||||
);
|
||||
if (useTwoWires) {
|
||||
startSimplePwmHard(&m_pwmDir1, "ETB Dir 1",
|
||||
executor,
|
||||
pinDir1,
|
||||
&m_pinDir1,
|
||||
clampedFrequency,
|
||||
0
|
||||
);
|
||||
|
||||
startSimplePwmHard(&m_pwmDir1, "ETB Dir 1",
|
||||
executor,
|
||||
pinDir1,
|
||||
&m_pinDir1,
|
||||
clampedFrequency,
|
||||
0
|
||||
);
|
||||
startSimplePwmHard(&m_pwmDir2, "ETB Dir 2",
|
||||
executor,
|
||||
pinDir2,
|
||||
&m_pinDir2,
|
||||
clampedFrequency,
|
||||
0
|
||||
);
|
||||
|
||||
startSimplePwmHard(&m_pwmDir2, "ETB Dir 2",
|
||||
executor,
|
||||
pinDir2,
|
||||
&m_pinDir2,
|
||||
clampedFrequency,
|
||||
0
|
||||
);
|
||||
m_pinEnable.initPin("ETB Enable", pinEnable);
|
||||
|
||||
} else {
|
||||
m_pinDir1.initPin("ETB Dir 1", pinDir1);
|
||||
m_pinDir2.initPin("ETB Dir 2", pinDir2);
|
||||
|
||||
startSimplePwmHard(&m_pwmEnable, "ETB Enable",
|
||||
executor,
|
||||
pinEnable,
|
||||
&m_pinEnable,
|
||||
clampedFrequency,
|
||||
0
|
||||
);
|
||||
}
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
}
|
||||
};
|
||||
|
|
|
@ -174,25 +174,22 @@ void initIdleHardware(Logging* sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
*/
|
||||
// todo: even for double-solenoid mode we can probably use same single SimplePWM
|
||||
// todo: open question why do we pass 'OutputPin' into 'startSimplePwmExt' if we have custom applyIdleSolenoidPinState listener anyway?
|
||||
if (!CONFIG(isDoubleSolenoidIdle)) {
|
||||
startSimplePwm(&idleSolenoidOpen, "Idle Valve",
|
||||
&engine->executor,
|
||||
&enginePins.idleSolenoidPin,
|
||||
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)),
|
||||
(pwm_gen_callback*)applyIdleSolenoidPinState);
|
||||
} else {
|
||||
if (CONFIG(idle).solenoidPin != GPIO_UNASSIGNED) {
|
||||
startSimplePwm(&idleSolenoidOpen, "Idle Valve Open",
|
||||
&engine->executor,
|
||||
&enginePins.idleSolenoidPin,
|
||||
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)),
|
||||
(pwm_gen_callback*)applyIdleSolenoidPinState);
|
||||
|
||||
startSimplePwm(&idleSolenoidClose, "Idle Valve Close",
|
||||
&engine->executor,
|
||||
&enginePins.secondIdleSolenoidPin,
|
||||
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)),
|
||||
(pwm_gen_callback*)applyIdleSolenoidPinState);
|
||||
&engine->executor,
|
||||
&enginePins.idleSolenoidPin,
|
||||
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)),
|
||||
(pwm_gen_callback*)applyIdleSolenoidPinState);
|
||||
}
|
||||
|
||||
if (CONFIG(isDoubleSolenoidIdle) && CONFIG(secondSolenoidPin) != GPIO_UNASSIGNED) {
|
||||
startSimplePwm(&idleSolenoidClose, "Idle Valve Close",
|
||||
&engine->executor,
|
||||
&enginePins.secondIdleSolenoidPin,
|
||||
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)),
|
||||
(pwm_gen_callback*)applyIdleSolenoidPinState);
|
||||
}
|
||||
|
||||
idlePositionSensitivityThreshold = 0.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,10 +87,9 @@ void setMockState(brain_pin_e pin, bool state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
/**
|
||||
* 64-bit result would not overflow, but that's complex stuff for our 32-bit MCU
|
||||
*/
|
||||
//todo: macro to save method invocation
|
||||
efitimeus_t getTimeNowUs(void) {
|
||||
ScopePerf perf(PE::GetTimeNowUs);
|
||||
return getTimeNowNt() / (CORE_CLOCK / 1000000);
|
||||
return NT2US(getTimeNowNt());
|
||||
}
|
||||
|
||||
volatile uint32_t lastLowerNt = 0;
|
||||
|
|
|
@ -130,6 +130,14 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
}
|
||||
|
||||
void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
|
||||
for (int i = 0; i< MAX_OUTPUTS_FOR_IGNITION;i++) {
|
||||
IgnitionOutputPin *output = event->outputs[i];
|
||||
|
||||
if (output) {
|
||||
fireSparkBySettingPinLow(event, output);
|
||||
}
|
||||
}
|
||||
|
||||
efitick_t nowNt = getTimeNowNt();
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
|
@ -141,13 +149,6 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
|
|||
LogTriggerCoilState(nowNt, false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif // EFI_TOOTH_LOGGER
|
||||
|
||||
for (int i = 0; i< MAX_OUTPUTS_FOR_IGNITION;i++) {
|
||||
IgnitionOutputPin *output = event->outputs[i];
|
||||
|
||||
if (output) {
|
||||
fireSparkBySettingPinLow(event, output);
|
||||
}
|
||||
}
|
||||
#if !EFI_UNIT_TEST
|
||||
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
|
||||
#if EFI_TUNER_STUDIO
|
||||
|
|
Loading…
Reference in New Issue