Update TESLA-BATTERY.cpp

This commit is contained in:
josiahhiggs 2024-12-25 20:54:16 +13:00
parent c08cbb6689
commit 931f99fb35

View file

@ -37,8 +37,8 @@ static uint16_t battery_energy_to_charge_complete = 0; // kWh
static uint16_t battery_energy_to_charge_complete_m1 = 0; // kWh
static uint16_t battery_expected_energy_remaining = 0; // kWh
static uint16_t battery_expected_energy_remaining_m1 = 0; // kWh
static bool battery_full_charge_complete = false; // Changed to bool
static bool battery_fully_charged = false; // Changed to bool
static bool battery_full_charge_complete = false; // Changed to bool
static bool battery_fully_charged = false; // Changed to bool
static uint16_t battery_ideal_energy_remaining = 0; // kWh
static uint16_t battery_ideal_energy_remaining_m0 = 0; // kWh
static uint16_t battery_nominal_energy_remaining = 0; // kWh
@ -98,46 +98,46 @@ static uint8_t battery_hvil_status = 0;
static uint8_t battery_packContNegativeState = 0;
static uint8_t battery_packContPositiveState = 0;
static uint8_t battery_packContactorSetState = 0;
static bool battery_packCtrsClosingAllowed = false; // Change to bool
static bool battery_pyroTestInProgress = false; // Change to bool
static bool battery_packCtrsOpenNowRequested = false; // Change to bool
static bool battery_packCtrsOpenRequested = false; // Change to bool
static bool battery_packCtrsClosingAllowed = false; // Change to bool
static bool battery_pyroTestInProgress = false; // Change to bool
static bool battery_packCtrsOpenNowRequested = false; // Change to bool
static bool battery_packCtrsOpenRequested = false; // Change to bool
static uint8_t battery_packCtrsRequestStatus = 0;
static bool battery_packCtrsResetRequestRequired = false; // Change to bool
static bool battery_dcLinkAllowedToEnergize = false; // Change to bool
static bool battery_fcContNegativeAuxOpen = false; // Change to bool
static bool battery_packCtrsResetRequestRequired = false; // Change to bool
static bool battery_dcLinkAllowedToEnergize = false; // Change to bool
static bool battery_fcContNegativeAuxOpen = false; // Change to bool
static uint8_t battery_fcContNegativeState = 0;
static bool battery_fcContPositiveAuxOpen = false; // Change to bool
static bool battery_fcContPositiveAuxOpen = false; // Change to bool
static uint8_t battery_fcContPositiveState = 0;
static uint8_t battery_fcContactorSetState = 0;
static bool battery_fcCtrsClosingAllowed = false; // Change to bool
static bool battery_fcCtrsOpenNowRequested = false; // Change to bool
static bool battery_fcCtrsOpenRequested = false; // Change to bool
static bool battery_fcCtrsClosingAllowed = false; // Change to bool
static bool battery_fcCtrsOpenNowRequested = false; // Change to bool
static bool battery_fcCtrsOpenRequested = false; // Change to bool
static uint8_t battery_fcCtrsRequestStatus = 0;
static bool battery_fcCtrsResetRequestRequired = false; // Change to bool
static bool battery_fcLinkAllowedToEnergize = false; // Change to bool
static bool battery_fcCtrsResetRequestRequired = false; // Change to bool
static bool battery_fcLinkAllowedToEnergize = false; // Change to bool
//0x212: 530 BMS_status
static bool battery_BMS_hvacPowerRequest = false; //Change to bool
static bool battery_BMS_notEnoughPowerForDrive = false; //Change to bool
static bool battery_BMS_notEnoughPowerForSupport = false; //Change to bool
static bool battery_BMS_preconditionAllowed = false; //Change to bool
static bool battery_BMS_updateAllowed = false; //Change to bool
static bool battery_BMS_activeHeatingWorthwhile = false; //Change to bool
static bool battery_BMS_cpMiaOnHvs = false; //Change to bool
static bool battery_BMS_hvacPowerRequest = false; //Change to bool
static bool battery_BMS_notEnoughPowerForDrive = false; //Change to bool
static bool battery_BMS_notEnoughPowerForSupport = false; //Change to bool
static bool battery_BMS_preconditionAllowed = false; //Change to bool
static bool battery_BMS_updateAllowed = false; //Change to bool
static bool battery_BMS_activeHeatingWorthwhile = false; //Change to bool
static bool battery_BMS_cpMiaOnHvs = false; //Change to bool
static uint8_t battery_BMS_contactorState = 0;
static uint8_t battery_BMS_state = 0;
static uint8_t battery_BMS_hvState = 0;
static uint16_t battery_BMS_isolationResistance = 0;
static bool battery_BMS_chargeRequest = false; //Change to bool
static bool battery_BMS_keepWarmRequest = false; //Change to bool
static bool battery_BMS_chargeRequest = false; //Change to bool
static bool battery_BMS_keepWarmRequest = false; //Change to bool
static uint8_t battery_BMS_uiChargeStatus = 0;
static bool battery_BMS_diLimpRequest = false; //Change to bool
static bool battery_BMS_okToShipByAir = false; //Change to bool
static bool battery_BMS_okToShipByLand = false; //Change to bool
static bool battery_BMS_diLimpRequest = false; //Change to bool
static bool battery_BMS_okToShipByAir = false; //Change to bool
static bool battery_BMS_okToShipByLand = false; //Change to bool
static uint32_t battery_BMS_chgPowerAvailable = 0;
static uint8_t battery_BMS_chargeRetryCount = 0;
static bool battery_BMS_pcsPwmEnabled = false; //Change to bool
static bool battery_BMS_ecuLogUploadRequest = false; //Change to bool
static bool battery_BMS_pcsPwmEnabled = false; //Change to bool
static bool battery_BMS_ecuLogUploadRequest = false; //Change to bool
static uint8_t battery_BMS_minPackTemperature = 0;
// 0x224:548 PCS_dcdcStatus
static uint8_t battery_PCS_dcdcPrechargeStatus = 0;
@ -145,7 +145,7 @@ static uint8_t battery_PCS_dcdc12VSupportStatus = 0;
static uint8_t battery_PCS_dcdcHvBusDischargeStatus = 0;
static uint16_t battery_PCS_dcdcMainState = 0;
static uint8_t battery_PCS_dcdcSubState = 0;
static bool battery_PCS_dcdcFaulted = false; //Change to bool
static bool battery_PCS_dcdcFaulted = false; //Change to bool
static bool battery_PCS_dcdcOutputIsLimited = false; //Change to bool
static uint32_t battery_PCS_dcdcMaxOutputCurrentAllowed = 0;
static uint8_t battery_PCS_dcdcPrechargeRtyCnt = 0;
@ -196,38 +196,38 @@ static uint16_t PCS_dcdcIntervalMinLvOutputCurr = 0;
static uint32_t PCS_dcdc12vSupportLifetimekWh = 0;
//0x7AA: //1962 HVP_debugMessage:
static uint8_t HVP_debugMessageMultiplexer = 0;
static bool HVP_gpioPassivePyroDepl = false; //Change to bool
static bool HVP_gpioPyroIsoEn = false; //Change to bool
static bool HVP_gpioCpFaultIn = false; //Change to bool
static bool HVP_gpioPackContPowerEn = false; //Change to bool
static bool HVP_gpioHvCablesOk = false; //Change to bool
static bool HVP_gpioHvpSelfEnable = false; //Change to bool
static bool HVP_gpioLed = false; //Change to bool
static bool HVP_gpioCrashSignal = false; //Change to bool
static bool HVP_gpioShuntDataReady = false; //Change to bool
static bool HVP_gpioFcContPosAux = false; //Change to bool
static bool HVP_gpioFcContNegAux = false; //Change to bool
static bool HVP_gpioBmsEout = false; //Change to bool
static bool HVP_gpioCpFaultOut = false; //Change to bool
static bool HVP_gpioPyroPor = false; //Change to bool
static bool HVP_gpioShuntEn = false; //Change to bool
static bool HVP_gpioHvpVerEn = false; //Change to bool
static bool HVP_gpioPackCoontPosFlywheel = false; //Change to bool
static bool HVP_gpioCpLatchEnable = false; //Change to bool
static bool HVP_gpioPcsEnable = false; //Change to bool
static bool HVP_gpioPcsDcdcPwmEnable = false; //Change to bool
static bool HVP_gpioPcsChargePwmEnable = false; //Change to bool
static bool HVP_gpioFcContPowerEnable = false; //Change to bool
static bool HVP_gpioHvilEnable = false; //Change to bool
static bool HVP_gpioSecDrdy = false; //Change to bool
static bool HVP_gpioPassivePyroDepl = false; //Change to bool
static bool HVP_gpioPyroIsoEn = false; //Change to bool
static bool HVP_gpioCpFaultIn = false; //Change to bool
static bool HVP_gpioPackContPowerEn = false; //Change to bool
static bool HVP_gpioHvCablesOk = false; //Change to bool
static bool HVP_gpioHvpSelfEnable = false; //Change to bool
static bool HVP_gpioLed = false; //Change to bool
static bool HVP_gpioCrashSignal = false; //Change to bool
static bool HVP_gpioShuntDataReady = false; //Change to bool
static bool HVP_gpioFcContPosAux = false; //Change to bool
static bool HVP_gpioFcContNegAux = false; //Change to bool
static bool HVP_gpioBmsEout = false; //Change to bool
static bool HVP_gpioCpFaultOut = false; //Change to bool
static bool HVP_gpioPyroPor = false; //Change to bool
static bool HVP_gpioShuntEn = false; //Change to bool
static bool HVP_gpioHvpVerEn = false; //Change to bool
static bool HVP_gpioPackCoontPosFlywheel = false; //Change to bool
static bool HVP_gpioCpLatchEnable = false; //Change to bool
static bool HVP_gpioPcsEnable = false; //Change to bool
static bool HVP_gpioPcsDcdcPwmEnable = false; //Change to bool
static bool HVP_gpioPcsChargePwmEnable = false; //Change to bool
static bool HVP_gpioFcContPowerEnable = false; //Change to bool
static bool HVP_gpioHvilEnable = false; //Change to bool
static bool HVP_gpioSecDrdy = false; //Change to bool
static uint16_t HVP_hvp1v5Ref = 0;
static int16_t HVP_shuntCurrentDebug = 0;
static bool HVP_packCurrentMia = false; //Change to bool
static bool HVP_auxCurrentMia = false; //Change to bool
static bool HVP_currentSenseMia =false; //Change to bool
static bool HVP_shuntRefVoltageMismatch = false; //Change to bool
static bool HVP_shuntThermistorMia = false; //Change to bool
static bool HVP_shuntHwMia = false; //Change to bool
static bool HVP_packCurrentMia = false; //Change to bool
static bool HVP_auxCurrentMia = false; //Change to bool
static bool HVP_currentSenseMia = false; //Change to bool
static bool HVP_shuntRefVoltageMismatch = false; //Change to bool
static bool HVP_shuntThermistorMia = false; //Change to bool
static bool HVP_shuntHwMia = false; //Change to bool
static int16_t HVP_dcLinkVoltage = 0;
static int16_t HVP_packVoltage = 0;
static int16_t HVP_fcLinkVoltage = 0;
@ -258,14 +258,19 @@ static bool battery_PowerLossReset = false; //Warns if the processor has experi
static bool battery_SwAssertion = false; //An internal software assertion has failed.
static bool battery_CrashEvent = false; //Warns if the crash signal is detected by HVP
static bool battery_OverDchgCurrentFault = false; //Warns if the pack discharge is above max discharge current limit
static bool battery_OverChargeCurrentFault = false; //Warns if the pack discharge current is above max charge current limit
static bool battery_OverCurrentFault = false; //Warns if the pack current (discharge or charge) is above max current limit.
static bool battery_OverChargeCurrentFault =
false; //Warns if the pack discharge current is above max charge current limit
static bool battery_OverCurrentFault =
false; //Warns if the pack current (discharge or charge) is above max current limit.
static bool battery_OverTemperatureFault = false; //A pack module temperature is above maximum temperature limit
static bool battery_OverVoltageFault = false; //A brick voltage is above maximum voltage limit
static bool battery_UnderVoltageFault = false; //A brick voltage is below minimum voltage limit
static bool battery_PrimaryBmbMiaFault = false; //Warns if the voltage and temperature readings from primary BMB chain are mia
static bool battery_SecondaryBmbMiaFault = false; //Warns if the voltage and temperature readings from secondary BMB chain are mia
static bool battery_BmbMismatchFault = false; //Warns if the primary and secondary BMB chain readings don't match with each other
static bool battery_PrimaryBmbMiaFault =
false; //Warns if the voltage and temperature readings from primary BMB chain are mia
static bool battery_SecondaryBmbMiaFault =
false; //Warns if the voltage and temperature readings from secondary BMB chain are mia
static bool battery_BmbMismatchFault =
false; //Warns if the primary and secondary BMB chain readings don't match with each other
static bool battery_BmsHviMiaFault = false; //Warns if the BMS node is mia on HVS or HVI CAN
static bool battery_CpMiaFault = false; //Warns if the CP node is mia on HVS CAN
static bool battery_PcsMiaFault = false; //The PCS node is mia on HVS CAN
@ -276,11 +281,13 @@ static bool battery_ShuntHwMiaFault = false; //Warns if the shunt current readi
static bool battery_PyroMiaFault = false; //Warns if the pyro squib is not connected
static bool battery_hvsMiaFault = false; //Warns if the pack contactor hw fault
static bool battery_hviMiaFault = false; //Warns if the FC contactor hw fault
static bool battery_Supply12vFault = false; //Warns if the low voltage (12V) battery is below minimum voltage threshold
static bool battery_VerSupplyFault = false; //Warns if the Energy reserve voltage supply is below minimum voltage threshold
static bool battery_Supply12vFault = false; //Warns if the low voltage (12V) battery is below minimum voltage threshold
static bool battery_VerSupplyFault =
false; //Warns if the Energy reserve voltage supply is below minimum voltage threshold
static bool battery_HvilFault = false; //Warn if a High Voltage Inter Lock fault is detected
static bool battery_BmsHvsMiaFault = false; //Warns if the BMS node is mia on HVS or HVI CAN
static bool battery_PackVoltMismatchFault = false; //Warns if the pack voltage doesn't match approximately with sum of brick voltages
static bool battery_PackVoltMismatchFault =
false; //Warns if the pack voltage doesn't match approximately with sum of brick voltages
static bool battery_EnsMiaFault = false; //Warns if the ENS line is not connected to HVC
static bool battery_PackPosCtrArcFault = false; //Warns if the HVP detectes series arc at pack contactor
static bool battery_packNegCtrArcFault = false; //Warns if the HVP detectes series arc at FC contactor
@ -305,7 +312,7 @@ static bool battery_packCtrCloseFailed = false;
static bool battery_fcCtrCloseFailed = false;
static bool battery_shuntThermistorMia = false;
//0x320: 800 BMS_alertMatrix
static uint8_t battery_BMS_matrixIndex = 0; // Changed to bool
static uint8_t battery_BMS_matrixIndex = 0; // Changed to bool
static bool battery_BMS_a061_robinBrickOverVoltage = false;
static bool battery_BMS_a062_SW_BrickV_Imbalance = false;
static bool battery_BMS_a063_SW_ChargePort_Fault = false;