2024-01-30 03:31:27 +00:00
|
|
|
|
#include "can.h"
|
|
|
|
|
#include "REV_CarMessage.h"
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "CDZ_DATA.h"
|
|
|
|
|
#include "Err_Info_Process.h"
|
|
|
|
|
#include "Err_code.h"
|
|
|
|
|
#define DEBUG_BMS 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG_BMS > 0
|
|
|
|
|
#define BMS_PRINT DEPRINT
|
|
|
|
|
#define BMS_PRINT_ARRAY DEPRINT_ARRAY
|
|
|
|
|
#else
|
|
|
|
|
#define BMS_PRINT
|
|
|
|
|
#define BMS_PRINT_ARRAY
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern uint8_t stopChargeReason;
|
|
|
|
|
extern int8_t can_write( CanTxMsg *TxMessage);
|
|
|
|
|
extern int8_t can_write2( CanTxMsg *TxMessage);
|
|
|
|
|
|
|
|
|
|
// SOC
|
|
|
|
|
uint8_t Bms_BatChargeRealObdBatCurSOC = 0 ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
void bms_SendBHM(uint16_t MaxVoltage);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><>ʶ
|
|
|
|
|
void bms_SendBRM(uint16_t step);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
|
|
|
|
void bms_SendBCP(uint16_t step);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ BRO
|
|
|
|
|
//0x0--BMS<4D><53><EFBFBD>ܱ<EFBFBD>ʶ 0xaa--BMS<4D>ܱ<EFBFBD>ʶ
|
|
|
|
|
void bms_SendBRO(uint8_t Ready);
|
|
|
|
|
//<2F><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BCL
|
|
|
|
|
void bms_SendBCL(void);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ BCS
|
|
|
|
|
void bms_SendBCS(uint16_t step);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ״̬ BSM
|
|
|
|
|
void bms_SendBSM(uint16_t step);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><>ֹ<EFBFBD><D6B9><EFBFBD>籨<EFBFBD><E7B1A8> BST
|
|
|
|
|
void bms_SendBST(uint16_t step);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> BMSͳ<53>Ʊ<EFBFBD><C6B1><EFBFBD> BSD
|
|
|
|
|
void bms_SendBSD(uint16_t step);
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> BMS<4D><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BEM
|
|
|
|
|
void bms_SendBEM(uint16_t step);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
record_t ChargeRecordInfo ={0}; //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChargeParam_t CDZ_ChargeInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
|
|
|
|
|
Bms_BatInfo_t Bms_BatInfo;
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD> */
|
|
|
|
|
static CDZ_BAT_CONFIG_PARAM_t Bms_BatConfigParam ;
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>β<D7B6><CEB2><EFBFBD><EFBFBD><EFBFBD>Ϣ*/
|
|
|
|
|
Bms_BatRealInfo_t Bms_BatChargeRealInfo ;
|
|
|
|
|
CanRxMsg BMSCAN1Msg;
|
|
|
|
|
CanTxMsg BMS_CanTxData;
|
|
|
|
|
CanTxMsg BMS_Can2TxData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BmsParaDataInit(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* Function: HEX2BCD
|
|
|
|
|
* Description: ?16??????BCD?
|
|
|
|
|
* Input: hex: ?????16??
|
|
|
|
|
* Return: ?????BCD?
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
u8 HEX2BCD(u8 hex)
|
|
|
|
|
{
|
|
|
|
|
return (((hex / 10) << 4) & 0xf0) | ((hex % 10) & 0xf);
|
|
|
|
|
}
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* Function: BCD2HEX
|
|
|
|
|
* Description: ?BCD????16??
|
|
|
|
|
* Input: bcd: ?????BCD?
|
|
|
|
|
* Return: ?????16????
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
u8 BCD2HEX(u8 bcd)
|
|
|
|
|
{
|
|
|
|
|
return (((bcd >> 4) & 0xf) * 10 + (bcd & 0xf));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===========================<3D><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD> ====================================
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD>
|
|
|
|
|
static int8_t CDZ_ParseCHM(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
if(iLen >3)iLen =3;
|
|
|
|
|
memcpy(CDZ_ChargeInfo.VersionNo,pData,iLen);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE>ʶ
|
|
|
|
|
static int8_t CDZ_ParseCRM(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
if(iLen >8)iLen =8;
|
|
|
|
|
CDZ_ChargeInfo.identify = pData[0];
|
|
|
|
|
CDZ_ChargeInfo.SerialNo[0] = pData[1];
|
|
|
|
|
CDZ_ChargeInfo.SerialNo[1] = pData[2];
|
|
|
|
|
CDZ_ChargeInfo.SerialNo[2] = pData[3];
|
|
|
|
|
CDZ_ChargeInfo.SerialNo[3] = pData[4];
|
|
|
|
|
CDZ_ChargeInfo.RegionalCode[0] = pData[5];
|
|
|
|
|
CDZ_ChargeInfo.RegionalCode[1] = pData[6];
|
|
|
|
|
CDZ_ChargeInfo.RegionalCode[2] = pData[7];
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʱ<D7AE><CAB1>ͬ<EFBFBD><CDAC>
|
|
|
|
|
static int8_t CDZ_ParseCTS(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
if(iLen >8)iLen =8;
|
|
|
|
|
CDZ_ChargeInfo.date[0] =BCD2HEX(pData[0]); // s 29
|
|
|
|
|
CDZ_ChargeInfo.date[1] = BCD2HEX(pData[1]);//min 59
|
|
|
|
|
CDZ_ChargeInfo.date[2] = BCD2HEX(pData[2]);//hour 23
|
|
|
|
|
CDZ_ChargeInfo.date[3] = BCD2HEX(pData[3]);//day 12
|
|
|
|
|
CDZ_ChargeInfo.date[4] = BCD2HEX(pData[4]); //mon 6
|
|
|
|
|
CDZ_ChargeInfo.date[5] = BCD2HEX(pData[5]); //year 19
|
|
|
|
|
CDZ_ChargeInfo.date[6] = BCD2HEX(pData[6]); //year 20
|
|
|
|
|
|
|
|
|
|
memcpy((uint8_t *)&ChargeRecordInfo.date[0],(uint8_t *)&CDZ_ChargeInfo.date[0],7) ;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
static int8_t CDZ_ParseCML(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int16_t data = 0;
|
|
|
|
|
CDZ_ChargeInfo.ChargeOutMaxVoltage =(pData[1] <<8) | pData[0]; // 0.1V
|
|
|
|
|
CDZ_ChargeInfo.ChargeOutMinVoltage =(pData[3] <<8 )| pData[2]; // 0.1V
|
|
|
|
|
data = (pData[5] <<8 | pData[4]);
|
|
|
|
|
data = data > 4000 ? (data - 4000): (4000-data);
|
|
|
|
|
CDZ_ChargeInfo.ChargeOutMaxCurrent =data; // 0.1A
|
|
|
|
|
data = (pData[7] <<8 | pData[6]);
|
|
|
|
|
data = data > 4000 ? (data - 4000): (4000-data);
|
|
|
|
|
CDZ_ChargeInfo.ChargeOutMinCurrent =data; // 0.1 A
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><D7AE><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CRO
|
|
|
|
|
static int8_t CDZ_ParseCRO(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.ready = pData[0]; // 0.1V
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD> CCS
|
|
|
|
|
static int8_t CDZ_ParseCCS(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
int16_t data = 0;
|
|
|
|
|
CDZ_ChargeInfo.ChargeOutVoltage = (pData[1] <<8) + pData[0]; // 0.1V
|
|
|
|
|
data = (pData[3] <<8) + pData[2];
|
|
|
|
|
data = data > 4000 ? (data - 4000): (4000-data);
|
|
|
|
|
CDZ_ChargeInfo.ChargeOutCurrent = data; // 0.1A
|
|
|
|
|
//Bms_BatChargeRealInfo.BatRealVol =CDZ_ChargeInfo.ChargeOutVoltage ;
|
|
|
|
|
if(data >= 10)// <20><><EFBFBD><EFBFBD>1Aʱ
|
|
|
|
|
{
|
|
|
|
|
Bms_BatChargeRealInfo.BatRealCur =CDZ_ChargeInfo.ChargeOutCurrent ;
|
|
|
|
|
//Bms_BatChargeRealInfo.BatRealVol =CDZ_ChargeInfo.ChargeOutVoltage ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Bms_BatChargeRealInfo.BatRealCur = 0 ;
|
|
|
|
|
}
|
|
|
|
|
CDZ_ChargeInfo.ChargeTime = (pData[5] <<8) + pData[4]; // 0.1V
|
|
|
|
|
CDZ_ChargeInfo.ChargeTime = CDZ_ChargeInfo.ChargeTime ;
|
|
|
|
|
CDZ_ChargeInfo.ChargeAllow = pData[6]; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD> CST
|
|
|
|
|
static int8_t CDZ_ParseCST(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
CDZ_ChargeInfo.end.stats[1] = pData[0];
|
|
|
|
|
CDZ_ChargeInfo.end.stats[2] = pData[1];
|
|
|
|
|
CDZ_ChargeInfo.end.stats[3] = pData[2];
|
|
|
|
|
CDZ_ChargeInfo.end.stats[4] = pData[3];
|
|
|
|
|
|
|
|
|
|
// CDZ_ChargeInfo.StopReason = pData[0]; // 0.1V
|
|
|
|
|
// CDZ_ChargeInfo.ChargeEndFaultCode = (pData[2] <<8) + pData[1]; // 0.1V
|
|
|
|
|
// CDZ_ChargeInfo.ChargeEndErrCode = pData[3]; //
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD>α<D7B6><CEB1><EFBFBD> CSD
|
|
|
|
|
static int8_t CDZ_ParseCSD(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// CSD <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>
|
|
|
|
|
// CDZ_ChargeInfo.ChargeTimeTotal = (pData[1]<<8)+ pData[0]; // 0.1V
|
|
|
|
|
//CDZ_ChargeInfo.ChargeEnergyTotal = (pData[3] <<8) + pData[2]; // 0.1V
|
|
|
|
|
CDZ_ChargeInfo.SerialNumber[0] = pData[4];
|
|
|
|
|
CDZ_ChargeInfo.SerialNumber[1] = pData[5];
|
|
|
|
|
CDZ_ChargeInfo.SerialNumber[2] = pData[6];
|
|
|
|
|
CDZ_ChargeInfo.SerialNumber[3] = pData[7];
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CEM
|
|
|
|
|
static int8_t CDZ_ParseCEM(const uint8_t *pData, int32_t iLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
// CDZ_ChargeInfo.BmsRcvCode = (pData[3] <<24) + (pData[2]<<16)+ (pData[1]<<8)+ pData[0]; // 0.1V
|
|
|
|
|
|
|
|
|
|
CDZ_ChargeInfo.end.stats[5] = pData[0];
|
|
|
|
|
CDZ_ChargeInfo.end.stats[6] = pData[1];
|
|
|
|
|
CDZ_ChargeInfo.end.stats[7] = pData[2];
|
|
|
|
|
CDZ_ChargeInfo.end.stats[8] = pData[3];
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>bms_check_status
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD>false <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
int8_t bms_check_status(void)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>wulingbms_check_status
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD>鳵<EFBFBD><EFBFBD>bms<EFBFBD>Ƿ<EFBFBD><EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD>false <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
int8_t wulingbms_check_status(void)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CanRxMsg testBMSCAN1Msg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>wulingbms_check_status
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD>鳵<EFBFBD><EFBFBD>bms<EFBFBD>Ƿ<EFBFBD><EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD>false <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
static void bms_parseData(int32_t objId, uint8_t *cCanData, int32_t can_DataLen, int8_t Ch)
|
|
|
|
|
{
|
|
|
|
|
int8_t bParseResult = 0;
|
|
|
|
|
|
|
|
|
|
// BMS_PRINT("\n\r<>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>can <20><><EFBFBD><EFBFBD>[%d]:",Ch);
|
|
|
|
|
// BMS_PRINT("%x \n",objId);
|
|
|
|
|
// BMS_PRINT_ARRAY(cCanData,can_DataLen);
|
|
|
|
|
//CDZ_ChargeInfo.BmsRcvTimeCount = 0;
|
|
|
|
|
CDZ_Time_Out_Handl();//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
switch(objId)
|
|
|
|
|
{
|
|
|
|
|
case CanCHMID: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
|
|
|
|
|
|
|
|
|
bParseResult = CDZ_ParseCHM(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_HANDING_CHM;
|
|
|
|
|
// test_bmsrevdata =1;
|
|
|
|
|
//BMS_PRINT("\n\r<><72><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD> st_BmsStatusInfo[%d].BmsRcvCode = %x\n\r",Ch,st_BmsStatusInfo[Ch].BmsRcvCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case CanCRMID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCRM(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_HANDING_CRM;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCTSID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCTS(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_CONFIG_CTS;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCMLID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCML(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_CONFIG_CML;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCROID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCRO(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_CONFIG_CRO;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCCSID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCCS(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_CHARGE_CCS;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCSTID:
|
|
|
|
|
case CanCSTID1:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCST(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_END_CST;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCSDID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCSD(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_END_CSD;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CanCEMID:
|
|
|
|
|
{
|
|
|
|
|
bParseResult = CDZ_ParseCEM(cCanData, can_DataLen, Ch);
|
|
|
|
|
if (bParseResult)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode |= D_CDZ_END_CEM;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>can1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD>-1<EFBFBD>쳣 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
int bms_RcvCanSingleDataProc(CanRxMsg pSingleCanRxData)
|
|
|
|
|
{
|
|
|
|
|
static CanRxMsg SingleCanRxData = {0};
|
|
|
|
|
static uint32_t SingleId;
|
|
|
|
|
SingleCanRxData = pSingleCanRxData;
|
|
|
|
|
SingleId = SingleCanRxData.ExtId;
|
|
|
|
|
|
|
|
|
|
if((SingleCanRxData.ExtId & 0x0000FFFF) != 0x0000F456) //<2F><><EFBFBD>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD>
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if((SingleCanRxData.ExtId & 0xFFFF0000) == CAN_CM_CTRL_ID)//<2F>յ<EFBFBD>bms<6D><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
BMSCAN1Msg = SingleCanRxData;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if((SingleCanRxData.ExtId & 0xFFFF0000) == CAN_CM_DATA_ID)//<2F>յ<EFBFBD>bms<6D><73><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
BMSCAN1Msg = SingleCanRxData;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
(SingleId == CanCHMID) || (SingleId== CanCRMID) ||
|
|
|
|
|
(SingleId == CanCTSID) || (SingleId == CanCMLID) ||
|
|
|
|
|
(SingleId == CanCROID) || (SingleId == CanCCSID) ||
|
|
|
|
|
(SingleId == CanCSDID) || (SingleId == CanCEMID) ||
|
|
|
|
|
(SingleId == CanCSTID) || (SingleId == CanCSTID1)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
testBMSCAN1Msg = SingleCanRxData;
|
|
|
|
|
bms_parseData(SingleCanRxData.ExtId, SingleCanRxData.Data, SingleCanRxData.DLC, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CAN_REV_Mutli_t CanMessage;// add dxm ??bms???????
|
|
|
|
|
uint32_t MutliRecvTimer = 0;//add dxm
|
|
|
|
|
uint32_t MutliRecvCount = 0;//add dxm
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>bms_RcvCanMutliData
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺can
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
void bms_RcvCanMutliData(CanRxMsg candata,uint8_t channel,uint8_t *flag)
|
|
|
|
|
{
|
|
|
|
|
static uint8_t uPackNum = 0;
|
|
|
|
|
if(CanMessage.tail < CAN_MAX_PACKET)
|
|
|
|
|
{
|
|
|
|
|
CanMessage.Msgbody[CanMessage.tail] = candata;
|
|
|
|
|
CanMessage.tail++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((candata.ExtId & 0xFFFF0000) == CAN_CM_CTRL_ID) //<2F>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(candata.Data[0] == CM_RTS_CTRL_CODE || candata.Data[0] == CM_EMA_CTRL_CODE)
|
|
|
|
|
{
|
|
|
|
|
uPackNum = candata.Data[3];
|
|
|
|
|
}
|
|
|
|
|
else if(candata.Data[0] == CM_CTS_CTRL_CODE)
|
|
|
|
|
{
|
|
|
|
|
uPackNum = candata.Data[1];
|
|
|
|
|
}
|
|
|
|
|
MutliRecvCount = 10;//15ms????
|
|
|
|
|
}
|
|
|
|
|
else if((candata.ExtId & 0xFFFF0000) == CAN_CM_DATA_ID) //<2F>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(uPackNum == candata.Data[0])
|
|
|
|
|
{
|
|
|
|
|
MutliRecvCount = 20;
|
|
|
|
|
uPackNum = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MutliRecvCount = 50;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
TickOut(&MutliRecvTimer,0);
|
|
|
|
|
*flag =0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t bms_rev_busy_flag = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
volatile uint8_t MutliRecvFlag = {0};
|
|
|
|
|
CanRxMsg MutliBMSCAN1Msg;
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>bms_RcvCanMutliData
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>can<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
//void USB_LP_CAN1_RX0_IRQHandler(void)
|
|
|
|
|
//{
|
|
|
|
|
// CanRxMsg RxMessage;
|
|
|
|
|
// CAN_Receive(CAN1,CAN_FIFO0,&RxMessage);
|
|
|
|
|
|
|
|
|
|
// bms_rev_busy_flag = 1;
|
|
|
|
|
|
|
|
|
|
// if(bms_RcvCanSingleDataProc(RxMessage) == 1)
|
|
|
|
|
// {
|
|
|
|
|
// MutliBMSCAN1Msg = RxMessage;
|
|
|
|
|
// bms_RcvCanMutliData(MutliBMSCAN1Msg,0,&bms_rev_busy_flag);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>Is_bms_RcvMutliMsgOverFlag
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж϶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺Ch ͨ<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
static void Is_bms_RcvMutliMsgOverFlag()
|
|
|
|
|
{
|
|
|
|
|
if(MutliRecvCount)
|
|
|
|
|
{
|
|
|
|
|
if(TickOut(&MutliRecvTimer,MutliRecvCount)== TRUE)
|
|
|
|
|
{
|
|
|
|
|
// BMS_PRINT("\n\r<><72>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʱ[%d]<5D><><EFBFBD><EFBFBD>\r\n",MutliRecvCount);
|
|
|
|
|
MutliRecvFlag = 1;//<2F><><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>־λ
|
|
|
|
|
MutliRecvCount= 0;//<2F><>ʱ<EFBFBD><CAB1>0
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//δ<><CEB4>ʱ<EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else //test
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>bms_RcvCanMutliDataProc
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><EFBFBD>պͽ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺Ch CAN ͨ<EFBFBD><EFBFBD> (0/1)
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
static CanRxMsg st_CanRxData= {0};
|
|
|
|
|
void bms_RcvCanMutliDataProc()
|
|
|
|
|
{
|
|
|
|
|
static uint32_t objId= 0;
|
|
|
|
|
static uint8_t MutliPacketFlag = FALSE;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>
|
|
|
|
|
static uint16_t cCanMutliDataLen= 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
|
|
|
|
//static CanRxMsg st_CanRxData= 0;
|
|
|
|
|
Is_bms_RcvMutliMsgOverFlag(); //<2F>ж϶<D0B6><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>λ
|
|
|
|
|
|
|
|
|
|
if(MutliRecvFlag == 1)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(CanMessage.head >= CanMessage.tail)
|
|
|
|
|
{
|
|
|
|
|
MutliRecvFlag = 0;
|
|
|
|
|
CanMessage.tail =0;
|
|
|
|
|
CanMessage.head =0;
|
|
|
|
|
// BMS_PRINT("\n\r<><72>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
memcpy(&st_CanRxData,&CanMessage.Msgbody[CanMessage.head++],sizeof(CanRxMsg));
|
|
|
|
|
|
|
|
|
|
if((st_CanRxData.ExtId & 0x0000FFFF) != 0x000056F4 ) //ID<49><44><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if((st_CanRxData.ExtId & 0xFFFF0000) == CAN_CM_CTRL_ID ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(st_CanRxData.Data[0] == CM_RTS_CTRL_CODE) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(st_CanRxData.Data[0] == CM_CTS_CTRL_CODE) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if( (st_CanRxData.ExtId & 0xFFFF0000) == CAN_CM_DATA_ID ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(MutliPacketFlag == TRUE) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
MutliPacketFlag = FALSE;
|
|
|
|
|
bms_parseData(objId, 0, cCanMutliDataLen, 0);
|
|
|
|
|
cCanMutliDataLen= 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************can2<6E><32><EFBFBD><EFBFBD>*****************************/
|
|
|
|
|
#define WAIT_TIME_MS 3
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void bms_SendBHM(uint16_t MaxVoltage)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBHMID;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 2;
|
|
|
|
|
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
BMS_CanTxData.Data[0] = MaxVoltage &0xff;
|
|
|
|
|
BMS_CanTxData.Data[1] =(MaxVoltage >> 8)&0xff;//<2F><><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><>ʶ
|
|
|
|
|
void bms_SendBRM(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
uint8_t ucVehichleBmsInfo[17] ={0}; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6>Ϣ VIN<49><4E>
|
|
|
|
|
|
|
|
|
|
if(step == 1)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBRMID1;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 8;
|
|
|
|
|
memset(BMS_CanTxData.Data,0xff,8);
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x10;
|
|
|
|
|
BMS_CanTxData.Data[1] = 0x31;//<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[2] = 0x00;//<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[3] = 0x07;//49֡<39><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ7<D2AA><37><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[4] = 0xff;
|
|
|
|
|
BMS_CanTxData.Data[5] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[6] = 0x02;
|
|
|
|
|
BMS_CanTxData.Data[7] = 0x00;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
else if(step == 2)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBRMID2;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 8;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
//01 01 01 01 03 e8 03 58
|
|
|
|
|
//010101<30><31>ǰ<EFBFBD>汾<EFBFBD><E6B1BE>Ϣ
|
|
|
|
|
//03<30><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>﮵<EFBFBD><EFAEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// 0x03e8 <20><><EFBFBD><EFBFBD><EFBFBD>ض<D8B6><EEB6A8><EFBFBD><EFBFBD>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ض<D8B6>ܵ<EFBFBD>ѹ :0x1b58 = 7000 =700V
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:0x00000000
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x01;
|
|
|
|
|
BMS_CanTxData.Data[1] = GetBRM_VersionArr_0();
|
|
|
|
|
BMS_CanTxData.Data[2] = GetBRM_VersionArr_1();
|
|
|
|
|
BMS_CanTxData.Data[3] = GetBRM_VersionArr_2(); //bmsͨѶЭ<D1B6><D0AD><EFBFBD>汾<EFBFBD><E6B1BE>Ĭ<EFBFBD><C4AC> 00 01 01
|
|
|
|
|
BMS_CanTxData.Data[4] = GetBRM_Battery_TYPE(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[5] = GetBRM_RatedCapacity()&0xff;
|
|
|
|
|
BMS_CanTxData.Data[6] = (GetBRM_RatedCapacity()>>8)&0xff;//<2F><EFBFBD><EEB6A8><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[7] = GetBRM_RatedTotalVoltage()&0xff;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʱ 10ms
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x02;
|
|
|
|
|
BMS_CanTxData.Data[1] =(GetBRM_RatedTotalVoltage()>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD>ѹ
|
|
|
|
|
BMS_CanTxData.Data[2] = BMSDefaultParameters.BRM.Battery_manufacturer[0];
|
|
|
|
|
BMS_CanTxData.Data[3] = BMSDefaultParameters.BRM.Battery_manufacturer[1];
|
|
|
|
|
BMS_CanTxData.Data[4] = BMSDefaultParameters.BRM.Battery_manufacturer[2];
|
|
|
|
|
BMS_CanTxData.Data[5] = BMSDefaultParameters.BRM.Battery_manufacturer[3]; //<2F><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--4<>ֽ<EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[6] = 0x00;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[7] = 0x00;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʱ 10ms
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x03;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[1] = 0x01;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[2] = 0x02;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--4<>ֽ<EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[3] = BMSDefaultParameters.BRM.Batteryack_production_dateYesr; //-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--3<>ֽ<EFBFBD> <20><>
|
|
|
|
|
BMS_CanTxData.Data[4] = BMSDefaultParameters.BRM.Batteryack_production_dateMouth; // <20><>
|
|
|
|
|
BMS_CanTxData.Data[5] = BMSDefaultParameters.BRM.Batteryack_production_dateData; // <20><>
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[6] = BMSDefaultParameters.BRM.Battery_pack_charge_count.fields.ChargeCount[0];
|
|
|
|
|
BMS_CanTxData.Data[7] = BMSDefaultParameters.BRM.Battery_pack_charge_count.fields.ChargeCount[1];
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
//<2F><>ʱ 10ms
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
|
|
|
|
|
SysParaPileD.VIN_Enable = 0;//<2F><><EFBFBD>ϱ<EFBFBD>VIN
|
|
|
|
|
if(SysParaPileD.VIN_Enable == 1) //<2F>ϱ<EFBFBD>VIN
|
|
|
|
|
{
|
|
|
|
|
memcpy(ucVehichleBmsInfo, BMSDefaultParameters.BRM.ucCarVin,sizeof(Bms_BatInfo.ucVehichleInfo));
|
|
|
|
|
}
|
|
|
|
|
else //<2F><><EFBFBD>ϱ<EFBFBD> VIN
|
|
|
|
|
{
|
|
|
|
|
memset(ucVehichleBmsInfo,0xFF,sizeof(ucVehichleBmsInfo));
|
|
|
|
|
}
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x04;
|
|
|
|
|
BMS_CanTxData.Data[1] = BMSDefaultParameters.BRM.Battery_pack_charge_count.fields.ChargeCount[2];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--3<>ֽ<EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[2] = BMSDefaultParameters.BRM.Battery_pack_property_right_identification; //<2F><><EFBFBD>ز<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[3] = 0x00; // Ԥ<><D4A4>
|
|
|
|
|
BMS_CanTxData.Data[4] = ucVehichleBmsInfo[0]; // <20><><EFBFBD><EFBFBD> VIN
|
|
|
|
|
BMS_CanTxData.Data[5] = ucVehichleBmsInfo[1];
|
|
|
|
|
BMS_CanTxData.Data[6] = ucVehichleBmsInfo[2];
|
|
|
|
|
BMS_CanTxData.Data[7] = ucVehichleBmsInfo[3];
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʱ 10ms
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x05;
|
|
|
|
|
BMS_CanTxData.Data[1] = ucVehichleBmsInfo[4];
|
|
|
|
|
BMS_CanTxData.Data[2] = ucVehichleBmsInfo[5];
|
|
|
|
|
BMS_CanTxData.Data[3] = ucVehichleBmsInfo[6];
|
|
|
|
|
BMS_CanTxData.Data[4] = ucVehichleBmsInfo[7];
|
|
|
|
|
BMS_CanTxData.Data[5] = ucVehichleBmsInfo[8];
|
|
|
|
|
BMS_CanTxData.Data[6] = ucVehichleBmsInfo[9];
|
|
|
|
|
BMS_CanTxData.Data[7] = ucVehichleBmsInfo[10];
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʱ 10ms
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x06;
|
|
|
|
|
BMS_CanTxData.Data[1] = ucVehichleBmsInfo[11];
|
|
|
|
|
BMS_CanTxData.Data[2] = ucVehichleBmsInfo[12];
|
|
|
|
|
BMS_CanTxData.Data[3] = ucVehichleBmsInfo[13];
|
|
|
|
|
BMS_CanTxData.Data[4] = ucVehichleBmsInfo[14];
|
|
|
|
|
BMS_CanTxData.Data[5] = ucVehichleBmsInfo[15];
|
|
|
|
|
BMS_CanTxData.Data[6] = ucVehichleBmsInfo[16];
|
|
|
|
|
BMS_CanTxData.Data[7] = 0x10; //bms<6D><73><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʱ 10ms
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x07;
|
|
|
|
|
BMS_CanTxData.Data[1] = 0x0A; //<2F><>10
|
|
|
|
|
BMS_CanTxData.Data[2] = 0x0B; //<2F><>11
|
|
|
|
|
BMS_CanTxData.Data[3] = 0x07; //<2F><>20
|
|
|
|
|
BMS_CanTxData.Data[4] = 0xE0; // 16
|
|
|
|
|
BMS_CanTxData.Data[5] = 0xff; //Ԥ<><D4A4>Ĭ<EFBFBD><C4AC>0xff
|
|
|
|
|
BMS_CanTxData.Data[6] = 0xff; //Ԥ<><D4A4>Ĭ<EFBFBD><C4AC>0xff
|
|
|
|
|
BMS_CanTxData.Data[7] = 0xff; //Ԥ<><D4A4>Ĭ<EFBFBD><C4AC>0xff
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#include "adc.h"
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
|
|
|
|
void bms_SendBCP(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
if(step == 1)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBRMID1;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 8;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x10;
|
|
|
|
|
BMS_CanTxData.Data[1] = 0x0d;
|
|
|
|
|
BMS_CanTxData.Data[2] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[3] = 0x02;
|
|
|
|
|
BMS_CanTxData.Data[4] = 0xff;
|
|
|
|
|
BMS_CanTxData.Data[5] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[6] = 0x06;
|
|
|
|
|
BMS_CanTxData.Data[7] = 0x00;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
else if(step == 2)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBRMID2;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 8;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ:375 (0.1v), <20><><EFBFBD><EFBFBD>:1720 (0.1A)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ:5994 (0.1V),<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>:60 (C)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD>״̬:458 (0.1%), <EFBFBD><EFBFBD>ǰ<EFBFBD>ܵ<EFBFBD>ѹ:5335 (0.1V)*/
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x01;
|
|
|
|
|
BMS_CanTxData.Data[1] = BMSDefaultParameters.BCP.MaxChargingVoltageSingle&0xff;
|
|
|
|
|
BMS_CanTxData.Data[2] = (BMSDefaultParameters.BCP.MaxChargingVoltageSingle>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ420*0.01 = 4.2v <20><><EFBFBD><EFBFBD>0.01
|
|
|
|
|
BMS_CanTxData.Data[3] = (4000-BMSDefaultParameters.BCP.MaxChargingCurrent)&0xff;
|
|
|
|
|
BMS_CanTxData.Data[4] = ((4000-BMSDefaultParameters.BCP.MaxChargingCurrent)>>8)&0xff;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>0.1 ƫ<><C6AB><EFBFBD><EFBFBD>-400
|
|
|
|
|
BMS_CanTxData.Data[5] = BMSDefaultParameters.BCP.NominalTotalEnergy&0xff;
|
|
|
|
|
BMS_CanTxData.Data[6] = (BMSDefaultParameters.BCP.NominalTotalEnergy>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>0.1
|
|
|
|
|
BMS_CanTxData.Data[7] = BMSDefaultParameters.BCP.MaxTotalChargingVoltage&0xff;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
//<2F><>ʱ 10ms 50 00 f4 01 64 19 00
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x02;
|
|
|
|
|
BMS_CanTxData.Data[1] =(BMSDefaultParameters.BCP.MaxTotalChargingVoltage>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD>ѹ
|
|
|
|
|
BMS_CanTxData.Data[2] = BMSDefaultParameters.BCP.MaxTemperature+10; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>110 -50 = 60<36><30>C ƫ<><C6AB><EFBFBD><EFBFBD>-50
|
|
|
|
|
uint16_t uTotalBatSOC = BMSDefaultParameters.BCP.ChargeState *10;
|
|
|
|
|
BMS_CanTxData.Data[3] = uTotalBatSOC &0xff;
|
|
|
|
|
BMS_CanTxData.Data[4] = (uTotalBatSOC>>8)&0xff; //<2F><><EFBFBD><EFBFBD>Soc״̬ <20><><EFBFBD><EFBFBD>0.1
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[5] = BMSDefaultParameters.BCP.CurrentVoltage&0xff ;
|
|
|
|
|
BMS_CanTxData.Data[6] = (BMSDefaultParameters.BCP.CurrentVoltage >>8)&0xff;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ǰ<EFBFBD><C7B0>ѹ300v
|
|
|
|
|
BMS_CanTxData.Data[7] = 0x00;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ BRO
|
|
|
|
|
//0x0--BMS<4D><53><EFBFBD>ܱ<EFBFBD>ʶ 0xaa--BMS<4D>ܱ<EFBFBD>ʶ
|
|
|
|
|
void bms_SendBRO(uint8_t Ready)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBROID;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 1;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = Ready;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BCL
|
|
|
|
|
void bms_SendBCL(void)
|
|
|
|
|
{
|
|
|
|
|
uint16_t fTotalBatVol ,fTotalBatCur;
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBCLID;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 5;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BCL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ:0xfa0 =4000=400V
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:0xf46 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ:02 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
fTotalBatVol = BMSDefaultParameters.BCL.VoltageDemand;
|
|
|
|
|
fTotalBatCur = (4000-BMSDefaultParameters.BCL.CurrentDemand);
|
|
|
|
|
// Bms_BatChargeRealInfo.uChargeMode = 2 ; //2<><32><EFBFBD><EFBFBD> 1--<2D><>ѹ
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = (fTotalBatVol)&0xff;
|
|
|
|
|
BMS_CanTxData.Data[1] = (fTotalBatVol>>8)&0xff; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>0.1
|
|
|
|
|
BMS_CanTxData.Data[2] = (fTotalBatCur)&0xff;
|
|
|
|
|
BMS_CanTxData.Data[3] = (fTotalBatCur>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>0.1 ƫ<><C6AB><EFBFBD><EFBFBD>-400
|
|
|
|
|
BMS_CanTxData.Data[4] = BMSDefaultParameters.BCL.Mode?2:1;//<2F><><EFBFBD><EFBFBD>ģʽ 0x1:<3A><>ѹ 0x2:<3A><><EFBFBD><EFBFBD>
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ BCS
|
|
|
|
|
void bms_SendBCS(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
if(step == 1)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBRMID1;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 8;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x10;
|
|
|
|
|
BMS_CanTxData.Data[1] = 0x09;
|
|
|
|
|
BMS_CanTxData.Data[2] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[3] = 0x02;
|
|
|
|
|
BMS_CanTxData.Data[4] = 0xff;
|
|
|
|
|
BMS_CanTxData.Data[5] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[6] = 0x11;
|
|
|
|
|
BMS_CanTxData.Data[7] = 0x00;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
else if(step == 2)
|
|
|
|
|
{
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBRMID2;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 8;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ֵ:0x139e =5022 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ:0x
|
|
|
|
|
fa0 = 4000 =400A(ƫ<EFBFBD><EFBFBD>-400A) <EFBFBD>ɵ<EFBFBD>״̬: 32%
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD> 0x0050 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x01;
|
|
|
|
|
|
|
|
|
|
//1-12λ:<3A><><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>ѹ <20><><EFBFBD><EFBFBD>0.01
|
|
|
|
|
//13~16λ:<3A><><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0~15
|
|
|
|
|
//Bms_BatChargeRealInfo.nBayMaxVolInfo =((1<<12) |( Bms_BatConfigParam.BatMaxChargeVol-100));
|
|
|
|
|
//BMSDefaultParameters.BCS.MaxSingleCellVoltage.value =((1<<12) |( BMSDefaultParameters.BCS.MaxSingleCellVoltage.value-100));
|
|
|
|
|
BMS_CanTxData.Data[1] = BMSDefaultParameters.BCS.ChargingVoltage&0xff;
|
|
|
|
|
BMS_CanTxData.Data[2] = (BMSDefaultParameters.BCS.ChargingVoltage>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
BMS_CanTxData.Data[3] = BMSDefaultParameters.BCS.ChargingCurrent&0xff;
|
|
|
|
|
BMS_CanTxData.Data[4] = (BMSDefaultParameters.BCS.ChargingCurrent>>8)&0xff;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[5] = BMSDefaultParameters.BCS.MaxSingleCellVoltage.value&0xff;
|
|
|
|
|
BMS_CanTxData.Data[6] = (BMSDefaultParameters.BCS.MaxSingleCellVoltage.value>>8)&0xff;
|
|
|
|
|
BMS_CanTxData.Data[7] = BMSDefaultParameters.uBatCurSOC; //<2F><>ǰSOC״̬
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Delay_MS(WAIT_TIME_MS);
|
|
|
|
|
//<2F><>ʱ 10ms 50 00 f4 01 64 19 00
|
|
|
|
|
BMSDefaultParameters.BCS.RemainingChargeTime = 100 - BMSDefaultParameters.uBatCurSOC;
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x02;
|
|
|
|
|
BMS_CanTxData.Data[1] = BMSDefaultParameters.BCS.RemainingChargeTime&0xff;
|
|
|
|
|
BMS_CanTxData.Data[2] = (BMSDefaultParameters.BCS.RemainingChargeTime>>8)&0xff; //<2F><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
BMS_CanTxData.Data[3] = 0;
|
|
|
|
|
BMS_CanTxData.Data[4] = 0;
|
|
|
|
|
BMS_CanTxData.Data[5] = 0;
|
|
|
|
|
BMS_CanTxData.Data[6] = 0;
|
|
|
|
|
BMS_CanTxData.Data[7] = 0;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ״̬ BSM
|
|
|
|
|
void bms_SendBSM(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
uint8_t BatMaxVoltNum = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
|
|
|
|
uint8_t BatMaxtemp = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
|
|
|
uint8_t BatMaxTempNum = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD>
|
|
|
|
|
int8_t BatMintemp = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
|
|
|
int8_t BatMintempNum = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD>
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBSMID;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 7;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
if(SysParaPileD.SocSimulaType == 1)
|
|
|
|
|
{
|
|
|
|
|
BatMaxVoltNum = 0x05; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
|
|
|
|
BatMaxtemp = 0x4B; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> <09><>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>-50<35><30>C<EFBFBD><43><EFBFBD>Լ<EFBFBD>50<35><30>
|
|
|
|
|
BatMaxTempNum = 0x04; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD>
|
|
|
|
|
BatMintemp = 0x4A; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> <09><>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>-50<35><30>C<EFBFBD><43><EFBFBD>Լ<EFBFBD>50<35><30>
|
|
|
|
|
BatMintempNum = 0x03; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BatMaxVoltNum = 0x05; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> 5<><35>
|
|
|
|
|
BatMaxtemp = 0x4B; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> 75-50 = 25<32><35>C <09><>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>-50<35><30>C<EFBFBD><43><EFBFBD>Լ<EFBFBD>50<35><30>
|
|
|
|
|
BatMaxTempNum = 0x04; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD> 4<><34>
|
|
|
|
|
BatMintemp = 0x4A; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> 74-50 = 24<32><34>C <20><>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>-50<35><30>C<EFBFBD><43><EFBFBD>Լ<EFBFBD>50<35><30>
|
|
|
|
|
BatMintempNum = 0x03; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD> 3<><33>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//6.0~6.1λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD>
|
|
|
|
|
//6.2~6.3λ:<3A><><EFBFBD><EFBFBD>SOC״̬<D7B4><CCAC><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD>
|
|
|
|
|
//6.4~6.5λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//6.6~6.7λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȹ<C2B6><C8B9><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//7.0~7.1λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD>Ե״̬ 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD>
|
|
|
|
|
//7.2~7.3λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD>
|
|
|
|
|
//7.4~7.5λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><>ֹ 01:<3A><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = GetBSM_highest_cell_voltage_number(); //<2F><><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[1] = GetBSM_highest_battery_temperature()+10; //<2F><><EFBFBD>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[2] = GetBSM_highest_temperature_detection_point(); //<2F><><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[3] = GetBSM_lowest_battery_temperature()+10; //<2F><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[4] = GetBSM_lowest_temperature_detection_point(); //<2F><><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[5] = 0x00; //δʹ<CEB4><CAB9>
|
|
|
|
|
// Bms_BatChargeRealInfo.uChargeEnable = 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0--<2D><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
BMS_CanTxData.Data[6] = (GetBSM_charging_permission()<<4); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> <20><>ֹ<EFBFBD><D6B9><EFBFBD>籨<EFBFBD><E7B1A8> BST
|
|
|
|
|
void bms_SendBST(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
u8 Bms_AbortReason = 0; //bms<6D><73>ֹԭ<D6B9><D4AD>
|
|
|
|
|
u16 Bms_fault = 0; //bms<6D><73>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
u8 Bms_ChargingError = 0; //bms<6D><73>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBSTID;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 4;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
//bms<6D><73>ֹԭ<D6B9><D4AD>
|
|
|
|
|
//1.1~1.2λ:<3A>ﵽ<EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SOC 00:δ<>ﵽ 01:<3A>ﵽ 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//3.3~3.4λ:<3A>ﵽ<EFBFBD>ܵ<EFBFBD>ѹ<EFBFBD>趨ֵ 00:δ<>ﵽ 01:<3A>ﵽ 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//3.5~3.6λ:<3A>ﵽ<EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>趨ֵ 00:δ<>ﵽ 01:<3A>ﵽ 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//3.7~3.8λ:<3A><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD><EFBFBD><D7AE>ֹ(<28>յ<EFBFBD>CST֡) 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F>ﵽSOC<4F>趨ֵ
|
|
|
|
|
if(BMSDefaultParameters.uBatCurSOC == 100)
|
|
|
|
|
Bms_AbortReason |= 0x01;
|
|
|
|
|
else
|
|
|
|
|
Bms_AbortReason |= 0x00;
|
|
|
|
|
// //<2F>ﵽ<EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>趨ֵ
|
|
|
|
|
// if(stopChargeReason == 30)
|
|
|
|
|
// Bms_AbortReason |= 0x10;
|
|
|
|
|
// else
|
|
|
|
|
// Bms_AbortReason |= 0x00;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ
|
|
|
|
|
if(Err_Read(39) == true)
|
|
|
|
|
Bms_AbortReason |= 0x40;
|
|
|
|
|
else
|
|
|
|
|
Bms_AbortReason |= 0x00;
|
|
|
|
|
|
|
|
|
|
/*********************************bms<6D><73>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
//2.1~2.2λ:<3A><>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x01
|
|
|
|
|
//2.3~2.4λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x04
|
|
|
|
|
//2.5~2.6λ:bmsԪ<73><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x10
|
|
|
|
|
//2.7~2.8λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x40
|
|
|
|
|
|
|
|
|
|
//3.1~3.2λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȹ<C2B6><C8B9>߹<EFBFBD><DFB9><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x100
|
|
|
|
|
//3.3~3.4λ:<3A><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x400
|
|
|
|
|
//3.5~3.6λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x1000
|
|
|
|
|
//3.7~3.8λ:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD> 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x4000
|
|
|
|
|
********************************************************************/
|
|
|
|
|
if(Err_Read(26) == true)//<2F><>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD>
|
|
|
|
|
Bms_fault |= 0x01;
|
|
|
|
|
else
|
|
|
|
|
Bms_fault |= 0x00;
|
|
|
|
|
|
|
|
|
|
// if(FdcInfo.gun_plugin_flag == 12)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD>
|
|
|
|
|
// Bms_fault |= 0x40;
|
|
|
|
|
// else
|
|
|
|
|
// Bms_fault |= 0x00;
|
|
|
|
|
|
|
|
|
|
// if(stopChargeReason == 24)//<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// Bms_fault |= 0x400;
|
|
|
|
|
// else
|
|
|
|
|
// Bms_fault |= 0x00;
|
|
|
|
|
|
|
|
|
|
//bms<6D><73>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
//4.1~4.2:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 00:<3A><><EFBFBD><EFBFBD> 01:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x01
|
|
|
|
|
//4.3~4.4:<3A><>ѹ<EFBFBD>쳣 00:<3A><><EFBFBD><EFBFBD> 01:<3A><>ѹ<EFBFBD>쳣 10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x04
|
|
|
|
|
if(Err_Read(5) == true)
|
|
|
|
|
Bms_ChargingError |= 0x01;
|
|
|
|
|
else
|
|
|
|
|
Bms_ChargingError |= 0x00;
|
|
|
|
|
|
|
|
|
|
if(Err_Read(1) == true || Err_Read(2) == true)
|
|
|
|
|
Bms_ChargingError |= 0x04;
|
|
|
|
|
else
|
|
|
|
|
Bms_ChargingError |= 0x00;
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = Bms_AbortReason;
|
|
|
|
|
BMS_CanTxData.Data[1] = Bms_fault&0xff;
|
|
|
|
|
BMS_CanTxData.Data[2] = Bms_fault>>8&0xff;
|
|
|
|
|
BMS_CanTxData.Data[3] = Bms_ChargingError;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> BMSͳ<53>Ʊ<EFBFBD><C6B1><EFBFBD> BSD
|
|
|
|
|
void bms_SendBSD(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
static uint16_t BattCellMaxVolt,BattCellMinVolt; //<2F><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ѹ
|
|
|
|
|
static uint16_t BattCellMaxTemp, BattCellMinTemp; //<2F><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBSDID;
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 7;
|
|
|
|
|
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = BMSDefaultParameters.uBatCurSOC; //<2F><>ֹsoc
|
|
|
|
|
BMS_CanTxData.Data[1] = GetBSDmin_cell_voltage()&0xff;
|
|
|
|
|
BMS_CanTxData.Data[2] = (GetBSDmin_cell_voltage()>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ѹ <20><><EFBFBD><EFBFBD>0.01 0x044c = 1100*0.01 = 11v
|
|
|
|
|
BMS_CanTxData.Data[3] = GetBSDmax_cell_voltage()&0xff;
|
|
|
|
|
BMS_CanTxData.Data[4] = (GetBSDmax_cell_voltage()>>8)&0xff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ <20><><EFBFBD><EFBFBD>0.01 0x04b0 = 1200*0.01 = 12v
|
|
|
|
|
BMS_CanTxData.Data[5] = GetBSDmin_battery_temperature(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> ƫ<><C6AB><EFBFBD><EFBFBD>-50 0x64 = 100-50 = 50<35><30>C
|
|
|
|
|
BMS_CanTxData.Data[6] = GetBSDmax_battery_temperature(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> ƫ<><C6AB><EFBFBD><EFBFBD>-50 0x65 = 101-50 = 51<35><31>C
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//bms <20><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> BMS<4D><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BEM
|
|
|
|
|
void bms_SendBEM(uint16_t step)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.StdId = 0;
|
|
|
|
|
BMS_CanTxData.ExtId = CanBEMID;
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.IDE = CAN_ID_EXT;
|
|
|
|
|
BMS_CanTxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_CanTxData.DLC = 4;
|
|
|
|
|
memset(BMS_CanTxData.Data, 0xff, 8);
|
|
|
|
|
|
|
|
|
|
//1.1~1.2λ:<3A><><EFBFBD><EFBFBD><EFBFBD><D7AE>ʶ<EFBFBD><CAB6><EFBFBD>ij<EFBFBD>ʱ(0x00) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//1.3~1.4λ:<3A><><EFBFBD><EFBFBD><EFBFBD><D7AE>ʶ<EFBFBD><CAB6><EFBFBD>ij<EFBFBD>ʱ(0xaa) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//2.1~2.2λ:<3A><><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>ʱ<D7AE><CAB1>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ(CTS/CMN) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//2.3~2.4λ:<3A><><EFBFBD>ճ<EFBFBD><D5B3><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>ʱ(CRO) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//3.1~3.2λ:<3A><><EFBFBD>ճ<EFBFBD><D5B3><EFBFBD><EFBFBD><D7AE><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>ij<EFBFBD>ʱ(CCS) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//3.3~3.4λ:<3A><><EFBFBD>ճ<EFBFBD><D5B3><EFBFBD><EFBFBD><D7AE>ֹ<EFBFBD><D6B9><EFBFBD>籨<EFBFBD>ij<EFBFBD>ʱ(CST) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//4.1~4.2λ:<3A><><EFBFBD>ճ<EFBFBD><D5B3><EFBFBD>ͳ<D7AE>Ʊ<EFBFBD><C6B1>ij<EFBFBD>ʱ(CSD) 0x00:<3A><><EFBFBD><EFBFBD> 0x01:<3A><>ʱ 0x10:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
BMS_CanTxData.Data[0] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[1] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[2] = 0x00;
|
|
|
|
|
BMS_CanTxData.Data[3] = 0x00;
|
|
|
|
|
can_write(&BMS_CanTxData);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===========================OBD BMS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD> ====================================
|
|
|
|
|
|
|
|
|
|
wulingbat_info_t WuLingBatteryInfo;
|
|
|
|
|
|
|
|
|
|
static int8_t ParseBMS100(CanRxMsg *pData)//<2F><><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ID0x100<30><30><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(pData->Data[0]==1)
|
|
|
|
|
{
|
|
|
|
|
WuLingBatteryInfo.Long_TEST = 1;//<2F>ϻ<EFBFBD><CFBB><EFBFBD>־λ
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CanRxMsg testBMSCAN2Msg;
|
|
|
|
|
CanTxMsg testBMSCAN2MsgTx;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern uint8_t NetworkManageFrameFlag;
|
|
|
|
|
|
|
|
|
|
static uint32_t NetworkManageFrameFlagTimer = 0; /* <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡ <20><>tick */
|
|
|
|
|
static uint32_t NetworkLocalWakingTimer = 0; /* <20><>¼<EFBFBD><C2BC><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD>ֵ<EFBFBD>tick */
|
|
|
|
|
|
|
|
|
|
void CheckNetworkManageFrameFlagTimeout(void)
|
|
|
|
|
{
|
|
|
|
|
// if (ChkPwrManageAccoff()!=0)
|
|
|
|
|
// {
|
|
|
|
|
// TickOut(&NetworkLocalWakingTimer, 0); /* <20><>ǰ<EFBFBD><C7B0><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tick<63><6B>¼ */
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (NetworkManageFrameFlagTimer == 0) /* <20><><EFBFBD><EFBFBD>NetworkManageFrameFlagTimer=0 <20><>ʾ<EFBFBD>ճ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBB>Ѻ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᷢ<EFBFBD><E1B7A2>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>↑ʼ<EFBFAA><CABC>ʱ */
|
|
|
|
|
// { /* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʷ<EFBFBD><CAB7>͵Ĺ<CDB5><C4B9><EFBFBD>֡<EFBFBD><D6A1>tick<63><6B><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚϴ<C8BD><CFB4><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㿼<EFBFBD><E3BFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
// TickOut(&NetworkManageFrameFlagTimer, 0);
|
|
|
|
|
// }
|
|
|
|
|
// else if (TickOut(&NetworkManageFrameFlagTimer, 1200))
|
|
|
|
|
// {
|
|
|
|
|
// NetworkManageFrameFlag = 0; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NetworkManageFrameFlag <20><>Ҫ<EFBFBD><D2AA>Ϊ<EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><DFBC><EFBFBD>һ<EFBFBD><D2BB> */
|
|
|
|
|
// }
|
|
|
|
|
// #if 0
|
|
|
|
|
// if(TickOut(&NetworkManageFrameFlagTimer, 1200) == TRUE) // 5s ?
|
|
|
|
|
// {
|
|
|
|
|
// NetworkManageFrameFlag = 0;
|
|
|
|
|
// TickOut(&NetworkManageFrameFlagTimer, 0);
|
|
|
|
|
// }
|
|
|
|
|
// #endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡
|
|
|
|
|
*
|
|
|
|
|
* @return TRUE: <EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD>ͣ<EFBFBD>FALSE<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
static __inline bool NetWorkAppDateSending(void)
|
|
|
|
|
{
|
|
|
|
|
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>A+ ACC <20><>can<61><6E><EFBFBD>绽<EFBFBD>ѣ<EFBFBD>û<EFBFBD><C3BB>3sֹͣ
|
|
|
|
|
if (TickOut(&NetworkManageFrameFlagTimer, 3000) == TRUE && TickOut(&NetworkLocalWakingTimer, 3000) == TRUE)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>bms2_parseData
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD>룺Ch CAN ͨ<EFBFBD><EFBFBD> (0/1)
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*********************************************************************************/
|
|
|
|
|
int bms_RcvCan2DataProc(CanRxMsg pCanRxData)
|
|
|
|
|
{
|
|
|
|
|
static CanRxMsg SingleCanRxData = {0};
|
|
|
|
|
uint32_t SingleId;
|
|
|
|
|
SingleCanRxData = pCanRxData;
|
|
|
|
|
SingleId = SingleCanRxData.StdId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|
|
|
|
// if(
|
|
|
|
|
// ( )||(SingleId == CANBMS600INFOID_WULING)||
|
|
|
|
|
// (SingleId == CANBMS605INFOID_WULING)||(SingleId == CANBMS614INFOID_WULING)||
|
|
|
|
|
// (SingleId == CANBMS62AINFOID_WULING)||(SingleId == CANBMS651INFOID_WULING)||
|
|
|
|
|
// (SingleId == CANBMS653INFOID_WULING)||(SingleId == CANBMS652INFOID_WULING)||
|
|
|
|
|
// (SingleId == CANBMS654INFOID_WULING)||(SingleId == CANBMS686INFOID_WULING))
|
|
|
|
|
// {
|
|
|
|
|
// NetworkManageFrameFlag = 1;
|
|
|
|
|
// TickOut(&NetworkManageFrameFlagTimer, 0);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testBMSCAN2Msg = SingleCanRxData;
|
|
|
|
|
GPIO_SetBits(GPIOC,GPIO_Pin_7); //1043 ENable
|
|
|
|
|
REV_CanData.CarMessage(&SingleCanRxData); //<2F><><EFBFBD><EFBFBD>can<61><6E><EFBFBD><EFBFBD>
|
|
|
|
|
memset( &SingleCanRxData,0,sizeof(CanRxMsg));
|
|
|
|
|
SingleCanRxData.StdId =0;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************ģ<><C4A3>VIN<49><4E>********************************/
|
|
|
|
|
int VinCalc(char *Vin,char *reslt)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
unsigned int sum =0;
|
|
|
|
|
unsigned int check = 0;
|
|
|
|
|
char temp=0;
|
|
|
|
|
unsigned int j = 0;
|
|
|
|
|
|
|
|
|
|
const char jianquan[26][2] = {
|
|
|
|
|
{'A',1},{'B',2},{'C',3},{'D',4},{'E',5},{'F',6},
|
|
|
|
|
{'G',7},{'H',8},{'I',0},{'J',1},{'K',2},{'L',3},
|
|
|
|
|
{'M',4},{'N',5},{'O',0},{'P',7},{'Q',8},{'R',9},
|
|
|
|
|
{'S',2},{'T',3},{'U',4},{'V',5},{'W',6},{'X',7},
|
|
|
|
|
{'Y',8},{'Z',9}};
|
|
|
|
|
char pos[17]={8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2};
|
|
|
|
|
|
|
|
|
|
for(i=0;i<17;i++)
|
|
|
|
|
{
|
|
|
|
|
if(Vin[i]>='a'&&Vin[i]<='z')
|
|
|
|
|
{
|
|
|
|
|
temp = Vin[i]-0x20;
|
|
|
|
|
}
|
|
|
|
|
else if((Vin[i]>='A')&&(Vin[i]<='Z'))
|
|
|
|
|
{
|
|
|
|
|
temp = Vin[i];
|
|
|
|
|
}
|
|
|
|
|
else if((Vin[i]>='0')&&(Vin[i]<='9'))temp = Vin[i]-'0';
|
|
|
|
|
else return GD_ERR;
|
|
|
|
|
|
|
|
|
|
if((temp>='A')&&(temp<='Z'))
|
|
|
|
|
{
|
|
|
|
|
for(j=0;j<26;j++)
|
|
|
|
|
{
|
|
|
|
|
if(temp == jianquan[j][0])
|
|
|
|
|
temp = jianquan[j][1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
check += temp*pos[i];
|
|
|
|
|
}
|
|
|
|
|
*reslt = check%11;
|
|
|
|
|
return GD_OK;
|
|
|
|
|
}
|
|
|
|
|
extern u32 ChipUniqueID[3];
|
|
|
|
|
char VinTest(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char check = 0;
|
|
|
|
|
vin_byte_t vin_code;
|
|
|
|
|
char* Vin=SysParaPileD.VehichleInfo;//"LK6ADCE15LB408569";
|
|
|
|
|
vin_code.data = ChipUniqueID[2] >>16&0xff;
|
|
|
|
|
SysParaPileD.VehichleInfo[11] = vin_code.bits.vode_h >0x0A? vin_code.bits.vode_h-0x0A+0x30:vin_code.bits.vode_h +0x30;
|
|
|
|
|
SysParaPileD.VehichleInfo[12] = vin_code.bits.vode_l >0x0A? vin_code.bits.vode_l -0x0A+0x30:vin_code.bits.vode_l +0x30;;
|
|
|
|
|
vin_code.data = ChipUniqueID[2] >>8&0xff;
|
|
|
|
|
SysParaPileD.VehichleInfo[13] = vin_code.bits.vode_h >0x0A? vin_code.bits.vode_h-0x0A+0x30:vin_code.bits.vode_h +0x30;
|
|
|
|
|
SysParaPileD.VehichleInfo[14] = vin_code.bits.vode_l >0x0A? vin_code.bits.vode_l -0x0A+0x30:vin_code.bits.vode_l +0x30;;
|
|
|
|
|
|
|
|
|
|
vin_code.data = ChipUniqueID[2]&0xff;
|
|
|
|
|
SysParaPileD.VehichleInfo[15] = vin_code.bits.vode_h >0x0A? vin_code.bits.vode_h-0x0A+0x30:vin_code.bits.vode_h +0x30;
|
|
|
|
|
SysParaPileD.VehichleInfo[16] = vin_code.bits.vode_l >0x0A? vin_code.bits.vode_l -0x0A+0x30:vin_code.bits.vode_l +0x30;;
|
|
|
|
|
|
|
|
|
|
// VinCalc((char*)&SysParaPileD.VehichleInfo[0],&check);
|
|
|
|
|
// data = VinTest();
|
|
|
|
|
VinCalc(Vin,&check);
|
|
|
|
|
SysParaPileD.VehichleInfo[8] = check +0x30;
|
|
|
|
|
SysParaPileD.device_type = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// char* Vin="LFV2A21K657355844";
|
|
|
|
|
|
|
|
|
|
return check;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char VinTest2(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char check = 0;
|
|
|
|
|
char VehichleInfo[17] = {"LK6ADCE19LB355844"};
|
|
|
|
|
vin_byte_t vin_code;
|
|
|
|
|
char* Vin= VehichleInfo;//"LK6ADCE15LB408569";
|
|
|
|
|
|
|
|
|
|
// data = VinTest();
|
|
|
|
|
VinCalc(Vin,&check);
|
|
|
|
|
VehichleInfo[8] = check +0x30;
|
|
|
|
|
SysParaPileD.device_type = 0;
|
|
|
|
|
|
|
|
|
|
return check;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************can2<6E><32><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>***************************************/
|
|
|
|
|
int8_t FDC_General_Status_5(void)
|
|
|
|
|
{
|
|
|
|
|
static u8 statsdata[8] = {0};
|
|
|
|
|
static u8 stats[8] = {0};
|
|
|
|
|
|
|
|
|
|
BMS_Can2TxData.StdId = 0x38A;
|
|
|
|
|
BMS_Can2TxData.ExtId = 0;
|
|
|
|
|
BMS_Can2TxData.IDE = CAN_ID_STD;
|
|
|
|
|
BMS_Can2TxData.RTR = CAN_RTR_DATA;
|
|
|
|
|
BMS_Can2TxData.DLC = 8; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
stats[0] = 1;
|
|
|
|
|
stats[1] = 1;
|
|
|
|
|
stats[2] = 1;
|
|
|
|
|
|
|
|
|
|
memcpy(statsdata, &stats[0], 8);
|
|
|
|
|
memcpy(BMS_Can2TxData.Data, statsdata, 8);
|
|
|
|
|
|
|
|
|
|
can_write2(&BMS_Can2TxData);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern bool can_sent_cycle_timeout(unsigned int frame_id);
|
|
|
|
|
|
|
|
|
|
static uint8_t DCDCSendBms2State = 1;
|
|
|
|
|
|
|
|
|
|
void WULING_DCDCSendBms2_force(void)
|
|
|
|
|
{
|
|
|
|
|
DCDCSendBms2State = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int8_t WULING_DCDCSendBms2(void)
|
|
|
|
|
{
|
|
|
|
|
uint32_t tmp;
|
|
|
|
|
static uint16_t index = 0,index2,index3,index4 = 0;
|
|
|
|
|
static uint32_t timerout = 0;
|
|
|
|
|
static uint32_t timer = 0;
|
|
|
|
|
static uint32_t timer2 = 0;
|
|
|
|
|
static uint32_t timer3 = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckNetworkManageFrameFlagTimeout();
|
|
|
|
|
|
|
|
|
|
if(DCDCSendBms2State ==1)
|
|
|
|
|
{
|
|
|
|
|
if(TickOutCycle(&timer, 10) == TRUE) // 100ms
|
|
|
|
|
{
|
|
|
|
|
index=0;
|
|
|
|
|
DCDCSendBms2State = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(DCDCSendBms2State ==2)
|
|
|
|
|
{
|
|
|
|
|
// if(ChkPwrManageAccoff()!=0 || ChkNetworkManageoff() !=0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// {
|
|
|
|
|
// timerout =0;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// if(timerout < 10000) //1s
|
|
|
|
|
// {
|
|
|
|
|
// if(TickOutCycle(&timer3, 10) == TRUE) // 100ms
|
|
|
|
|
// {
|
|
|
|
|
// timerout++;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if(TickOutCycle(&timer,5)== TRUE) // 100ms/20= 5
|
|
|
|
|
{
|
|
|
|
|
//100ms <20><><EFBFBD><EFBFBD>
|
|
|
|
|
if(index3++%4==0)
|
|
|
|
|
{
|
|
|
|
|
index++;
|
|
|
|
|
if(NetWorkAppDateSending() == TRUE)
|
|
|
|
|
{
|
|
|
|
|
FDC_General_Status_5();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|