steps towards #975

This commit is contained in:
rusefi 2019-10-18 19:45:32 -04:00
parent d9401fbdbc
commit 627f73502b
4 changed files with 34 additions and 17 deletions

View File

@ -530,21 +530,26 @@ bool isIdleHardwareRestartNeeded() {
return isConfigurationChanged(stepperEnablePin) || return isConfigurationChanged(stepperEnablePin) ||
isConfigurationChanged(stepperEnablePinMode) || isConfigurationChanged(stepperEnablePinMode) ||
isConfigurationChanged(bc.idle.stepperStepPin) || isConfigurationChanged(bc.idle.stepperStepPin) ||
isConfigurationChanged(bc.idle.stepperStepPin) || isConfigurationChanged(bc.idle.solenoidFrequency) ||
isConfigurationChanged(bc.idle.solenoidFrequency) || isConfigurationChanged(bc.useStepperIdle) ||
// isConfigurationChanged() || // isConfigurationChanged() ||
// isConfigurationChanged() ||
// isConfigurationChanged() ||
isConfigurationChanged(bc.useETBforIdleControl) || isConfigurationChanged(bc.useETBforIdleControl) ||
isConfigurationChanged(bc.idle.solenoidPin); isConfigurationChanged(bc.idle.solenoidPin);
} }
static void stopIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void stopIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
brain_pin_markUnused(activeConfiguration.stepperEnablePin);
brain_pin_markUnused(activeConfiguration.bc.idle.stepperStepPin);
brain_pin_markUnused(activeConfiguration.bc.idle.solenoidPin);
// brain_pin_markUnused(activeConfiguration.bc.idle.);
// brain_pin_markUnused(activeConfiguration.bc.idle.);
// brain_pin_markUnused(activeConfiguration.bc.idle.);
// brain_pin_markUnused(activeConfiguration.bc.idle.);
} }
static void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (CONFIGB(useStepperIdle)) { if (CONFIGB(useStepperIdle)) {
iacMotor.initialize(CONFIGB(idle).stepperStepPin, iacMotor.initialize(CONFIGB(idle).stepperStepPin,
CONFIGB(idle).stepperDirectionPin, CONFIGB(idle).stepperDirectionPin,
@ -555,7 +560,7 @@ static void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
logger); logger);
// This greatly improves PID accuracy for steppers with a small number of steps // This greatly improves PID accuracy for steppers with a small number of steps
idlePositionSensitivityThreshold = 1.0f / engineConfiguration->idleStepperTotalSteps; idlePositionSensitivityThreshold = 1.0f / engineConfiguration->idleStepperTotalSteps;
} else { } else if (!engineConfiguration->bc.useETBforIdleControl) {
/** /**
* Start PWM for idleValvePin * Start PWM for idleValvePin
*/ */
@ -576,10 +581,6 @@ void startIdleThread(Logging*sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
idlePid.initPidClass(&engineConfiguration->idleRpmPid); idlePid.initPidClass(&engineConfiguration->idleRpmPid);
#if ! EFI_UNIT_TEST
// todo: re-initialize idle pins on the fly
initIdleHardware(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_UNIT_TEST */
DISPLAY_STATE(Engine) DISPLAY_STATE(Engine)
DISPLAY_TEXT(Idle_State); DISPLAY_TEXT(Idle_State);

View File

@ -3,11 +3,10 @@
* @brief Idle Valve Control thread * @brief Idle Valve Control thread
* *
* @date May 23, 2013 * @date May 23, 2013
* @author Andrey Belomutskiy, (c) 2012-2017 * @author Andrey Belomutskiy, (c) 2012-2019
*/ */
#ifndef IDLE_THREAD_H_ #pragma once
#define IDLE_THREAD_H_
#include "engine.h" #include "engine.h"
#include "periodic_task.h" #include "periodic_task.h"
@ -33,6 +32,8 @@ void setIdleDFactor(float value);
void setIdleMode(idle_mode_e value); void setIdleMode(idle_mode_e value);
void setTargetIdleRpm(int value); void setTargetIdleRpm(int value);
void setIdleDT(int value); void setIdleDT(int value);
void stopIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool isIdleHardwareRestartNeeded();
void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration); void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration);
#endif /* IDLE_THREAD_H_ */

View File

@ -837,6 +837,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0) if (initBootloader() != 0)
return 123; return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */ #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191016; return 20191018;
} }
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */

View File

@ -33,6 +33,7 @@
#include "AdcConfiguration.h" #include "AdcConfiguration.h"
#include "electronic_throttle.h" #include "electronic_throttle.h"
#include "idle_thread.h"
#include "mcp3208.h" #include "mcp3208.h"
#include "hip9011.h" #include "hip9011.h"
#include "histogram.h" #include "histogram.h"
@ -274,6 +275,7 @@ void applyNewHardwareSettings(void) {
stopTriggerInputPins(); stopTriggerInputPins();
#endif /* EFI_SHAFT_POSITION_INPUT */ #endif /* EFI_SHAFT_POSITION_INPUT */
#if (HAL_USE_PAL && EFI_JOYSTICK) #if (HAL_USE_PAL && EFI_JOYSTICK)
stopJoystickPins(); stopJoystickPins();
#endif /* HAL_USE_PAL && EFI_JOYSTICK */ #endif /* HAL_USE_PAL && EFI_JOYSTICK */
@ -288,6 +290,13 @@ void applyNewHardwareSettings(void) {
stopHip9001_pins(); stopHip9001_pins();
#endif /* EFI_HIP_9011 */ #endif /* EFI_HIP_9011 */
#if EFI_IDLE_CONTROL
bool isIdleRestartNeeded = isIdleHardwareRestartNeeded();
if (isIdleRestartNeeded) {
// todostopIdleHardware();
}
#endif
#if EFI_ELECTRONIC_THROTTLE_BODY #if EFI_ELECTRONIC_THROTTLE_BODY
bool etbRestartNeeded = isETBRestartNeeded(); bool etbRestartNeeded = isETBRestartNeeded();
if (etbRestartNeeded) { if (etbRestartNeeded) {
@ -348,6 +357,12 @@ void applyNewHardwareSettings(void) {
#endif /* EFI_HIP_9011 */ #endif /* EFI_HIP_9011 */
#if EFI_IDLE_CONTROL
// if (isIdleRestartNeeded) {
initIdleHardware();
// }
#endif
#if EFI_ELECTRONIC_THROTTLE_BODY #if EFI_ELECTRONIC_THROTTLE_BODY
if (etbRestartNeeded) { if (etbRestartNeeded) {
startETBPins(PASS_ENGINE_PARAMETER_SIGNATURE); startETBPins(PASS_ENGINE_PARAMETER_SIGNATURE);