Skip to content

Commit 70f56d0

Browse files
committed
heater control: way out of NoHeaterSupply state
1 parent 99b87b5 commit 70f56d0

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

firmware/heater_control.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
5656
{
5757
bool heaterAllowed = heaterAllowState == HeaterAllow::Allowed;
5858

59-
// Check battery voltage for thresholds only if there is still no command over CAN
59+
#if defined(HEATER_INPUT_DIVIDER) || defined(BOARD_HAS_VOLTAGE_SENSE)
60+
// Check localy measured battery voltage for thresholds only if there is still no command over CAN
6061
if (heaterAllowState == HeaterAllow::Unknown)
6162
{
6263
// measured voltage too low to auto-start heating
@@ -71,6 +72,11 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
7172
heaterAllowed = m_heaterStableTimer.hasElapsedSec(HEATER_SUPPLY_STAB_TIME);
7273
}
7374
}
75+
#else
76+
// f0_module receives both heaterAllowed and heaterSupplyVoltage within same CAN message
77+
// no need to additionaly check heaterSupplyVoltage if ECU commands to heat/stop heating
78+
(void)heaterSupplyVoltage;
79+
#endif
7480

7581
if (!heaterAllowed)
7682
{
@@ -150,9 +156,23 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
150156

151157
break;
152158
case HeaterState::Stopped:
153-
case HeaterState::NoHeaterSupply:
154159
/* nop */
155160
break;
161+
case HeaterState::NoHeaterSupply:
162+
#if defined(HEATER_INPUT_DIVIDER) || defined(BOARD_HAS_VOLTAGE_SENSE)
163+
if (heaterSupplyVoltage > HEATER_SUPPLY_ON_VOLTAGE)
164+
{
165+
// measured voltage is high enougth to auto-start heating, wait some time to stabilize
166+
if (m_heaterStableTimer.hasElapsedSec(HEATER_SUPPLY_STAB_TIME)) {
167+
m_preheatTimer.reset();
168+
return HeaterState::Preheat;
169+
}
170+
}
171+
#else
172+
m_preheatTimer.reset();
173+
return HeaterState::Preheat;
174+
#endif
175+
break;
156176
}
157177

158178
return currentState;

0 commit comments

Comments
 (0)