This commit is contained in:
rusefi 2020-03-23 23:06:52 -04:00
parent c0e141026c
commit 0e6aacb3b8
1 changed files with 11 additions and 2 deletions

View File

@ -37,7 +37,7 @@ static Logging *logger;
static boostOpenLoop_Map3D_t boostMapOpen("boostmapopen", 1); static boostOpenLoop_Map3D_t boostMapOpen("boostmapopen", 1);
static boostOpenLoop_Map3D_t boostMapClosed("boostmapclosed", 1); static boostOpenLoop_Map3D_t boostMapClosed("boostmapclosed", 1);
static SimplePwm boostPwmControl("boost"); static SimplePwm boostPwmControl("boost");
static Pid boostControlPid(&persistentState.persistentConfiguration.engineConfiguration.boostPid); static Pid boostControlPid;
static bool shouldResetPid = false; static bool shouldResetPid = false;
@ -50,6 +50,8 @@ static void pidReset(void) {
} }
class BoostControl: public PeriodicTimerController { class BoostControl: public PeriodicTimerController {
DECLARE_ENGINE_PTR;
int getPeriodMs() override { int getPeriodMs() override {
return GET_PERIOD_LIMITED(&engineConfiguration->boostPid); return GET_PERIOD_LIMITED(&engineConfiguration->boostPid);
} }
@ -100,10 +102,10 @@ class BoostControl: public PeriodicTimerController {
static BoostControl BoostController; static BoostControl BoostController;
#if !EFI_UNIT_TEST
void setBoostPFactor(float value) { void setBoostPFactor(float value) {
engineConfiguration->boostPid.pFactor = value; engineConfiguration->boostPid.pFactor = value;
boostControlPid.reset(); boostControlPid.reset();
} }
void setBoostIFactor(float value) { void setBoostIFactor(float value) {
@ -115,6 +117,7 @@ void setBoostDFactor(float value) {
engineConfiguration->boostPid.dFactor = value; engineConfiguration->boostPid.dFactor = value;
boostControlPid.reset(); boostControlPid.reset();
} }
#endif /* EFI_UNIT_TEST */
void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->isBoostControlEnabled = true; engineConfiguration->isBoostControlEnabled = true;
@ -145,6 +148,7 @@ void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
} }
static void turnBoostPidOn() { static void turnBoostPidOn() {
#if !EFI_UNIT_TEST
if (CONFIG(boostControlPin) == GPIO_UNASSIGNED){ if (CONFIG(boostControlPin) == GPIO_UNASSIGNED){
return; return;
} }
@ -159,6 +163,7 @@ static void turnBoostPidOn() {
0.5f, 0.5f,
(pwm_gen_callback*) applyPinState (pwm_gen_callback*) applyPinState
); );
#endif /* EFI_UNIT_TEST */
} }
void startBoostPin(void) { void startBoostPin(void) {
@ -174,16 +179,20 @@ void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfigur
} }
void initBoostCtrl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { void initBoostCtrl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if !EFI_UNIT_TEST
if (CONFIG(boostControlPin) == GPIO_UNASSIGNED){ if (CONFIG(boostControlPin) == GPIO_UNASSIGNED){
return; return;
} }
boostControlPid.initPidClass(&persistentState.persistentConfiguration.engineConfiguration.boostPid);
logger = sharedLogger; logger = sharedLogger;
boostMapOpen.init(config->boostTableOpenLoop, config->boostMapBins, config->boostRpmBins); boostMapOpen.init(config->boostTableOpenLoop, config->boostMapBins, config->boostRpmBins);
boostMapClosed.init(config->boostTableClosedLoop, config->boostTpsBins, config->boostRpmBins); boostMapClosed.init(config->boostTableClosedLoop, config->boostTpsBins, config->boostRpmBins);
boostControlPid.reset(); boostControlPid.reset();
startBoostPin(); startBoostPin();
BoostController.Start(); BoostController.Start();
#endif
} }
#endif #endif