|
@@ -17,8 +17,8 @@ void BCU(void)
|
|
while (TRUE)
|
|
while (TRUE)
|
|
{
|
|
{
|
|
if (UartRecvFlag == 1 || RecvCounter >= 15)
|
|
if (UartRecvFlag == 1 || RecvCounter >= 15)
|
|
- {
|
|
|
|
- //osDelay(1000);
|
|
|
|
|
|
+ {
|
|
|
|
+ RecvCounter = 0;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -26,133 +26,166 @@ void BCU(void)
|
|
RecvCounter++;
|
|
RecvCounter++;
|
|
osDelay(1000);
|
|
osDelay(1000);
|
|
}
|
|
}
|
|
- //printf("RecvCounter:%d\n ",RecvCounter);
|
|
|
|
|
|
+ //printf("RecvCounter:%d\n ",RecvCounter);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
|
|
PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
|
|
while (TRUE)
|
|
while (TRUE)
|
|
{
|
|
{
|
|
switch (gProcess_Bcu_Task)
|
|
switch (gProcess_Bcu_Task)
|
|
{
|
|
{
|
|
- //=========================初始化===============================
|
|
|
|
- case PROCESS_STATE_INIT:
|
|
|
|
- {
|
|
|
|
- BCU_Init();
|
|
|
|
- memcpy(blcv_Q_totalCpEi, BcuDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
|
|
|
|
- memcpy(blcv_Q_reqCpEi, BcuDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
|
|
|
|
- socd_pct_bcuSocEi = BcuDataInfo.socd_pct_bcuSocE;
|
|
|
|
- socd_pct_battSocEi = BcuDataInfo.socd_pct_battSocE;
|
|
|
|
- sohd_tm_chrgStartStatEi = BcuDataInfo.sohd_tm_chrgStartStatE;
|
|
|
|
- sohd_flg_chrgEndEi = BcuDataInfo.sohd_flg_chrgEndE;
|
|
|
|
- memcpy(sohv_V_chrgStartStatEi, BcuDataInfo.sohv_V_chrgStartStatE, sizeof(sohv_V_chrgStartStatEi));
|
|
|
|
- sohd_Q_chrgEi = BcuDataInfo.sohd_Q_chrgE;
|
|
|
|
- memcpy(sohv_Q_packCapArrEi, BcuDataInfo.sohv_Q_packCapArrE, sizeof(sohv_Q_packCapArrEi));
|
|
|
|
- memcpy(sohv_Q_cellCapArrEi, BcuDataInfo.sohv_Q_cellCapArrE, sizeof(sohv_Q_cellCapArrEi));
|
|
|
|
- sfmd_flg_mainCirClosFltEi = BcuDataInfo.sfmd_flg_mainCirClosFltE;
|
|
|
|
- sfmd_flg_heatCirClosFltEi = BcuDataInfo.sfmd_flg_heatCirClosFltE;
|
|
|
|
- sfmd_flg_heatCirOpenFltEi = BcuDataInfo.sfmd_flg_heatCirOpenFltE;
|
|
|
|
- sfmd_flg_heatRunFltEi = BcuDataInfo.sfmd_flg_heatRunFltE;
|
|
|
|
- ihd_st_EOLState = AppNVMData.EOLState;
|
|
|
|
-
|
|
|
|
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- //============================工作模式==========================
|
|
|
|
- case PROCESS_STATE_WORK:
|
|
|
|
- {
|
|
|
|
- while (TRUE)
|
|
|
|
|
|
+ //=========================初始化===============================
|
|
|
|
+ case PROCESS_STATE_INIT:
|
|
{
|
|
{
|
|
- if (TimeCounter % 10 == 0)
|
|
|
|
- {
|
|
|
|
- if (gProcess_app == LISTEN)
|
|
|
|
- {
|
|
|
|
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- //数据获取
|
|
|
|
- if (BattWorkStateDelay == 0 && battI == 10000)
|
|
|
|
|
|
+ BCU_Init();
|
|
|
|
+ memcpy(blcv_Q_totalCpEi, BcuDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
|
|
|
|
+ memcpy(blcv_Q_reqCpEi, BcuDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
|
|
|
|
+ socd_pct_bcuSocEi = BcuDataInfo.socd_pct_bcuSocE;
|
|
|
|
+ socd_pct_battSocEi = BcuDataInfo.socd_pct_battSocE;
|
|
|
|
+ sohd_tm_chrgStartStatEi = BcuDataInfo.sohd_tm_chrgStartStatE;
|
|
|
|
+ sohd_flg_chrgEndEi = BcuDataInfo.sohd_flg_chrgEndE;
|
|
|
|
+ memcpy(sohv_V_chrgStartStatEi, BcuDataInfo.sohv_V_chrgStartStatE, sizeof(sohv_V_chrgStartStatEi));
|
|
|
|
+ sohd_Q_chrgEi = BcuDataInfo.sohd_Q_chrgE;
|
|
|
|
+ memcpy(sohv_Q_packCapArrEi, BcuDataInfo.sohv_Q_packCapArrE, sizeof(sohv_Q_packCapArrEi));
|
|
|
|
+ memcpy(sohv_Q_cellCapArrEi, BcuDataInfo.sohv_Q_cellCapArrE, sizeof(sohv_Q_cellCapArrEi));
|
|
|
|
+ memcpy((iscv_Q_remainCpEi), BcuDataInfo.iscv_Q_remainCpEE, sizeof(iscv_Q_remainCpEi));
|
|
|
|
+ iscd_tm_totalEi = BcuDataInfo.iscd_tm_totalEE;
|
|
|
|
+ sfmd_flg_mainCirClosFltEi = BcuDataInfo.sfmd_flg_mainCirClosFltE;
|
|
|
|
+ sfmd_flg_heatCirClosFltEi = BcuDataInfo.sfmd_flg_heatCirClosFltE;
|
|
|
|
+ sfmd_flg_heatCirOpenFltEi = BcuDataInfo.sfmd_flg_heatCirOpenFltE;
|
|
|
|
+ sfmd_flg_heatRunFltEi = BcuDataInfo.sfmd_flg_heatRunFltE;
|
|
|
|
+ sfmd_flg_iscFltEi = BcuDataInfo.sfmd_flg_iscFltEE;
|
|
|
|
+ ihd_st_EOLState = AppNVMData.EOLState;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ PROC_BCU_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //============================工作模式==========================
|
|
|
|
+ case PROCESS_STATE_WORK:
|
|
|
|
+ {
|
|
|
|
+ while (TRUE)
|
|
|
|
+ {
|
|
|
|
+ if (UartRecvFlag == 1 || RecvCounter >= 15)
|
|
|
|
+ {
|
|
|
|
+ RecvCounter = 0;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ RecvCounter++;
|
|
|
|
+ osDelay(1000);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while (TRUE)
|
|
|
|
+ {
|
|
|
|
+ if (TimeCounter % 10 == 0)
|
|
{
|
|
{
|
|
- memcpy(appv_V_cellU, battCellU, sizeof(appv_V_cellU));
|
|
|
|
|
|
+ if (gProcess_app == LISTEN)
|
|
|
|
+ {
|
|
|
|
+ PROC_BCU_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ //数据获取
|
|
|
|
+ ihd_I_curr = (int16_T)(-(battI - 10000));
|
|
|
|
+ memcpy(ihv_V_cellU, battCellU, sizeof(battCellU));
|
|
|
|
+ for (i = 0; i < cmnc_num_modTNum; i++)
|
|
|
|
+ {
|
|
|
|
+ ihv_T_modT[i] = battCellTemp[i];
|
|
|
|
+ }
|
|
|
|
+ ihd_T_mosT = MOSTemp;
|
|
|
|
+ ihd_T_DCPlugT = fastChargeTemp;
|
|
|
|
+ ihd_T_ACPlugT = normalChargeTemp;
|
|
|
|
+ ihd_T_heatPanT1 = heatTemp1;
|
|
|
|
+ ihd_T_heatPanT2 = heatTemp2;
|
|
|
|
+ ihd_pct_soc = battSOC * 10;
|
|
|
|
+ ihd_pct_soh = battSOH * 10;
|
|
|
|
+ ihd_flg_HVILFlt = Lockstatus;
|
|
|
|
+ ihd_st_workStat = BattWorkStateDelay;
|
|
|
|
+ ihd_flg_urtRecFlt = UartErrorFlag;
|
|
|
|
+ ihd_flg_urtRecFlg = UartRecvFlag;
|
|
|
|
+ ihd_st_chrgConnect = chargerConnectState;
|
|
|
|
+ ihd_flg_cellULowFlt = ((battWarningState)&0x01) == 1;
|
|
|
|
+ ihd_flg_battULowFlt = ((battWarningState >> 1) & 0x01) == 1;
|
|
|
|
+ ihd_flg_cellUOverFlt = ((battWarningState >> 2) & 0x01) == 1;
|
|
|
|
+ ihd_flg_battUOverFlt = ((battWarningState >> 3) & 0x01) == 1;
|
|
|
|
+ ihd_flg_disChrgCurrOverFlt = ((battWarningState >> 4) & 0x01) == 1;
|
|
|
|
+ ihd_flg_chrgCurrOverFlt = ((battWarningState >> 5) & 0x01) == 1;
|
|
|
|
+ ihd_flg_disChrgModTOverFlt = ((battWarningState >> 6) & 0x01) == 1;
|
|
|
|
+ ihd_flg_chrgModTOverFlt = ((battWarningState >> 7) & 0x01) == 1;
|
|
|
|
+ ihd_flg_chrgMosTOverFlt = ((battWarningState >> 11) & 0x01) == 1;
|
|
|
|
+ ihd_flg_disChrgMosClosFlt = ((battWarningState >> 18) & 0x01) == 1;
|
|
|
|
+ ihd_flg_chrgMosClosFlt = ((battWarningState >> 19) & 0x01) == 1;
|
|
|
|
+ ihd_flg_disChrgModTLowFlt = ((battWarningState >> 22) & 0x01) == 1;
|
|
|
|
+ ihd_flg_chrgModTLowFlt = ((battWarningState >> 23) & 0x01) == 1;
|
|
|
|
+ ihd_flg_currOpenFlt = 0;
|
|
|
|
+ ihd_st_heatForceControl = HeatForceControl;
|
|
|
|
+ ihd_st_chrgMosControl = ChargeForbiddenControl == 0;
|
|
|
|
+ ihd_st_disChrgMosControl = DisChargeForbiddenControl == 0;
|
|
|
|
+ ihd_st_relayControl = RelayForbiddenControl == 0;
|
|
|
|
+ //ihd_flg_DTCClear = 1; //////clear
|
|
|
|
+ //调用算法
|
|
|
|
+ SFM();
|
|
|
|
+ TMS();
|
|
|
|
+ CM();
|
|
|
|
+ SPM();
|
|
|
|
+ ISC();
|
|
|
|
+ //实时存储
|
|
|
|
+ if (socd_flg_EEsave == 1 || ihd_flg_DTCClear)
|
|
|
|
+ {
|
|
|
|
+ BCUEEDataSave();
|
|
|
|
+ ihd_flg_DTCClear = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ if (BattWorkStateDelay == 0 && battI == 10000)
|
|
|
|
+ {
|
|
|
|
+ memcpy(appv_V_cellU, battCellU, sizeof(appv_V_cellU));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ihd_tm_parkTime >= cmnc_tm_parkTime && battI == 10000)
|
|
|
|
+ {
|
|
|
|
+ appd_st_preCyc = 1 ;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ appd_st_preCyc = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
- ihd_I_curr = (int16_T)(-(battI - 10000));
|
|
|
|
- memcpy(ihv_V_cellU, battCellU, sizeof(battCellU));
|
|
|
|
- for (i = 0; i < cmnc_num_modTNum; i++)
|
|
|
|
|
|
+ osDelay(100);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //======================休眠模式===============================
|
|
|
|
+ case PROCESS_STATE_SLEEP:
|
|
|
|
+ {
|
|
|
|
+ BCUEEDataSave();
|
|
|
|
+ ihd_tm_parkTime = 0;
|
|
|
|
+ while (TRUE)
|
|
|
|
+ {
|
|
|
|
+ if (TimeCounter % 10 == 0)
|
|
{
|
|
{
|
|
- ihv_T_modT[i] = battCellTemp[i];
|
|
|
|
|
|
+ ihd_tm_parkTime++;
|
|
|
|
+
|
|
}
|
|
}
|
|
- ihd_T_mosT = MOSTemp;
|
|
|
|
- ihd_T_DCPlugT = fastChargeTemp;
|
|
|
|
- ihd_T_ACPlugT = normalChargeTemp;
|
|
|
|
- ihd_T_heatPanT1 = heatTemp1;
|
|
|
|
- ihd_T_heatPanT2 = heatTemp2;
|
|
|
|
- ihd_pct_soc = battSOC * 10;
|
|
|
|
- ihd_pct_soh = battSOH * 10;
|
|
|
|
- ihd_flg_HVILFlt = Lockstatus;
|
|
|
|
- ihd_st_workStat = BattWorkStateDelay;
|
|
|
|
- ihd_flg_urtRecFlt = UartErrorFlag;
|
|
|
|
- ihd_flg_urtRecFlg = UartRecvFlag;
|
|
|
|
- ihd_st_chrgConnect = chargerConnectState;
|
|
|
|
- ihd_flg_cellULowFlt = ((battWarningState)&0x01) == 1;
|
|
|
|
- ihd_flg_battULowFlt = ((battWarningState >> 1) & 0x01) == 1;
|
|
|
|
- ihd_flg_cellUOverFlt = ((battWarningState >> 2) & 0x01) == 1;
|
|
|
|
- ihd_flg_battUOverFlt = ((battWarningState >> 3) & 0x01) == 1;
|
|
|
|
- ihd_flg_disChrgCurrOverFlt = ((battWarningState >> 4) & 0x01) == 1;
|
|
|
|
- ihd_flg_chrgCurrOverFlt = ((battWarningState >> 5) & 0x01) == 1;
|
|
|
|
- ihd_flg_disChrgModTOverFlt = ((battWarningState >> 6) & 0x01) == 1;
|
|
|
|
- ihd_flg_chrgModTOverFlt = ((battWarningState >> 7) & 0x01) == 1;
|
|
|
|
- ihd_flg_chrgMosTOverFlt = ((battWarningState >> 11) & 0x01) == 1;
|
|
|
|
- ihd_flg_disChrgMosClosFlt = ((battWarningState >> 18) & 0x01) == 1;
|
|
|
|
- ihd_flg_chrgMosClosFlt = ((battWarningState >> 19) & 0x01) == 1;
|
|
|
|
- ihd_flg_disChrgModTLowFlt = ((battWarningState >> 22) & 0x01) == 1;
|
|
|
|
- ihd_flg_chrgModTLowFlt = ((battWarningState >> 23) & 0x01) == 1;
|
|
|
|
- ihd_flg_currOpenFlt = 0;
|
|
|
|
- ihd_st_heatForceControl = HeatForceControl;
|
|
|
|
- ihd_st_chrgMosControl = ChargeForbiddenControl == 0;
|
|
|
|
- ihd_st_disChrgMosControl = DisChargeForbiddenControl == 0;
|
|
|
|
- ihd_st_relayControl = RelayForbiddenControl == 0;
|
|
|
|
- //ihd_flg_DTCClear = ihd_flg_disChrgMosClosFlt;
|
|
|
|
-
|
|
|
|
- //调用算法
|
|
|
|
- SFM();
|
|
|
|
- TMS();
|
|
|
|
- CM();
|
|
|
|
- SPM();
|
|
|
|
- //实时存储
|
|
|
|
- if (socd_flg_EEsave == 1 || ihd_flg_DTCClear)
|
|
|
|
|
|
+ if (gProcess_app == WORK)
|
|
{
|
|
{
|
|
- BCUEEDataSave();
|
|
|
|
- ihd_flg_DTCClear = false;
|
|
|
|
|
|
+ PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+ osDelay(100);
|
|
}
|
|
}
|
|
- osDelay(100);
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- }
|
|
|
|
- //======================休眠模式===============================
|
|
|
|
- case PROCESS_STATE_SLEEP:
|
|
|
|
- {
|
|
|
|
- BCUEEDataSave();
|
|
|
|
- ihd_tm_parkTime = 0;
|
|
|
|
- while (TRUE)
|
|
|
|
|
|
+ default:
|
|
{
|
|
{
|
|
- if (TimeCounter % 10 == 0)
|
|
|
|
- {
|
|
|
|
- ihd_tm_parkTime++;
|
|
|
|
- }
|
|
|
|
- if (gProcess_app == WORK)
|
|
|
|
- {
|
|
|
|
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- osDelay(100);
|
|
|
|
|
|
+ PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- }
|
|
|
|
- default:
|
|
|
|
- {
|
|
|
|
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -164,6 +197,7 @@ void BCU_Init(void)
|
|
TMS_Init();
|
|
TMS_Init();
|
|
CM_Init();
|
|
CM_Init();
|
|
SPM_Init();
|
|
SPM_Init();
|
|
|
|
+ ISC_Init();
|
|
}
|
|
}
|
|
|
|
|
|
//==========================主线程调用======================================
|
|
//==========================主线程调用======================================
|
|
@@ -193,9 +227,12 @@ void BCUEEDataSave(void)
|
|
BcuDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
|
|
BcuDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
|
|
memcpy(BcuDataInfo.sohv_Q_packCapArrE, sohv_Q_packCapArrEo, sizeof(sohv_Q_packCapArrEo));
|
|
memcpy(BcuDataInfo.sohv_Q_packCapArrE, sohv_Q_packCapArrEo, sizeof(sohv_Q_packCapArrEo));
|
|
memcpy(BcuDataInfo.sohv_Q_cellCapArrE, sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
|
|
memcpy(BcuDataInfo.sohv_Q_cellCapArrE, sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
|
|
|
|
+ memcpy(BcuDataInfo.iscv_Q_remainCpEE, iscv_Q_remainCpEo, sizeof(iscv_Q_remainCpEo));
|
|
|
|
+ BcuDataInfo.iscd_tm_totalEE = iscd_tm_totalEo;
|
|
BcuDataInfo.sfmd_flg_mainCirClosFltE = sfmd_flg_mainCirClosFltEo;
|
|
BcuDataInfo.sfmd_flg_mainCirClosFltE = sfmd_flg_mainCirClosFltEo;
|
|
BcuDataInfo.sfmd_flg_heatCirClosFltE = sfmd_flg_heatCirClosFltEo;
|
|
BcuDataInfo.sfmd_flg_heatCirClosFltE = sfmd_flg_heatCirClosFltEo;
|
|
BcuDataInfo.sfmd_flg_heatCirOpenFltE = sfmd_flg_heatCirOpenFltEo;
|
|
BcuDataInfo.sfmd_flg_heatCirOpenFltE = sfmd_flg_heatCirOpenFltEo;
|
|
BcuDataInfo.sfmd_flg_heatRunFltE = sfmd_flg_heatRunFltEo;
|
|
BcuDataInfo.sfmd_flg_heatRunFltE = sfmd_flg_heatRunFltEo;
|
|
|
|
+ BcuDataInfo.sfmd_flg_iscFltEE = sfmd_flg_iscFltEo;
|
|
BcuDataInfo.appDataModify = TRUE;
|
|
BcuDataInfo.appDataModify = TRUE;
|
|
}
|
|
}
|