128 lines
4.9 KiB
C
128 lines
4.9 KiB
C
#ifndef __DIAGNOSIS_MID_H__
|
||
#define __DIAGNOSIS_MID_H__
|
||
|
||
#include "uds_config.h"
|
||
|
||
#pragma anon_unions
|
||
|
||
#define PROGRAMMING_PASS_TIMEOUT_TIME 500 //5s base:10ms
|
||
#define OTA_TIMEOUT_TIME (6) //30min base:5min
|
||
|
||
//车身信息给到uds
|
||
typedef struct {
|
||
uint8_t IgnSts : 1; //ign状态 0:OFF 1:ON
|
||
uint8_t BattLow : 1; //电瓶低压
|
||
uint8_t BattHigh : 1; //电瓶高压
|
||
uint8_t Limphome : 1; //
|
||
uint8_t InOverVoltFault : 1; //输入过压故障 0:正常 1:故障
|
||
uint8_t InUnderVoltFault : 1; //输入欠压故障 0:正常 1:故障
|
||
uint8_t ChargeTempDerateFault : 1; //充电座温度降额故障 0:正常 1:故障
|
||
uint8_t InterTempDerateFault : 1; //内部温度降额故障 0:正常 1:故障
|
||
uint8_t InterOverTempFault : 1; //内部温度过温故障 0:正常 1:故障
|
||
uint8_t ChargeOverTempFault : 1; //充电座过温故障 0:正常 1:故障
|
||
uint8_t DcPosRelayAdhFault : 1; //直流正极继电器粘连 0:正常 1:故障
|
||
uint8_t DcNegRelayAdhFault : 1; //直流负极继电器粘连 0:正常 1:故障
|
||
uint8_t AcPosRelayAdhFault : 1; //交流正极继电器粘连 0:正常 1:故障
|
||
uint8_t AcNegRelayAdhFault : 1; //交流负极继电器粘连 0:正常 1:故障
|
||
uint8_t HvInterlockFault : 1; //高压互锁故障 0:正常 1:故障
|
||
uint8_t CcCc2RelayCtrlInv : 1; //CC/CC2控制继电器控制失效 0:正常 1:故障
|
||
uint8_t CpCc1RelayCtrlInv : 1; //CC/CC2控制继电器控制失效 0:正常 1:故障
|
||
|
||
uint16_t CurrDcVolt; //当前直流电压 0.1V
|
||
uint8_t ChargeTemp; //充电座温度值 °C
|
||
uint8_t BoardTemp; //板载温度值 °C
|
||
// uint8_t OtaModeSts; //OTA 模式状态 0:not in ota 1:in transition ota 2:in ota
|
||
uint8_t BusoffCnt; //busoff计数器,进入busoff后每恢复一次就累加1。CAN总线正常后退出busoff就清零。
|
||
DTC_SnapshotType Snapshot;
|
||
}VehicleInfo2UdsType;
|
||
|
||
|
||
typedef struct {
|
||
uint8_t NcmRxEnable : 1;
|
||
uint8_t NcmTxEnable : 1;
|
||
uint8_t NmcmRxEnable : 1;
|
||
uint8_t NmcmTxEnable : 1;
|
||
uint8_t UdsOffLine : 1;
|
||
uint8_t EcuConfig;
|
||
uint8_t DCDCEnable; //0x00:ENABLE 0x01:DISABLE
|
||
uint8_t ChargeTempProtVal; //充电座温度保护值 °C 偏移-40
|
||
uint8_t BoardTempProtVal; //板载温度保护值 °C 偏移-40
|
||
uint16_t DCVoltProtVal; //直流电压保护值 0.1V
|
||
uint16_t InsulDetVoltVal; // 绝缘检测电压 0.1V
|
||
uint8_t DTCNum; //DTC个数
|
||
uint8_t DTCList[DTC_ID_NUM];
|
||
uint8_t OtaModeSts; //OTA 模式状态 0:not in ota 1:in transition ota 2:in ota
|
||
uint8_t CloseMainContactorsReq;//DCU闭合主继电器 0:close 1:open 其他:invalid
|
||
}UdsInfo2VehicleType;
|
||
|
||
|
||
|
||
extern VehicleInfo2UdsType vehicleInfo2uds;
|
||
extern UdsInfo2VehicleType udsInfo2Vehicle;
|
||
|
||
|
||
extern INT32U g_ulRand;
|
||
extern uint32_t g_ulCanStatus;
|
||
|
||
|
||
extern uint8_t UdsSelfCheckFlag;
|
||
extern uint8_t UdsCalibrationFlag;
|
||
extern uint8_t EraseFlashMemory(uint32_t addr,uint32_t length);
|
||
extern uint8_t EraseEepromMemory(uint32_t addr,uint32_t length);
|
||
|
||
extern void GenRand(void);
|
||
extern INT8U Get0x19SerDiagData(INT8U *pOut,INT8U Type,INT8U *pdata);
|
||
extern INT16U Get0x22SerDiagData(INT8U *pOut);
|
||
extern INT8U Set0x2EDidDiagData(INT8U *pIn,INT16U PLen);
|
||
extern void SaveDtcRecode(INT16U Addr,INT32U DtcCode,INT8U Status,INT8U Acccnt);
|
||
extern void CheckDtcHsCanError(void);
|
||
extern void UdsQueueCanOut(void);
|
||
extern uint8_t GenerateSID27SeedValue(uint8_t *seed);
|
||
extern uint8_t GenerateSID27KeyValue(uint8_t levelType,uint8_t *seed,uint8_t *key);
|
||
|
||
extern INT8U Set0x2FDiagData(INT8U *pIn,INT16U PLen,INT8U *pOut,INT16U *RLen);
|
||
extern INT8U Set0x31DiagData(INT8U *pIn,INT16U PLen,INT8U *pOut,INT16U *RLen);
|
||
extern INT8U Set0x36DiagData(INT8U *pIn,INT16U PLen,INT8U *pOut,INT16U *RLen);
|
||
|
||
extern uint8_t EE_Write(uint8_t *pImage, const uint8_t *pData, uint32_t Len, void (*pCbFn)(uint32_t));
|
||
extern uint8_t EE_Read(uint8_t *pImage, uint8_t **pData);
|
||
|
||
|
||
extern void SetUdsUpdataFlag(void);
|
||
extern void DTC_SignalRecover(void);
|
||
extern uint8_t ClearCurrentDTCData(uint8_t i);
|
||
extern void ClearDtc(void);
|
||
extern void IO_InputOutputRelease(void);
|
||
extern void Uds_SetMsgMonitorTimer(uint16_t msgid);
|
||
extern void SnapshotRecordNumberGet(DTC_RecordDataBufType *record_data, uint16_t *dataBuf, uint8_t *num);
|
||
|
||
extern void UdsEncryptDate_Crc32Cal_Init(void);
|
||
extern void UdsEncryptDate_Crc32Cal_Update(const u8 *pData, u32 size);
|
||
extern uint32_t UdsEncryptDate_Crc32Cal_Final(void);
|
||
extern uint16_t UdsEncryptDate_Decrypt(uint8_t *src,uint16_t size_src);
|
||
extern void UdsEncryptDate_Xor(uint8_t *src,uint16_t size_src);
|
||
|
||
bool CheckVechileStatus(void);
|
||
bool CheckIsBatteryLow(void);
|
||
bool CheckIsBatteryHigh(void);
|
||
bool CheckIsIgnON(void);
|
||
bool CheckIsIgnOff2ON(void);
|
||
bool CheckIsTurnLeft_Short2Gnd(void);
|
||
bool CheckIsTurnLeft_Openload(void);
|
||
bool CheckIsTurnLeft_Normal(void);
|
||
bool CheckIsTurnRight_Short2Gnd(void);
|
||
bool CheckIsTurnRight_Openload(void);
|
||
bool CheckIsTurnRight_Normal(void);
|
||
bool CheckIsDRL_Short2Gnd(void);
|
||
bool CheckIsDRL_Openload(void);
|
||
bool CheckIsDRL_Normal(void);
|
||
bool CheckIsPosition_Short2Gnd(void);
|
||
bool CheckIsPosition_Openload(void);
|
||
bool CheckIsPosition_Normal(void);
|
||
bool CheckIsCanBusoff(void);
|
||
bool CheckIsNM_Limphome(void);
|
||
bool CheckIsFobUnlearn(void);
|
||
bool CheckIsVinUnwrite(void);
|
||
#endif
|
||
|