/* * @Description: * @Version: * @Author: Arnold * @Date: 2023-12-25 10:37:47 * @LastEditTime: 2023-12-26 11:22:36 */ #ifndef __CDZ_DATA_H__ #define __CDZ_DATA_H__ #include #include #include #ifndef __STATIC_INLINE #define __STATIC_INLINE static __inline #endif enum TypeBattery { lead_batteries=0x01,/* 铅酸电池 */ Hi_MH=0x02,/* 镍氢电池 */ LFP_battery=0x03,/* 磷酸铁锂电池 */ CM_battery=0x04,/* 锰酸锂电池 */ LC_battery=0x05,/* 钴酸锂电池 */ TM_battery=0x06,/* 三元锂电池 */ LP_battery=0x07,/* 聚合物锂电池 */ LTi_battery=0x08,/* 钛酸锂电池 */ Other_batteries,/* 其他电池 */ }; enum BMS_ChrgAllow { allow = 0X1, refuse = 0X0 }; enum VCU_ChrgAllowed { Reserved2=0x3, PAUSED=0x2, ALLOWED =0x1, NOT_ALLOWED = 0x0 }; enum VCU_Mode { Default_mode, Normal_mode, AC_charge_mode, AC_discharge_mode, DC_charge_mode, DC_discharge_mode, Reservation_AC_charge_mode, charge_Mode_12V, Remote_control_mode, charge_battery_heat_mode, Remote_battery_heat_mode, Reserved }; enum BMS_OncConSt { No_connect, Half_connect, AC_charge_connect, AC_discharge_connect, Connect_Fault, Reserved1 }; enum BMS_WorkStatus { HV_finished = 0x3, HV_shutdown = 0x4 }; struct Car_BMS_message { uint32_t IC_Mileage; uint8_t IVI_TimeInfoSecond; uint8_t IVI_TimeInfoMinute; uint8_t IVI_TimeInfoHour; uint8_t IVI_TimeInfoDay; uint8_t IVI_TimeInfoMonth; uint8_t IVI_TimeInfoYear; }; struct Car_message { uint16_t VCU_RevVehicleHVpower; int16_t Charg_Curr; struct Car_BMS_message Car_BMS_message; enum VCU_Mode VCU_Mode;//VCU工作模式 enum VCU_ChrgAllowed VCU_ChrgAllowed;//VCU充电允许 enum BMS_ChrgAllow BMS_ChrgAllowed;//BMS充电允许 enum BMS_WorkStatus BMS_WorkStatus;//BMS工作状态 enum BMS_OncConSt BMS_OncConSt;//BMS插枪连接状态 bool (*Set_BMS_Charging_allowance)(enum BMS_ChrgAllow setting_up);//设置充电允许 bool (*Get_BMS_Charging_allowance)(struct Car_message* self); bool (*Set_Car_Charging_allowance)(enum VCU_ChrgAllowed setting_up);//设置充电允许 bool (*Get_Car_Charging_allowance)(struct Car_message* self); bool (*Set_Car_Working_Mode)(enum VCU_Mode setting_up);//设置工作模式 enum VCU_Mode (*Get_Car_Working_Mode)(struct Car_message* self); bool (*Set_Car_Working_Status)(enum BMS_WorkStatus setting_up);//设置充电模式 bool (*Get_Car_Working_Status)(struct Car_message* self); bool (*Set_Car_OncConSt_Status)(enum BMS_OncConSt setting_up);//BMS插枪连接状态 uint8_t (*Get_Car_OncConSt_Status)(struct Car_message* self); }; #pragma pack(1) struct BHM_DATA { uint16_t Maximum_allowable_total_charging_voltage;//最大允许充电总电压 }; // struct BRM_DATA // { // uint32_t Protocol_version_number:24; // enum TypeBattery Car_batteryType;//车电池类型 // uint16_t Rated_capacity_of_power_battery_system;/* 动力蓄电池系统额定容量*/ // uint16_t Power_battery_Rated_total_voltage_of_the_battery;/* 动力电池蓄电池额定总电压 */ // }; // 定义共用体 union Version_BMScommun { struct { uint8_t VersionArr[3]; } fields; uint32_t value:24; // 整个16位共用体的数值 }; union BMSChargeCount { //充电计数 struct { uint8_t ChargeCount[3]; } fields; uint32_t value:24; // 整个16位共用体的数值 }; struct BRM_DATA { union Version_BMScommun VersionNumber; // 协议版本号 enum TypeBattery BatteryType; // 车电池类型 uint16_t RatedCapacity; // 动力蓄电池系统额定容量 uint16_t RatedTotalVoltage; // 动力电池蓄电池额定总电压 char Battery_manufacturer[4];//厂家编号 uint8_t BatterySerialNumber[4];//电池组序号 uint8_t Batteryack_production_dateYesr;//年 uint8_t Batteryack_production_dateMouth;//月 uint8_t Batteryack_production_dateData;//日 union BMSChargeCount Battery_pack_charge_count;//电池组充电计数 uint8_t Battery_pack_property_right_identification;//电池组产权标识 uint8_t reserve;//保留 uint8_t ucCarVin[17];//车辆VIN uint8_t BMS_Software_version_number[8];//BMS软件版本号 }; // struct BCP_DATA // { // uint16_t MaxChargingVoltageSingle;/* 单体最高允许充电电压 */ // uint16_t Maximum_allowable_charging_current;/* 最高允许充电电流 */ // uint16_t Nominal_total_energy_of_power_battery;/* 动力蓄电池标称总能量 */ // uint16_t Maximum_allowable_total_charging_voltage;/* 最高允许充电总电压 */ // uint8_t maximum_permissible_temperature;/* 最高允许温度 */ // uint16_t Vehicle_power_battery_charge_state;/* 整车动力电池电荷状态 */ // uint16_t Current_battery_voltage_of_vehicle_power_battery;/* 整车动力蓄电池当前电池电压 */ // }; struct BCP_DATA { uint16_t MaxChargingVoltageSingle; // 单体最高允许充电电压 uint16_t MaxChargingCurrent; // 最高允许充电电流 uint16_t NominalTotalEnergy; // 动力蓄电池标称总能量 uint16_t MaxTotalChargingVoltage; // 最高允许充电总电压 uint8_t MaxTemperature; // 最高允许温度 uint16_t ChargeState; // 整车动力电池电荷状态 uint16_t CurrentVoltage; // 整车动力蓄电池当前电池电压 }; struct BRO_DATA { uint8_t Whether_the_BMS_is_ready;/* BMS是否准备就绪 */ }; enum ChargingMode { ConstantVoltage = 0x01,/* 恒压 */ ConstantCurrent = 0x02,/* 恒流 */ }; struct BCL_DATA { uint16_t VoltageDemand; // 电压需求(V) uint16_t CurrentDemand; // 电流需求(V) enum ChargingMode Mode:8; // 充电模式 }; // 定义共用体 union VoltageAndGroup { struct { uint16_t voltage : 12; // 前12个bit用于表示电压 uint16_t group : 4; // 后4个bit用于表示组号 } fields; uint16_t value; // 整个16位共用体的数值 }; struct BCS_DATA { uint16_t ChargingVoltage; // 充电电压测量值 (2字节, 精度0.1) uint16_t ChargingCurrent; // 充电电流测量值 (2字节, 精度0.1) union VoltageAndGroup MaxSingleCellVoltage; // 最高单体动力蓄电池电压及组号 (1字节, 精度0) uint8_t SOC; // 当前荷电状态SOC% (1字节, 精度1%) uint16_t RemainingChargeTime; // 估算剩余充电时间 (2字节, 精度1min) }; // 定义枚举类型 typedef enum { Normal = 0, High = 1, Low = 2 } StatusEnum; typedef union { uint8_t stats[2]; struct { uint8_t high_low_voltage_status:2; // 单体动力蓄电池电压过高/过低 uint8_t high_low_SOC_status:2; // 整车动力蓄电池电荷状态SOC过高/过低 uint8_t charging_overcurrent_status:2; // 动力蓄电池充电过电流 uint8_t high_temperature_status:2; // 动力蓄电池温度过高 uint8_t insulation_status:2; // 动力蓄电池绝缘状态 uint8_t output_connector_status:2; // 动力蓄电池组输出连接器链接状态 uint8_t charging_permission:2; // 充电允许 }bits; }BSM_DATA_FAULT; // 定义报文结构体 struct BSM_DATA { uint8_t highest_cell_voltage_number; // 最高单体动力蓄电池电压所在编号 uint8_t highest_battery_temperature; // 最高动力蓄电池温度 uint8_t highest_temperature_detection_point; // 最高温度检测点编号 uint8_t lowest_battery_temperature; // 最低动力蓄电池温度 uint8_t lowest_temperature_detection_point; // 最低动力蓄电池温度检测点编号 StatusEnum high_low_voltage_status; // 单体动力蓄电池电压过高/过低 StatusEnum high_low_SOC_status; // 整车动力蓄电池电荷状态SOC过高/过低 StatusEnum charging_overcurrent_status; // 动力蓄电池充电过电流 StatusEnum high_temperature_status; // 动力蓄电池温度过高 StatusEnum insulation_status; // 动力蓄电池绝缘状态 StatusEnum output_connector_status; // 动力蓄电池组输出连接器链接状态 StatusEnum charging_permission; // 充电允许 BSM_DATA_FAULT BSM_DATA_FAULT; }; typedef union { uint8_t stats[4]; struct { uint8_t SOC_Target:2; //达到所需求的SOC目标值 uint8_t Total_voltage_set_point:2; //达到总电压设定值 uint8_t Cell_voltage_set_point:2; //达到单体电压设定值 uint8_t Charging_pile_stops_actively:2; //充电机主动中止 uint8_t Fault_insulation:2; //绝缘故障 uint8_t Overtemperature_fault_output_connector:2; //输出连接器过温故障 uint8_t BMS_element_Overtemperature_fault_output_connector:2; //BMS元件,输出连接器故障 uint8_t Charging_connector_failure:2; //充电连接器故障 uint8_t High_temperature_fault_battery_pack:2; //电池组温度过高故障 uint8_t Fault_high_voltage_relay:2; //高压继电器故障 uint8_t Check_voltage_fault_point_2:2; //检测点2电压检测故障 uint8_t Other_failures:2; //其他故障 uint8_t Excessive_current:2; //电流过大 uint8_t Abnormal_voltage:2; //电压异常 }bits; }BST_DATA_FAULT; struct BST_DATA { uint8_t charge_abort_reason; // BMS中止充电原因 uint16_t charge_abort_faults; // BMS中止充电故障原因 uint8_t charge_abort_errors; // BMS中止充电错误原因 BST_DATA_FAULT BST_DATA_FAULT; }; struct BSD_DATA { uint8_t soc_abort; // 中止荷电状态SOC uint16_t min_cell_voltage; // 动力蓄电池单体最低电压 (0.01V) uint16_t max_cell_voltage; // 动力蓄电池单体最高电压 (0.01V) uint8_t min_battery_temperature; // 动力蓄电池最低温度 (-50℃) uint8_t max_battery_temperature; // 动力蓄电池最高温度 (-50℃) }; #pragma pack() struct BMD_TO_CDZ { struct BHM_DATA BHM; struct BRM_DATA BRM; struct BCP_DATA BCP; struct BRO_DATA BRO; struct BCL_DATA BCL; struct BCS_DATA BCS; struct BSM_DATA BSM; struct BST_DATA BST; struct BSD_DATA BSD; uint8_t uBatCurSOC;//当前SOC状态 struct Car_message *parenr; }; void initializeBMS_default_parameters(void); extern struct BMD_TO_CDZ BMSDefaultParameters; //获取BHM电压值 __STATIC_INLINE uint16_t GetBHM_Vol(void) { return BMSDefaultParameters.BHM.Maximum_allowable_total_charging_voltage; } //获取BRM版本 __STATIC_INLINE uint8_t GetBRM_VersionArr_0(void) { return BMSDefaultParameters.BRM.VersionNumber.fields.VersionArr[0]; } //获取BRM版本 __STATIC_INLINE uint8_t GetBRM_VersionArr_1(void) { return BMSDefaultParameters.BRM.VersionNumber.fields.VersionArr[1]; } //获取BRM版本 __STATIC_INLINE uint8_t GetBRM_VersionArr_2(void) { return BMSDefaultParameters.BRM.VersionNumber.fields.VersionArr[2]; } //BRM配置电池类型 __STATIC_INLINE enum TypeBattery GetBRM_Battery_TYPE(void) { return BMSDefaultParameters.BRM.BatteryType; } //BRM配置电池容量 Ah __STATIC_INLINE uint16_t GetBRM_RatedCapacity(void) { return BMSDefaultParameters.BRM.RatedCapacity; } //BRM配置电池电压 __STATIC_INLINE uint16_t GetBRM_RatedTotalVoltage(void) { return BMSDefaultParameters.BRM.RatedTotalVoltage; } //BCP 单体最高充电电压 __STATIC_INLINE uint16_t GetBCP_MaxChargingVoltageSingle(void) { return BMSDefaultParameters.BCP.MaxChargingVoltageSingle; } //最高允许充电电流 __STATIC_INLINE uint16_t GetBCP_MaxChargingCurrent(void) { return BMSDefaultParameters.BCP.MaxChargingCurrent; } //动力蓄电池标称总能量 __STATIC_INLINE uint16_t GetBCP_NominalTotalEnergy(void) { return BMSDefaultParameters.BCP.NominalTotalEnergy; } //最高允许充电总电压 __STATIC_INLINE uint16_t GetBCP_MaxTotalChargingVoltage(void) { return BMSDefaultParameters.BCP.MaxTotalChargingVoltage; } //最高允许温度 __STATIC_INLINE uint16_t GetBCP_MaxTemperature(void) { return BMSDefaultParameters.BCP.MaxTemperature; } //整车动力蓄电池荷电状态 __STATIC_INLINE uint16_t GetBCP_ChargeState(void) { return BMSDefaultParameters.BCP.ChargeState; } //整车动力蓄电池当前电池电压 __STATIC_INLINE uint16_t GetBCP_CurrentVoltage(void) { return BMSDefaultParameters.BCP.CurrentVoltage; } //BCL当前需求电压 __STATIC_INLINE uint16_t GetBCL_VoltageDemand(void) { return BMSDefaultParameters.BCL.VoltageDemand; } //BCP当前需求电流 __STATIC_INLINE uint16_t GetBCL_CurrentDemand(void) { return BMSDefaultParameters.BCL.CurrentDemand; } //BCP当前充电模式 __STATIC_INLINE uint16_t GetBCL_Mode(void) { return BMSDefaultParameters.BCL.Mode; } //BCS __STATIC_INLINE uint16_t GetBCS_ChargingVoltage(void) { return BMSDefaultParameters.BCS.ChargingVoltage; } //BCS __STATIC_INLINE uint16_t GetBCS_ChargingCurrent(void) { return BMSDefaultParameters.BCS.ChargingCurrent; } //BCS __STATIC_INLINE uint16_t GetBCS_MaxSingleCellVoltage(void) { return BMSDefaultParameters.BCS.MaxSingleCellVoltage.value; } //BCS __STATIC_INLINE uint16_t GetBCS_RemainingChargeTime(void) { return BMSDefaultParameters.BCS.RemainingChargeTime; } //BSM __STATIC_INLINE uint16_t GetBSM_highest_cell_voltage_number(void) { return BMSDefaultParameters.BSM.highest_cell_voltage_number; } //BSM __STATIC_INLINE uint16_t GetBSM_highest_battery_temperature(void) { return BMSDefaultParameters.BSM.highest_battery_temperature; } //BSM __STATIC_INLINE uint16_t GetBSM_highest_temperature_detection_point(void) { return BMSDefaultParameters.BSM.highest_temperature_detection_point; } //BSM __STATIC_INLINE uint16_t GetBSM_lowest_battery_temperature(void) { return BMSDefaultParameters.BSM.lowest_battery_temperature; } //BSM __STATIC_INLINE uint16_t GetBSM_lowest_temperature_detection_point(void) { return BMSDefaultParameters.BSM.lowest_temperature_detection_point; } //BSM __STATIC_INLINE uint16_t GetBSM_high_low_voltage_status(void) { return BMSDefaultParameters.BSM.high_low_voltage_status; } //BSM __STATIC_INLINE uint16_t GetBSM_high_low_SOC_status(void) { return BMSDefaultParameters.BSM.high_low_SOC_status; } //BSM __STATIC_INLINE uint16_t GetBSM_charging_overcurrent_status(void) { return BMSDefaultParameters.BSM.charging_overcurrent_status; } //BSM __STATIC_INLINE uint16_t GetBSM_high_temperature_status(void) { return BMSDefaultParameters.BSM.high_temperature_status; } //BSM __STATIC_INLINE uint16_t GetBSM_insulation_status(void) { return BMSDefaultParameters.BSM.insulation_status; } //BSM __STATIC_INLINE uint16_t GetBSM_output_connector_status(void) { return BMSDefaultParameters.BSM.output_connector_status; }//BSM __STATIC_INLINE uint16_t GetBSM_charging_permission(void) { return BMSDefaultParameters.BSM.charging_permission; } //BST __STATIC_INLINE uint16_t GetBST_charge_abort_reason(void) { return BMSDefaultParameters.BST.charge_abort_reason; } //BST __STATIC_INLINE uint16_t GetBST_charge_abort_faults(void) { return BMSDefaultParameters.BST.charge_abort_faults; } //BST __STATIC_INLINE uint16_t GetBST_charge_abort_errors(void) { return BMSDefaultParameters.BST.charge_abort_errors; } //BSD __STATIC_INLINE uint16_t GetBSD_soc_abort(void) { return BMSDefaultParameters.BSD.soc_abort; } //BSD __STATIC_INLINE uint16_t GetBSDmin_cell_voltage(void) { return BMSDefaultParameters.BSD.min_cell_voltage; } //BSD __STATIC_INLINE uint16_t GetBSDmax_cell_voltage(void) { return BMSDefaultParameters.BSD.max_cell_voltage; } //BSD __STATIC_INLINE uint16_t GetBSDmin_battery_temperature(void) { return BMSDefaultParameters.BSD.min_battery_temperature; } //BSD __STATIC_INLINE uint16_t GetBSDmax_battery_temperature(void) { return BMSDefaultParameters.BSD.max_battery_temperature; } #endif