123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- #include "BCU.h"
- static process_Bcu gProcess_Bcu_Task;
- #define PROC_BCU_STATE_SWITCH(a) (gProcess_Bcu_Task = a)
- //=========================================================================
- //=========================================================================
- //=========================================================================
- void BCU(void)
- {
- uint16_T i;
- uint16_T RecvCounter = 0;
- static boolean_T Flg;
- //启动延迟没做
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
- while (TRUE)
- {
- switch (gProcess_Bcu_Task)
- {
- //=========================初始化===============================
- case PROCESS_STATE_INIT:
- {
- BCU_Init();
- Flg = 1;
- // cmnc_num_cellUNum = AppDataInfo.BattCellCount; /* 电压采样点实际个数; */
- // cmnc_num_modTNum = AppDataInfo.BattTempCount; /* 温度采样点实际个数; */
- // ihd_st_EOLState = AppNVMData.EOLState;
- // 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_remainCpE, sizeof(iscv_Q_remainCpEi));
- // memcpy(sorv_R_cellEi, BcuDataInfo.sorv_ohm_cellRE, sizeof(sorv_R_cell));
- // iscd_tm_totalEi = BcuDataInfo.iscd_tm_totalE;
- // 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_iscFltE;
- // ihd_tm_parkTime = BcuDataInfo.ihd_tm_parkTimeE;
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_WORK);
- break;
- }
- //============================工作模式==========================
- case PROCESS_STATE_WORK:
- {
- //数据得到之后再运行没做
- while (TRUE)
- {
- if (TimerCounter % 10 == 0)
- {
- // if (gProcess_app == LISTEN)
- // {
- // PROC_BCU_STATE_SWITCH(PROCESS_STATE_SLEEP);
- // break;
- // }
- //数据获取
- // ihd_st_reSet = SysResetFlag;
- // 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 = (getbit(battProtectState, 8)) == 1;
- // ihd_flg_battULowFlt = (getbit(battProtectState, 9)) == 1;
- // ihd_flg_cellUOverFlt = (getbit(battProtectState, 24)) == 1;
- // ihd_flg_battUOverFlt = (getbit(battProtectState, 25)) == 1;
- // ihd_flg_disChrgCurrOverFlt = (getbit(battProtectState, 1)) == 1;
- // ihd_flg_chrgCurrOverFlt = (getbit(battProtectState, 2)) == 1;
- // ihd_flg_disChrgModTOverFlt = (getbit(battProtectState, 20)) == 1;
- // ihd_flg_chrgModTOverFlt = (getbit(battProtectState, 16)) == 1;
- // ihd_flg_chrgMosTOverFlt = (getbit(battProtectState, 18)) == 1;
- // ihd_flg_disChrgMosClosFlt = ((battWarningState >> 18) & 0x01) == 1;
- // ihd_flg_chrgMosClosFlt = ((battWarningState >> 19) & 0x01) == 1;
- // ihd_flg_disChrgModTLowFlt = (getbit(battProtectState, 21)) == 1;
- // ihd_flg_chrgModTLowFlt = (getbit(battProtectState, 17)) == 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_st_heatStat = battHeatEnableState;
- //调用算法
- SFM();
- TMS();
- CSM();
- SPM();
- ISC();
- //实时存储
- if (socd_flg_EEsave == 1 || ihd_flg_DTCClear)
- {
- BCUEEDataSave();
- ihd_flg_DTCClear = false;
- }
- if (ihd_st_workStat == 0)
- {
- memcpy(appv_V_cellU, sfmv_V_cellU, sizeof(sfmv_V_cellU));
- }
-
- if(Flg == 1 && ihd_st_workStat != 0)
- {
- AppConfigInfo.BcuDataInfo.ihd_tm_parkTimeE = 0;
- AppConfigInfo.appSaveFlg = TRUE;
- Flg = 0;
- }
- if (ihd_st_wakeUpStat == 8)
- {
- if(bcud_flg_firstRun)
- {
- appd_st_preCyc = 1;
- }
- if(ihd_st_workStat != 0)
- {
- appd_st_preCyc = 0;
- }
- }
- bcud_flg_firstRun = false;
- }
- vTaskDelay(100);
- }
- break;
- }
- //======================休眠模式===============================
- // case PROCESS_STATE_SLEEP:
- // {
- // BCUEEDataSave();
- // ihd_tm_parkTime = 0;
- // while (TRUE)
- // {
- // if (TimerCounter % 10 == 0)
- // {
- // ihd_tm_parkTime++;
- // }
- // if (TimeCounter % 1000 == 0)
- // {
- // BcuDataInfo.ihd_tm_parkTimeE = ihd_tm_parkTime;
- // BcuDataInfo.appDataModify = TRUE;
- // }
- // if (gProcess_app == WORK)
- // {
- // BcuDataInfo.ihd_tm_parkTimeE = ihd_tm_parkTime;
- // BcuDataInfo.appDataModify = TRUE;
- // PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
- // break;
- // }
- // vTaskDelay(100);
- // }
- // break;
- // }
- default:
- {
- PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
- break;
- }
- }
- }
- }
- //========================算法初始化========================================
- void BCU_Init(void)
- {
- bcud_flg_firstRun = true;
- SFM_Init();
- TMS_Init();
- CSM_Init();
- SPM_Init();
- ISC_Init();
- }
- //==========================主线程调用======================================
- void AppTaskBcuInit(void *arg)
- {
- }
- //=========================数据存储========================================
- void BCUEEDataSave(void)
- {
- memcpy(AppConfigInfo.BcuDataInfo.blcv_Q_totalCpE, blcv_Q_totalCpEo, sizeof(blcv_Q_totalCpEo));
- memcpy(AppConfigInfo.BcuDataInfo.blcv_Q_reqCpE, blcv_Q_reqCpEo, sizeof(blcv_Q_reqCpEo));
- AppConfigInfo.BcuDataInfo.socd_pct_bcuSocE = socd_pct_bcuSocEo;
- AppConfigInfo.BcuDataInfo.socd_pct_battSocE = socd_pct_battSocEo;
- AppConfigInfo.BcuDataInfo.sohd_tm_chrgStartStatE = sohd_tm_chrgStartStatEo;
- AppConfigInfo.BcuDataInfo.sohd_flg_chrgEndE = sohd_flg_chrgEndEo;
- memcpy(AppConfigInfo.BcuDataInfo.sohv_V_chrgStartStatE, sohv_V_chrgStartStatEo, sizeof(sohv_V_chrgStartStatEo));
- AppConfigInfo.BcuDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
- memcpy(AppConfigInfo.BcuDataInfo.sohv_Q_packCapArrE, sohv_Q_packCapArrEo, sizeof(sohv_Q_packCapArrEo));
- memcpy(AppConfigInfo.BcuDataInfo.sohv_Q_cellCapArrE, sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
- memcpy(AppConfigInfo.BcuDataInfo.iscv_Q_remainCpE, iscv_Q_remainCpEo, sizeof(iscv_Q_remainCpEo));
- memcpy(AppConfigInfo.BcuDataInfo.sorv_ohm_cellRE, sorv_R_cellEo, sizeof(sorv_R_cellEo));
- AppConfigInfo.BcuDataInfo.iscd_tm_totalE = iscd_tm_totalEo;
- AppConfigInfo.BcuDataInfo.sfmd_flg_mainCirClosFltE = sfmd_flg_mainCirClosFltEo;
- AppConfigInfo.BcuDataInfo.sfmd_flg_heatCirClosFltE = sfmd_flg_heatCirClosFltEo;
- AppConfigInfo.BcuDataInfo.sfmd_flg_heatCirOpenFltE = sfmd_flg_heatCirOpenFltEo;
- AppConfigInfo.BcuDataInfo.sfmd_flg_heatRunFltE = sfmd_flg_heatRunFltEo;
- AppConfigInfo.BcuDataInfo.sfmd_flg_iscFltE = sfmd_flg_iscFltEo;
- AppConfigInfo.appSaveFlg = TRUE;
- }
|