CELIS/APPLICATION/CDZ/CDZ_DATA.h
lidun b61c21c648
修改任务优先级
Signed-off-by: lidun <1084178170@qq.com>
2024-03-02 09:58:11 +08:00

576 lines
15 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @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 <stdint.h>
#include <stdbool.h>
#include <string.h>
#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
{
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_message
{
uint16_t VCU_RevVehicleHVpower;
int16_t Charg_Curr;
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