Initial commit: CCU621_M firmware project with BLE debug link support.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
#ifndef BMS_TASK_H
|
||||
#define BMS_TASK_H
|
||||
|
||||
#ifdef __cplusplus /*C++���뻷���¼���C����*/
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------ Exported includes(ͷ�ļ�) ----------------------*/
|
||||
#include "main.h"
|
||||
#include "bms/bms_interface.h"
|
||||
#include "bms/sae1939.h"
|
||||
|
||||
|
||||
/*------ Exported macro(�궨��) -------------------------*/
|
||||
// BMS����֡���� �궨��
|
||||
#define GB_BMS_ADDR 0xF4
|
||||
#define GB_CHARGER_ADDR 0x56
|
||||
|
||||
#define GB_BMS_PGN_CHM 0x002600
|
||||
#define GB_BMS_PGN_BHM 0x002700
|
||||
#define GB_BMS_PGN_CRM 0x000100
|
||||
#define GB_BMS_PGN_BRM 0x000200
|
||||
|
||||
#define GB_BMS_PGN_BCP 0x000600
|
||||
#define GB_BMS_PGN_CTS 0x000700
|
||||
#define GB_BMS_PGN_CML 0x000800
|
||||
#define GB_BMS_PGN_BRO 0x000900
|
||||
#define GB_BMS_PGN_CRO 0x000A00
|
||||
|
||||
#define GB_BMS_PGN_BCL 0x001000
|
||||
#define GB_BMS_PGN_BCS 0x001100
|
||||
#define GB_BMS_PGN_CCS 0x001200
|
||||
#define GB_BMS_PGN_BSM 0x001300
|
||||
#define GB_BMS_PGN_BMV 0x001500
|
||||
#define GB_BMS_PGN_BMT 0x001600
|
||||
#define GB_BMS_PGN_BSP 0x001700
|
||||
#define GB_BMS_PGN_BST 0x001900
|
||||
#define GB_BMS_PGN_CST 0x001A00
|
||||
|
||||
#define GB_BMS_PGN_BSD 0x001C00
|
||||
#define GB_BMS_PGN_CSD 0x001D00
|
||||
|
||||
#define GB_BMS_PGN_BEM 0x001E00
|
||||
#define GB_BMS_PGN_CEM 0x001F00
|
||||
|
||||
#define GB_BRM_TIMEOUT_FLAG 0x01 //bit0:BRM���ij�ʱ
|
||||
#define GB_BCP_TIMEOUT_FLAG 0x02 //bit1:BCP���ij�ʱ
|
||||
#define GB_BRO_TIMEOUT_FLAG 0x04 //bit2:BRO���ij�ʱ
|
||||
#define GB_BCS_TIMEOUT_FLAG 0x08 //bit3:BCS���ij�ʱ
|
||||
#define GB_BCL_TIMEOUT_FLAG 0x10 //bit4:BCL���ij�ʱ
|
||||
#define GB_BST_TIMEOUT_FLAG 0x20 //bit5:BST���ij�ʱ
|
||||
#define GB_BSD_TIMEOUT_FLAG 0x40 //bit6:BSD���ij�ʱ
|
||||
|
||||
//��ʱ��ʱ���� -- ��ʱ��ʹ�ã���������
|
||||
#define BMS_TIM_10MS (1*1)
|
||||
#define BMS_TIM_50MS (5*1+1)
|
||||
#define BMS_TIM_250MS (29*1)
|
||||
#define BMS_TIM_500MS (50*1)
|
||||
|
||||
#define BMS_TIM_1S ((100+11+29)*1) //���͵�һ��cem ����Ҫ250ms
|
||||
#define BMS_TIM_5S ((500+22+135)*1)
|
||||
#define BMS_TIM_10S ((1000+12+250)*1)
|
||||
#define BMS_TIM_60S ((6000+12+1498)*1)
|
||||
/*------ Exported struct(�ṹ�嶨��) --------------------*/
|
||||
|
||||
//BMS���ڶ�ʱ��־
|
||||
typedef struct
|
||||
{
|
||||
U8_T cnt50ms; //50ms
|
||||
U8_T cnt250ms; //250ms
|
||||
U8_T cnt500ms; //500ms
|
||||
|
||||
U16_T u16_global_timerCnt; //��ʱ��ʱ,��ʱ����,����ʱ���£����յ�Ŀ�����0
|
||||
U16_T u16_bcl_timerCnt; //����ͬʱ�ж�֡���Ľ����������ӳ�ʱ��ʱ������bsmʹ��global
|
||||
U16_T u16_bro_timerCnt; //�����Σ���global��¼bro_aa��60s��ʱ���øñ�����¼bro��5�볬ʱ
|
||||
|
||||
}T_BMS_TIM;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cnt50ms = 0,
|
||||
cnt250ms,
|
||||
cnt500ms,
|
||||
cnt_global,
|
||||
cnt_bcl, //BSD״̬����
|
||||
cnt_bro_aa,
|
||||
}E_BMS_TIM;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GB_BMS_STOP=0, //ֹͣ���
|
||||
|
||||
GB_BMS_HANDSHAKE_TX_CHM, //���������Σ����ͳ�������CHM���ȴ����ճ�������BHM
|
||||
//GB_BMS_HANDSHAKE_RX_BHM_OK, //���������Σ����ͳ�������CHM���ѽ��ճ������ֳɹ�BHM��ϵͳ����Ե��⣬�ȴ�����ʼ���ֱ�ʶCRM������
|
||||
|
||||
GB_BMS_HANDSHAKE_TX_CRM_00, //���ֱ�ʶ�Σ�����CRM_00���ȴ�����BMS�ͳ�����ʶ����BRM
|
||||
GB_BMS_HANDSHAKE_TX_CRM_AA, //���ֱ�ʶ�Σ����յ�BMS�ͳ�����ʶ����BRM������CRM_AA���ȴ����յ�س���������BCP
|
||||
|
||||
GB_BMS_CFG_TX_CTS_CML, //���������ýΣ����յ���س���������BCP������CTS��CML���ȴ�����BMS��ɳ��������BRO
|
||||
GB_BMS_CFG_RX_BRO_AA, //���������ýΣ����յ���س���������BRO_00������CTS��CML���ȴ�����BMS��ɳ��������BRO_AA
|
||||
GB_BMS_CFG_TX_CRO_00, //���������ýΣ�����BMS��ɳ��������BRO_AA�����ͳ����������ɱ���CRO_00���ȴ�����CRO-AA����
|
||||
GB_BMS_CFG_TX_CRO_AA, //���������ýΣ�����BMS��ɳ��������BRO�����ͳ����������ɱ���CRO_AA���ȴ����յ���ܳ��״̬BCS/��س��������BCL
|
||||
|
||||
//GB_BMS_CHARGE_RX_BCL, //���Σ������յ���ܳ��״̬BCS���ȴ����յ�س��������BCL
|
||||
GB_BMS_CHARGE_STAGE, //���Σ�����CCS���ѽ��ձ���BCS��BCL������BST/BSM(����Ƿ����쳣)/��BMV/BMT/BSP(��ѡ)
|
||||
GB_BMS_CHARGE_TX_CST, //���Σ����ͳ�����ֹ��籨��CST���ȴ�����BMS��ֹ��籨��BST��BMSͳ�Ʊ���BSD
|
||||
|
||||
GB_BMS_FINISH_RX_BSD, //�������Σ����յ�BSD�����ͳ�����ֹ��籨��CSD
|
||||
|
||||
//GB_BMS_FINISH_RX_BSD_OK, //�������Σ����յ�BSD
|
||||
//GB_BMS_FINISH_TX_CSD, //�������Σ����ͳ���ͳ�Ʊ���CSD
|
||||
|
||||
GB_BMS_TX_CEM, //�������ʹ�����
|
||||
}GB_BMS_STATE_E;
|
||||
/* BMS״̬ */
|
||||
typedef enum
|
||||
{
|
||||
BMS_STATE_NONE=0, //��ͨ�ţ�BMSͳ�Ʊ������ݲ�����
|
||||
BMS_STATE_HANDSHAKE_START_OK, //�����������
|
||||
BMS_STATE_HANDSHAKE_FAIL, //��������ʧ��
|
||||
BMS_STATE_PRECHARGE, //Ԥ���
|
||||
BMS_STATE_CHARGING, //�����
|
||||
BMS_STATE_BSM_FORBID, //����У�BSM��ʾ��ֹ���
|
||||
BMS_STATE_STOP, //ֹͣ�У�����CST
|
||||
BMS_STATE_TIMEOUT, //���ij�ʱ(CEM/BEM)
|
||||
BMS_STATE_ERR, //���ݴ���
|
||||
}BMS_STATE_E;
|
||||
typedef enum
|
||||
{
|
||||
E_BMS_STOP_NULL =0,
|
||||
|
||||
E_BMS_STOP_1000 = 1000,
|
||||
E_BMS_STOP_1001 = 1001,
|
||||
E_BMS_STOP_1011 = 1011,
|
||||
|
||||
E_BMS_STOP_15000 = 15000,
|
||||
E_BMS_STOP_15001,
|
||||
E_BMS_STOP_15002,
|
||||
E_BMS_STOP_15003,
|
||||
E_BMS_STOP_15004,
|
||||
E_BMS_STOP_15005,
|
||||
E_BMS_STOP_15006,
|
||||
E_BMS_STOP_15007,
|
||||
E_BMS_STOP_15008,
|
||||
E_BMS_STOP_15009,
|
||||
|
||||
E_BMS_STOP_15010,
|
||||
E_BMS_STOP_15011,
|
||||
E_BMS_STOP_15012,
|
||||
E_BMS_STOP_15013,
|
||||
E_BMS_STOP_15014,
|
||||
E_BMS_STOP_15015,
|
||||
E_BMS_STOP_15016,
|
||||
E_BMS_STOP_15017,
|
||||
E_BMS_STOP_15018,
|
||||
E_BMS_STOP_15019,
|
||||
|
||||
E_BMS_STOP_15020,
|
||||
E_BMS_STOP_15021,
|
||||
E_BMS_STOP_15022,
|
||||
E_BMS_STOP_15023,
|
||||
E_BMS_STOP_15024,
|
||||
E_BMS_STOP_15025,
|
||||
E_BMS_STOP_15026,
|
||||
E_BMS_STOP_15027,
|
||||
E_BMS_STOP_15028,
|
||||
E_BMS_STOP_15029,
|
||||
E_BMS_STOP_15030,
|
||||
E_BMS_STOP_15031,
|
||||
}E_BMS_STOP_INFO;
|
||||
|
||||
//BMS��
|
||||
typedef enum
|
||||
{
|
||||
BMS_2011=0, //2011�����BMS��
|
||||
BMS_2015, //2015�����BMS��
|
||||
BMS_2023, //2023�����BMS��
|
||||
BMS_PLC, //CANתPLC
|
||||
}BMS_STANDARD_E;
|
||||
/* BMSʵʱ���� */
|
||||
typedef struct
|
||||
{
|
||||
GB_BMS_STATE_E e_state; //BMS״̬����
|
||||
BMS_STATE_E e_real_state; //���� bmsʵʱ״̬ //BMS״̬
|
||||
E_BMS_STOP_INFO e_stop_info; //bmsֹͣԭ��
|
||||
BMS_STANDARD_E e_bms_standard; //BMS�汾Э������ 2011 2015
|
||||
|
||||
U8_T u8_reconn_flag; //������ǣ�0Ĭ�ϣ�1��ʼ����
|
||||
|
||||
U8_T u8_cst_send_cnt; //cst���ʹ���
|
||||
U8_T u8_csd_send_cnt; //csd���ʹ���
|
||||
U8_T u8_cem_send_cnt; //cem���ʹ���
|
||||
U8_T u8_bms_rx_flag[BMS_RECV_TYPE_NUM]; //bms�����ѽ��ձ�ʶ��0��1�� //0bhm 1brm 2bcp 3bro 4bcs 5bcl 6bsm 7bmv 8bmt 9bst 10bsd 11bem
|
||||
|
||||
U16_T u16_timeout_flag; //���ձ��ij�ʱ��� �������CEM
|
||||
U16_T u16_stoptimeflag ; //SC1ֹͣ���ͱ�־
|
||||
|
||||
//=============================BMS���������ʵ����==============================
|
||||
BMS_BHM_DATA_T t_bhm_data;
|
||||
BMS_BRM_DATA_T t_brm_data;
|
||||
BMS_BCP_DATA_T t_bcp_data;
|
||||
BMS_BSD_DATA_T t_bsd_data;
|
||||
BMS_BCL_DATA_T t_bcl_data;
|
||||
BMS_BCS_DATA_T t_bcs_data;
|
||||
BMS_BSM_DATA_T t_bsm_data;
|
||||
BMS_BMV_DATA_T t_bmv_data; //����δʹ��
|
||||
BMS_BMT_DATA_T t_bmt_data; //����δʹ��
|
||||
|
||||
BMS_BEM_DATA_U t_bem_data;
|
||||
BMS_CEM_DATA_U t_cem_data;
|
||||
BMS_BST_DATA_U t_bst_data;
|
||||
BMS_CST_DATA_U t_cst_data;
|
||||
}S_BMS_RT_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CAN_DATA_T pt_msg; //���ձ��Ĵ洢����
|
||||
DLL_DATA_T pt_dll; //SAE����������̿�������
|
||||
}S_GB_BMS_CAN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8_T u8_gunCnt; //ǹ����
|
||||
U8_T u8_gb_enable; //����ʹ��
|
||||
U8_T u8_gun_type[GUN_MAX_CNT]; //ǹ���� 0ŷ�� 1����
|
||||
|
||||
#if CAN_PLC_FLAG //ŷ�� CANתPLCʹ��
|
||||
U8_T u8_gun_linkState[GUN_MAX_CNT]; //�����ӱ�־ 0δ��ǹ 1�Ѳ�ǹ
|
||||
#endif
|
||||
|
||||
T_BMS_TIM t_bms_tim[GUN_MAX_CNT]; //bms���ڶ�ʱ��־
|
||||
S_GB_BMS_CAN s_gb_bms_can[GUN_MAX_CNT]; //BMS CAN���ͽ��սӿ�
|
||||
S_BMS_RT_DATA s_bms_rt_data[GUN_MAX_CNT]; //BMSʵʱ����
|
||||
}S_BMS_DATA;
|
||||
|
||||
|
||||
|
||||
/*------ Exported variables(��������) -------------------*/
|
||||
|
||||
/*------ Exported function prototypes ������������ -------*/
|
||||
void v_bms_task(void *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BMS_TASK_H */
|
||||
Reference in New Issue
Block a user