Starter seems to be engaged forever fix #1965
This commit is contained in:
parent
7c2cb1d2ac
commit
47fbb92bff
|
@ -90,6 +90,7 @@ public:
|
||||||
|
|
||||||
PrimaryTriggerConfiguration primaryTriggerConfiguration;
|
PrimaryTriggerConfiguration primaryTriggerConfiguration;
|
||||||
VvtTriggerConfiguration vvtTriggerConfiguration;
|
VvtTriggerConfiguration vvtTriggerConfiguration;
|
||||||
|
efitick_t startStopStateLastPushTime = 0;
|
||||||
|
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
void OnTriggerStateDecodingError();
|
void OnTriggerStateDecodingError();
|
||||||
|
|
|
@ -149,6 +149,7 @@ static void onStartStopButtonToggle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (engine->rpmCalculator.isStopped()) {
|
if (engine->rpmCalculator.isStopped()) {
|
||||||
bool wasStarterEngaged = enginePins.starterControl.getAndSet(1);
|
bool wasStarterEngaged = enginePins.starterControl.getAndSet(1);
|
||||||
if (!wasStarterEngaged) {
|
if (!wasStarterEngaged) {
|
||||||
|
engine->startStopStateLastPushTime = getTimeNowNt();
|
||||||
scheduleMsg(&sharedLogger, "Let's crank this engine for up to %dseconds!", CONFIG(startCrankingDuration));
|
scheduleMsg(&sharedLogger, "Let's crank this engine for up to %dseconds!", CONFIG(startCrankingDuration));
|
||||||
}
|
}
|
||||||
} else if (engine->rpmCalculator.isRunning()) {
|
} else if (engine->rpmCalculator.isRunning()) {
|
||||||
|
@ -167,12 +168,26 @@ void slowStartStopButtonCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
engine->startStopState = startStopState;
|
engine->startStopState = startStopState;
|
||||||
|
|
||||||
|
if (engine->startStopStateLastPushTime == 0) {
|
||||||
|
// nothing is going on with startStop button
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// todo: should this be simply FSIO?
|
// todo: should this be simply FSIO?
|
||||||
if (engine->rpmCalculator.isRunning()) {
|
if (engine->rpmCalculator.isRunning()) {
|
||||||
// turn starter off once engine is running
|
// turn starter off once engine is running
|
||||||
bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
|
bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
|
||||||
if (wasStarterEngaged) {
|
if (wasStarterEngaged) {
|
||||||
scheduleMsg(&sharedLogger, "Engine runs we can disengage the starter");
|
scheduleMsg(&sharedLogger, "Engine runs we can disengage the starter");
|
||||||
|
engine->startStopStateLastPushTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTimeNowNt() - engine->startStopStateLastPushTime > NT_PER_SECOND * CONFIG(startCrankingDuration)) {
|
||||||
|
bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
|
||||||
|
if (wasStarterEngaged) {
|
||||||
|
scheduleMsg(&sharedLogger, "Cranking timeout %d seconds", CONFIG(startCrankingDuration));
|
||||||
|
engine->startStopStateLastPushTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ void InjectorOutputPin::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: this could be refactored by calling some super-reset method
|
// todo: this could be refactored by calling some super-reset method
|
||||||
currentLogicValue = INITIAL_PIN_STATE;
|
currentLogicValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IgnitionOutputPin::IgnitionOutputPin() {
|
IgnitionOutputPin::IgnitionOutputPin() {
|
||||||
|
@ -524,7 +524,7 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->currentLogicValue = INITIAL_PIN_STATE;
|
this->currentLogicValue = 0;
|
||||||
|
|
||||||
// The order of the next two calls may look strange, which is a good observation.
|
// The order of the next two calls may look strange, which is a good observation.
|
||||||
// We call them in this order so that the pin is set to a known state BEFORE
|
// We call them in this order so that the pin is set to a known state BEFORE
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
brain_pin_e brainPin;
|
brain_pin_e brainPin;
|
||||||
#endif /* EFI_GPIO_HARDWARE */
|
#endif /* EFI_GPIO_HARDWARE */
|
||||||
|
|
||||||
int8_t currentLogicValue = INITIAL_PIN_STATE;
|
int8_t currentLogicValue = 0;
|
||||||
/**
|
/**
|
||||||
* we track current pin status so that we do not touch the actual hardware if we want to write new pin bit
|
* we track current pin status so that we do not touch the actual hardware if we want to write new pin bit
|
||||||
* which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering
|
* which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#define INITIAL_PIN_STATE -1
|
|
||||||
#define GPIO_NULL NULL
|
#define GPIO_NULL NULL
|
||||||
|
|
||||||
// mode >= 0 is always true since that's an unsigned
|
// mode >= 0 is always true since that's an unsigned
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
TEST(start, startStop) {
|
TEST(start, startStop) {
|
||||||
WITH_ENGINE_TEST_HELPER(BMW_M73_PROTEUS);
|
WITH_ENGINE_TEST_HELPER(BMW_M73_PROTEUS);
|
||||||
|
eth.smartMoveTimeForwardSeconds(1); // '0' time has special meaning for implementation so let's move forward
|
||||||
|
|
||||||
// this is a pull-up, so 'true' on start-up
|
// this is a pull-up, so 'true' on start-up
|
||||||
setMockState(engineConfiguration->startStopButtonPin, true);
|
setMockState(engineConfiguration->startStopButtonPin, true);
|
||||||
|
|
||||||
|
@ -33,8 +35,6 @@ TEST(start, startStop) {
|
||||||
|
|
||||||
eth.smartMoveTimeForwardSeconds(5);
|
eth.smartMoveTimeForwardSeconds(5);
|
||||||
slowStartStopButtonCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
slowStartStopButtonCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
// todo: FIX THIS, starter wire should go off on timeout!
|
// starter is now OFF due to timeout
|
||||||
ASSERT_TRUE(efiReadPin(engineConfiguration->starterControlPin));
|
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue