parent
6cafebc6bd
commit
299a345c1c
|
@ -172,6 +172,8 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara
|
||||||
m_pid.initPidClass(pidParameters);
|
m_pid.initPidClass(pidParameters);
|
||||||
m_pedalMap = pedalMap;
|
m_pedalMap = pedalMap;
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,6 +758,10 @@ void setDefaultEtbParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default is to run each throttle off its respective hbridge
|
||||||
|
engineConfiguration->etbFunctions[0] = ETB_Throttle1;
|
||||||
|
engineConfiguration->etbFunctions[1] = ETB_Throttle2;
|
||||||
|
|
||||||
engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
|
engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
|
||||||
|
|
||||||
// voltage, not ADC like with TPS
|
// voltage, not ADC like with TPS
|
||||||
|
@ -831,16 +837,23 @@ void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
engine->etbActualCount = Sensor::hasSensor(SensorType::Tps2) ? 2 : 1;
|
engine->etbActualCount = Sensor::hasSensor(SensorType::Tps2) ? 2 : 1;
|
||||||
|
|
||||||
|
bool anyEtbConfigured = false;
|
||||||
|
|
||||||
for (int i = 0 ; i < engine->etbActualCount; i++) {
|
for (int i = 0 ; i < engine->etbActualCount; i++) {
|
||||||
auto motor = initDcMotor(i, CONFIG(etb_use_two_wires) PASS_ENGINE_PARAMETER_SUFFIX);
|
auto motor = initDcMotor(i, CONFIG(etb_use_two_wires) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
// If this motor is actually set up, init the etb
|
// If this motor is actually set up, init the etb
|
||||||
if (motor)
|
if (motor)
|
||||||
{
|
{
|
||||||
|
auto controller = engine->etbControllers[i];
|
||||||
|
if (!controller) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: configure per-motor in config so wastegate/VW idle works
|
// TODO: configure per-motor in config so wastegate/VW idle works
|
||||||
auto func = i == 0 ? ETB_Throttle1 : ETB_Throttle2;
|
auto func = i == 0 ? ETB_Throttle1 : ETB_Throttle2;
|
||||||
|
|
||||||
engine->etbControllers[i]->init(func, motor, &engineConfiguration->etb, &pedal2tpsMap);
|
anyEtbConfigured |= controller->init(func, motor, &engineConfiguration->etb, &pedal2tpsMap);
|
||||||
INJECT_ENGINE_REFERENCE(engine->etbControllers[i]);
|
INJECT_ENGINE_REFERENCE(engine->etbControllers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -858,8 +871,6 @@ void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
||||||
etbPidReset(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
||||||
|
|
||||||
#if !EFI_UNIT_TEST
|
#if !EFI_UNIT_TEST
|
||||||
etbThread.Start();
|
etbThread.Start();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,7 +47,6 @@ TEST(etb, initializationSingleThrottle) {
|
||||||
|
|
||||||
// Expect mock0 to be init as throttle 1, and PID params
|
// Expect mock0 to be init as throttle 1, and PID params
|
||||||
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr))).WillOnce(Return(true));
|
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr))).WillOnce(Return(true));
|
||||||
EXPECT_CALL(mocks[0], reset);
|
|
||||||
|
|
||||||
// We do not expect throttle #2 to be initialized
|
// We do not expect throttle #2 to be initialized
|
||||||
|
|
||||||
|
@ -72,11 +71,9 @@ TEST(etb, initializationDualThrottle) {
|
||||||
|
|
||||||
// Expect mock0 to be init as throttle 1, and PID params
|
// Expect mock0 to be init as throttle 1, and PID params
|
||||||
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr))).WillOnce(Return(true));
|
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr))).WillOnce(Return(true));
|
||||||
EXPECT_CALL(mocks[0], reset);
|
|
||||||
|
|
||||||
// Expect mock1 to be init as throttle 2, and PID params
|
// Expect mock1 to be init as throttle 2, and PID params
|
||||||
EXPECT_CALL(mocks[1], init(ETB_Throttle2, _, &engineConfiguration->etb, Ne(nullptr))).WillOnce(Return(true));
|
EXPECT_CALL(mocks[1], init(ETB_Throttle2, _, &engineConfiguration->etb, Ne(nullptr))).WillOnce(Return(true));
|
||||||
EXPECT_CALL(mocks[1], reset);
|
|
||||||
|
|
||||||
doInitElectronicThrottle(PASS_ENGINE_PARAMETER_SIGNATURE);
|
doInitElectronicThrottle(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue