forked from luguangmeng/BAIYI
180 lines
4.4 KiB
C
180 lines
4.4 KiB
C
|
#ifndef __UDS_DTC_H__
|
|||
|
#define __UDS_DTC_H__
|
|||
|
|
|||
|
// #include "config.h"
|
|||
|
#include "uds_config.h"
|
|||
|
|
|||
|
|
|||
|
#define DTC_FOREACH(func)\
|
|||
|
/*01*/ func(0xC11187,BMS_COMM_LOSE) \
|
|||
|
/*02*/ func(0xC29387,VCU_COMM_LOSE) \
|
|||
|
/*03*/ func(0x911716,ECU_VOLTAGE_LOW) \
|
|||
|
/*04*/ func(0x911717,ECU_VOLTAGE_HIGH) \
|
|||
|
/*05*/ func(0xC07388,ECU_ENTER_BUSOFF) \
|
|||
|
/*06*/ func(0x1F400C,INPUT_OVERVOLTAGE) \
|
|||
|
/*07*/ func(0x1F400D,INPUT_UNDERVOLTAGE) \
|
|||
|
/*08*/ func(0x1F4000,CHARGE_TEMP_DERATE) \
|
|||
|
/*09*/ func(0x1F4001,INTER_TEMP_DERATE) \
|
|||
|
/*10*/ func(0x1F4002,INTER_OVERTEMP) \
|
|||
|
/*11*/ func(0x1F4003,CHARGE_OVERTEMP) \
|
|||
|
/*12*/ func(0x1F4004,DC_POS_RELAY_ADH) \
|
|||
|
/*13*/ func(0x1F4005,DC_NEG_RELAY_ADH) \
|
|||
|
/*14*/ func(0x1F4006,AC_POS_RELAY_ADH) \
|
|||
|
/*15*/ func(0x1F4007,AC_NEG_RELAY_ADH) \
|
|||
|
/*16*/ func(0x1F4008,HV_INTERLOCK) \
|
|||
|
/*17*/ func(0x1F4009,CC_CC2_RELAY_CTRL_INV) \
|
|||
|
/*18*/ func(0x1F400A,CP_CC1_RELAY_CTRL_INV)
|
|||
|
|
|||
|
/*19*/ /*func(0x1F400B,DCU_VOL_ABN) */
|
|||
|
|
|||
|
|
|||
|
#define GENERATE_DTC_ID(value,name) id##name ,
|
|||
|
#define GENERATE_DTC_VALUE_ARRAY(value,name) value,
|
|||
|
#define GENERATE_DTC_FAULT_FLAG(value,name) uint32_t f##name: 1;
|
|||
|
#define GENERATE_DTC_TIMER_ARRAY(value,name) uint16_t u##name;
|
|||
|
#define GENERATE_DTC_OPTION(value,name) uint32_t op##name: 1;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//DTC <20><><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD>
|
|||
|
#define DTC_ReportNumberOfDTCByStatusMask 0x01
|
|||
|
#define DTC_ReportDTCByStatusMask 0x02
|
|||
|
#define DTC_ReportDTCSnapshotIdentification 0x03
|
|||
|
#define DTC_ReportDTCSnapshotRecordByDTCNumber 0x04
|
|||
|
#define DTC_ReportDTCExtendedDataRecordByDTCNumber 0x06
|
|||
|
#define DTC_ReportSupportedDTCs 0x0A
|
|||
|
|
|||
|
//DTCStatusMask/statusOfDtc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
#define DTC_STATUS_Test_Failed 0//<2F><><EFBFBD><EFBFBD>ʧЧ
|
|||
|
#define DTC_STATUS_Test_Failed_This_Monitoring_Cycle 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ʧЧ
|
|||
|
#define DTC_STATUS_Pending_DTC 2//<2F>ȴ<EFBFBD>DTC
|
|||
|
#define DTC_STATUS_Confirmed_DTC 3//ȷ<><C8B7>DTC"
|
|||
|
#define DTC_STATUS_Test_Not_Completed_Since_Last_Clear 4//<2F>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
|||
|
#define DTC_STATUS_Test_Failed_Since_Last_Clear 5//<2F>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ
|
|||
|
#define DTC_STATUS_Test_Not_Completed_This_Monitoring_Cycle 6//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
|||
|
#define DTC_STATUS_Warning_Indicator_Requested 7//<2F><><EFBFBD><EFBFBD>ָʾλ<CABE><CEBB><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define DTC_STATUS_Support_Bit_Status ((1<<DTC_STATUS_Test_Failed) | (1<<DTC_STATUS_Confirmed_DTC))
|
|||
|
|
|||
|
//<2F><><EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1>
|
|||
|
#define DIAG_START_TIME 0 //0 MS
|
|||
|
#define DIAG_START_INIT_TIME (470 - DIAG_START_TIME) //5000 MS
|
|||
|
|
|||
|
#pragma anon_unions
|
|||
|
|
|||
|
typedef enum _DTC_ID {
|
|||
|
DTC_FOREACH(GENERATE_DTC_ID)
|
|||
|
DTC_ID_NUM,
|
|||
|
}DTC_ID;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
typedef union _DTC_Fault_Flag{
|
|||
|
uint32_t w;
|
|||
|
struct
|
|||
|
{
|
|||
|
DTC_FOREACH(GENERATE_DTC_FAULT_FLAG)
|
|||
|
}b;
|
|||
|
}DTC_Fault_Flags;
|
|||
|
|
|||
|
typedef struct _DTC_Msg_Timer{
|
|||
|
DTC_FOREACH(GENERATE_DTC_TIMER_ARRAY)
|
|||
|
}DTC_Msg_Timers;
|
|||
|
|
|||
|
typedef union _DTC_Options{
|
|||
|
uint32_t w;
|
|||
|
struct
|
|||
|
{
|
|||
|
DTC_FOREACH(GENERATE_DTC_OPTION)
|
|||
|
}b;
|
|||
|
}DTC_Options;
|
|||
|
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
ISO15031_6_DTCformat,
|
|||
|
ISO14229_1_DTCformat,
|
|||
|
SAE1939_73_DTCformat,
|
|||
|
} DTC_FORMAT_IDENTIFIE;
|
|||
|
|
|||
|
typedef union
|
|||
|
{
|
|||
|
uint16_t map;
|
|||
|
struct//С<>˶<EFBFBD>ģʽ
|
|||
|
{
|
|||
|
uint8_t DTCcountLowByte;
|
|||
|
uint8_t DTCcountHighByte;
|
|||
|
//uint8_t DTCcountLowByte;
|
|||
|
} b;
|
|||
|
} DTC_COUNT;
|
|||
|
|
|||
|
typedef union
|
|||
|
{
|
|||
|
struct {
|
|||
|
uint8_t BatVolt; //<2F><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ѹ(<28><><EFBFBD><EFBFBD>25.4V) <09><><EFBFBD><EFBFBD>0.1V
|
|||
|
uint8_t SOCH; //SOC MSB 0.1%
|
|||
|
uint8_t SOCL; //SOC LSB
|
|||
|
uint8_t DCInVolH; //ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹMSB 0.1V
|
|||
|
uint8_t DCInVolL; //ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹLSB 0.1V
|
|||
|
uint8_t GunSts; //<2F><>ǹ״̬ 0x00 :δ<><CEB4>ǹ 0x01: AC<41><43><EFBFBD><EFBFBD>ģʽ 0x02:DC<44><43><EFBFBD><EFBFBD>ģʽ
|
|||
|
uint8_t DCRealySts; //ֱ<><D6B1><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>״̬ 0x00 :δ<><CEB4><EFBFBD><EFBFBD> 0x01: <20><><EFBFBD><EFBFBD> 0x02:ճ<><D5B3>
|
|||
|
uint8_t ACRealySts; //<2F><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>״̬ 0x00 :δ<><CEB4><EFBFBD><EFBFBD> 0x01: <20><><EFBFBD><EFBFBD> 0x02:ճ<><D5B3>
|
|||
|
uint8_t CC2ResistorH; //CC2<43><32><EFBFBD><EFBFBD>MSB 0.1<EFBFBD><EFBFBD>
|
|||
|
uint8_t CC2ResistorL; //CC2<43><32><EFBFBD><EFBFBD>LSB 0.1<EFBFBD><EFBFBD>
|
|||
|
uint8_t CommSts; //<2F><>ǰͨ<C7B0><CDA8>״̬ 0x00 :<3A><><EFBFBD><EFBFBD> 0x01: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧȥͨ<C8A5><CDA8> 0x02:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧȥͨ<C8A5><CDA8>
|
|||
|
};
|
|||
|
uint8_t d8[11];
|
|||
|
}DTC_SnapshotType;
|
|||
|
|
|||
|
typedef union
|
|||
|
{
|
|||
|
struct {
|
|||
|
uint8_t FaultCounter;
|
|||
|
// uint8_t FaultCounterOfAge;
|
|||
|
// uint8_t FaultAgingCounter;
|
|||
|
};
|
|||
|
uint8_t d8[3];
|
|||
|
}DTC_ExtendedType;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
uint8_t status;
|
|||
|
uint8_t snapNumber;
|
|||
|
DTC_SnapshotType snapshot;
|
|||
|
DTC_ExtendedType extended;
|
|||
|
uint8_t crc16[2]; //У<><D0A3>
|
|||
|
} DTC_RecordDataBufType;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
DTC_RecordDataBufType recordData[DTC_ID_NUM];
|
|||
|
}DTC_StatusType;
|
|||
|
|
|||
|
typedef union
|
|||
|
{
|
|||
|
struct {
|
|||
|
uint8_t DTCLowByte;
|
|||
|
uint8_t DTCMiddleByte;
|
|||
|
uint8_t DTCHightByte;
|
|||
|
uint8_t res;
|
|||
|
};
|
|||
|
uint32_t dtc;
|
|||
|
}DTC_MaskRecordTpye;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
uint8_t DTCReportSubFunction;
|
|||
|
uint8_t DTCStatusMask;
|
|||
|
DTC_MaskRecordTpye DTCMaskRecord;
|
|||
|
uint8_t DTCRecordNumber;
|
|||
|
DTC_FORMAT_IDENTIFIE DTCFormatIdentifie;
|
|||
|
DTC_COUNT DTCcount;
|
|||
|
DTC_StatusType DTCStatus;
|
|||
|
|
|||
|
} DTC_STRUCT;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endif
|