Commit 52b40f13 authored by 李俭双's avatar 李俭双

🐞 fix:43272,43276更改故障码接收存储问题

parent 62a56ea0
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "Data_TPMS/Data_TPMS.h" #include "Data_TPMS/Data_TPMS.h"
#include "Data_Voltage/Data_Voltage.h" #include "Data_Voltage/Data_Voltage.h"
#include "FaultCode/FaultCode.h" #include "FaultCode/FaultCode.h"
#include "FaultCode/code.h"
#include "BLUETOOTH/BlueTooth.h" #include "BLUETOOTH/BlueTooth.h"
#include "BLUETOOTH/Protocol_CRC16.h" #include "BLUETOOTH/Protocol_CRC16.h"
#include "BLUETOOTH/Protocol_Lib.h" #include "BLUETOOTH/Protocol_Lib.h"
......
...@@ -13,15 +13,15 @@ void Fault_Code_Receive(uint8_t CopyData[]) ...@@ -13,15 +13,15 @@ void Fault_Code_Receive(uint8_t CopyData[])
{ {
uint8_t i = 0; uint8_t i = 0;
ECU_FaultCode_Processing_Service(); //ECU_FaultCode_Processing_Service();
} }
uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len) uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t *CodeList, uint8_t len)
{ {
uint8_t i = 0; uint8_t i = 0;
uint8_t result = 0; uint8_t result = 0;
for(i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
if(FaultCode == CodeList[i]) if (FaultCode == CodeList[i])
{ {
result = 1; result = 1;
} }
...@@ -50,7 +50,10 @@ static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len) ...@@ -50,7 +50,10 @@ static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len)
} }
} }
} }
void ECU_FaultCode_Processing_Service ( void ) uint32_t u32YZHDArray[200];
uint32_t u32YZHDArraycount = 0;
uint32_t u32YZHDCount=0;
void ECU_FaultCode_Processing_Service(void)
{ {
uint8_t DTCH1 = 0; uint8_t DTCH1 = 0;
uint8_t DTCM1 = 0; uint8_t DTCM1 = 0;
...@@ -59,15 +62,16 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -59,15 +62,16 @@ void ECU_FaultCode_Processing_Service ( void )
uint32_t DTC1 = 0; uint32_t DTC1 = 0;
uint32_t DTC2 = 0; uint32_t DTC2 = 0;
uint32_t i = 0; uint32_t i = 0;
if ( Common_Get_IG_Sts() == COMMON_POWER_ON ) if (Common_Get_IG_Sts() == COMMON_POWER_ON)
{ {
if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x402_Msg_Count) == CAN_SIG_LOST) if (CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x402_Msg_Count) == CAN_SIG_LOST)
{ {
memset (FaultCode_Data, 0, FaultCode_Number); memset(FaultCode_Data, 0, FaultCode_Number);
FaultCode_Number = 0; FaultCode_Number = 0;
} }
else else
{ {
u32YZHDCount = 0;
DTCH1 = Get_CAN_CH0_ID_402_Sig_ECU_DTCH1(); DTCH1 = Get_CAN_CH0_ID_402_Sig_ECU_DTCH1();
DTCM1 = Get_CAN_CH0_ID_402_Sig_ECU_DTCM1(); DTCM1 = Get_CAN_CH0_ID_402_Sig_ECU_DTCM1();
DTCH2 = Get_CAN_CH0_ID_402_Sig_ECU_DTCH2(); DTCH2 = Get_CAN_CH0_ID_402_Sig_ECU_DTCH2();
...@@ -80,7 +84,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -80,7 +84,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC1 |= (DTCH1 & 0xF0) >> 4 ; DTC1 |= (DTCH1 & 0xF0) >> 4;
} }
DTC1 <<= 8; DTC1 <<= 8;
if ((DTCH1 & 0xF) >= 0xA) if ((DTCH1 & 0xF) >= 0xA)
...@@ -89,7 +93,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -89,7 +93,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC1 |= DTCH1 & 0xF ; DTC1 |= DTCH1 & 0xF;
} }
DTC1 <<= 8; DTC1 <<= 8;
...@@ -99,7 +103,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -99,7 +103,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC1 |= (DTCM1 & 0xF0) >> 4 ; DTC1 |= (DTCM1 & 0xF0) >> 4;
} }
DTC1 <<= 8; DTC1 <<= 8;
if ((DTCM1 & 0xF) >= 0xA) if ((DTCM1 & 0xF) >= 0xA)
...@@ -108,7 +112,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -108,7 +112,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC1 |= DTCM1 & 0xF ; DTC1 |= DTCM1 & 0xF;
} }
if (((DTCH2 & 0xF0) >> 4) >= 0xA) if (((DTCH2 & 0xF0) >> 4) >= 0xA)
...@@ -117,7 +121,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -117,7 +121,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC2 |= (DTCH2 & 0xF0) >> 4 ; DTC2 |= (DTCH2 & 0xF0) >> 4;
} }
DTC2 <<= 8; DTC2 <<= 8;
if ((DTCH2 & 0xF) >= 0xA) if ((DTCH2 & 0xF) >= 0xA)
...@@ -126,7 +130,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -126,7 +130,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC2 |= DTCH2 & 0xF ; DTC2 |= DTCH2 & 0xF;
} }
DTC2 <<= 8; DTC2 <<= 8;
...@@ -136,7 +140,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -136,7 +140,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC2 |= (DTCM2 & 0xF0) >> 4 ; DTC2 |= (DTCM2 & 0xF0) >> 4;
} }
DTC2 <<= 8; DTC2 <<= 8;
if ((DTCM2 & 0xF) >= 0xA) if ((DTCM2 & 0xF) >= 0xA)
...@@ -145,10 +149,9 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -145,10 +149,9 @@ void ECU_FaultCode_Processing_Service ( void )
} }
else else
{ {
DTC2 |= DTCM2 & 0xF ; DTC2 |= DTCM2 & 0xF;
} }
if (DTC_Amnt_Number == 0) if (DTC_Amnt_Number == 0)
{ {
for (i = 0; i < FualtCodeMax; i++) for (i = 0; i < FualtCodeMax; i++)
...@@ -159,29 +162,29 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -159,29 +162,29 @@ void ECU_FaultCode_Processing_Service ( void )
} }
DTC_Amnt_Number_Count = 0; DTC_Amnt_Number_Count = 0;
} }
if(DTC_Amnt_Number_Count < DTC_Amnt_Number) if (DTC_Amnt_Number_Count < DTC_Amnt_Number)
{ {
if ((DTC1 != 0) && (FaultCode_Compare(DTC1, &DTC_Data_Count[0], DTC_Amnt_Number_Count) == 0)) if ((DTC1 != 0) && (FaultCode_Compare(DTC1, &DTC_Data_Count[0], DTC_Amnt_Number_Count) == 0))
{ {
DTC_Data_Count[DTC_Amnt_Number_Count] = DTC1; DTC_Data_Count[DTC_Amnt_Number_Count] = DTC1;
DTC_Amnt_Number_Count ++; DTC_Amnt_Number_Count++;
Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count); Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count);
} }
} }
if(DTC_Amnt_Number_Count < DTC_Amnt_Number) if (DTC_Amnt_Number_Count < DTC_Amnt_Number)
{ {
if ((DTC2 != 0) && (FaultCode_Compare(DTC2, &DTC_Data_Count[0], DTC_Amnt_Number_Count) == 0)) if ((DTC2 != 0) && (FaultCode_Compare(DTC2, &DTC_Data_Count[0], DTC_Amnt_Number_Count) == 0))
{ {
DTC_Data_Count[DTC_Amnt_Number_Count] = DTC2; DTC_Data_Count[DTC_Amnt_Number_Count] = DTC2;
DTC_Amnt_Number_Count ++; DTC_Amnt_Number_Count++;
Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count); Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count);
} }
} }
if(DTC_Amnt_Number_Count > DTC_Amnt_Number) if (DTC_Amnt_Number_Count > DTC_Amnt_Number)
{ {
for (i = 0; i < FualtCodeMax; i++) for (i = 0; i < FualtCodeMax; i++)
{ {
//FaultCode_Data[i] = 0; // FaultCode_Data[i] = 0;
DTC_Data_Count[i] = 0; DTC_Data_Count[i] = 0;
DTC_Data[i] = 0; DTC_Data[i] = 0;
} }
...@@ -189,7 +192,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -189,7 +192,7 @@ void ECU_FaultCode_Processing_Service ( void )
} }
if (DTC_Amnt_Number_Count == DTC_Amnt_Number) if (DTC_Amnt_Number_Count == DTC_Amnt_Number)
{ {
for(i = 0; i < DTC_Amnt_Number_Count; i++) for (i = 0; i < DTC_Amnt_Number_Count; i++)
{ {
DTC_Data[i] = DTC_Data_Count[i]; DTC_Data[i] = DTC_Data_Count[i];
DTC_Data_Count[i] = 0; DTC_Data_Count[i] = 0;
...@@ -198,21 +201,25 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -198,21 +201,25 @@ void ECU_FaultCode_Processing_Service ( void )
FaultCode_Number = DTC_Amnt_Number; FaultCode_Number = DTC_Amnt_Number;
DTC_Amnt_Number_Count = 0; DTC_Amnt_Number_Count = 0;
for(i = 0; i < FaultCode_Number; i++) for (i = 0; i < FaultCode_Number; i++)
{ {
if(FaultCode_Data[i] != DTC_Data[i]) if (FaultCode_Data[i] != DTC_Data[i])
{ {
FaultCode_Data[i] = DTC_Data[i]; FaultCode_Data[i] = DTC_Data[i];
Fault_Code_App_SortNByte(FaultCode_Data, FaultCode_Number); Fault_Code_App_SortNByte(FaultCode_Data, FaultCode_Number);
} }
} }
} }
if (u32YZHDArraycount < 200)
{
u32YZHDArray[u32YZHDArraycount++] = u32YZHDCount;
}
} }
} }
else else
{ {
memset (FaultCode_Data, 0, FaultCode_Number); memset(FaultCode_Data, 0, FaultCode_Number);
FaultCode_Number = 0; FaultCode_Number = 0;
} }
} }
...@@ -12,4 +12,5 @@ void ECU_FaultCode_Processing_Service ( void ); ...@@ -12,4 +12,5 @@ void ECU_FaultCode_Processing_Service ( void );
extern void Fault_Code_Receive(uint8_t CopyData[]); extern void Fault_Code_Receive(uint8_t CopyData[]);
static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len); static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len);
static void Fault_Code_App_Swap(uint32_t *pData1, uint32_t *pData2); static void Fault_Code_App_Swap(uint32_t *pData1, uint32_t *pData2);
extern uint32_t u32YZHDCount;
#endif #endif
#include "code.h"
static _st_Init FaultCodeInit;
static uint16_t u16FaultCodeDtcCount = 0;
static uint16_t u16FaultCodeDtcCountBack = 0;
static uint16_t u16FaultCodeDtcCounttemp = 0;
static _st_FaultCode stFaultCode[MaxFaultCode] = {0};
static _st_FaultCode stFaultCodeBack[MaxFaultCode] = {0};
static _st_FaultCode stFaultCodetemp[MaxFaultCode] = {0};
static uint8_t u8FaultCodeValid = 0;
uint32_t Get_FaultCodeDtc1(void)
{
uint32_t u16FaultCode = 0x0000;
uint8_t DTCH1 = 0;
uint8_t DTCM1 = 0;
uint32_t DTC1 = 0;
DTCH1 = Get_CAN_CH0_ID_402_Sig_ECU_DTCH1();
DTCM1 = Get_CAN_CH0_ID_402_Sig_ECU_DTCM1();
if (((DTCH1 & 0xF0) >> 4) >= 0xA)
{
DTC1 |= ((DTCH1 & 0xF0) >> 4) + 3;
}
else
{
DTC1 |= (DTCH1 & 0xF0) >> 4;
}
DTC1 <<= 8;
if ((DTCH1 & 0xF) >= 0xA)
{
DTC1 |= (DTCH1 & 0xF) + 3;
}
else
{
DTC1 |= DTCH1 & 0xF;
}
DTC1 <<= 8;
if (((DTCM1 & 0xF0) >> 4) >= 0xA)
{
DTC1 |= ((DTCM1 & 0xF0) >> 4) + 3;
}
else
{
DTC1 |= (DTCM1 & 0xF0) >> 4;
}
DTC1 <<= 8;
if ((DTCM1 & 0xF) >= 0xA)
{
DTC1 |= (DTCM1 & 0xF) + 3;
}
else
{
DTC1 |= DTCM1 & 0xF;
}
if (DTC1 == 0)
{
return 0XFFFF;
}
u16FaultCode = DTC1;
return u16FaultCode;
}
uint32_t Get_FaultCodeDtc2(void)
{
uint32_t u16FaultCode = 0x0000;
uint8_t DTCH2 = 0;
uint8_t DTCM2 = 0;
uint32_t DTC2 = 0;
DTCH2 = Get_CAN_CH0_ID_402_Sig_ECU_DTCH2();
DTCM2 = Get_CAN_CH0_ID_402_Sig_ECU_DTCM2();
if (((DTCH2 & 0xF0) >> 4) >= 0xA)
{
DTC2 |= ((DTCH2 & 0xF0) >> 4) + 3;
}
else
{
DTC2 |= (DTCH2 & 0xF0) >> 4;
}
DTC2 <<= 8;
if ((DTCH2 & 0xF) >= 0xA)
{
DTC2 |= (DTCH2 & 0xF) + 3;
}
else
{
DTC2 |= DTCH2 & 0xF;
}
DTC2 <<= 8;
if (((DTCM2 & 0xF0) >> 4) >= 0xA)
{
DTC2 |= ((DTCM2 & 0xF0) >> 4) + 3;
}
else
{
DTC2 |= (DTCM2 & 0xF0) >> 4;
}
DTC2 <<= 8;
if ((DTCM2 & 0xF) >= 0xA)
{
DTC2 |= (DTCM2 & 0xF) + 3;
}
else
{
DTC2 |= DTCM2 & 0xF;
}
if (DTC2 == 0)
{
return 0XFFFF;
}
u16FaultCode = DTC2;
return u16FaultCode;
}
uint16_t Get_FaultCodeNum(void)
{
uint16_t u16FaultCode = 0x0000;
u16FaultCode = Get_CAN_CH0_ID_402_Sig_ECU_DTCAmnt();
return u16FaultCode;
}
uint16_t Get_FaultCodeValid(void)
{
return 1;
}
/**
* @brief 故障码初始化函数
*/
void FaultCode_Init(void)
{
uint16_t i = 0;
for (i = 0; i < MaxFaultCode; i++)
{
stFaultCode[i].u16FaultCode = 0;
stFaultCode[i].u16FaultCodeCount = 0;
stFaultCodeBack[i].u16FaultCode = 0;
stFaultCodeBack[i].u16FaultCodeCount = 0;
stFaultCodetemp[i].u16FaultCode = 0;
stFaultCodetemp[i].u16FaultCodeCount = 0;
}
FaultCodeInit.callbacks[DTC1] = Get_FaultCodeDtc1;
FaultCodeInit.callbacks[DTC2] = Get_FaultCodeDtc2;
FaultCodeInit.callbacks[DTC3] = NULL;
FaultCodeInit.FaultCodeVaildCbk = Get_FaultCodeValid;
FaultCodeInit.FaultCodeNumCbk = Get_FaultCodeNum;
u16FaultCodeDtcCountBack = 0;
u8FaultCodeValid = 0;
}
/**
* @brief 查询当前故障码是否存在
* @param u32FaultCode 故障码
* @param FaultCodeGrpup 故障码组
* @param len 故障码组长度
* @return 0:存在 1:不存在 2:无效故障码不存储
*/
uint8_t FaultCode_Check(const uint32_t u32FaultCode, const _st_FaultCode *FaultCodeGrpup, const uint16_t len)
{
uint16_t i = 0;
uint8_t Result = 1;
if ((u32FaultCode == 0XFFFF) || (u32FaultCode == 0))
{
return 2;
}
if (len == 1)
{
return 1;
}
for (i = 0; i < len; i++)
{
if (u32FaultCode == FaultCodeGrpup[i].u16FaultCode)
{
Result = 0;
return Result;
}
}
return Result;
}
/**
* 添加新的故障码到故障码数组中。
* @param faultCodes 指向故障码数组的指针。
* @param count 指向当前已添加故障码数量的指针。
* @param faultCode 要添加的故障码。
* @param len 实际故障码数量,用于检测数组中是否存在当前故障码
* @note 如果故障码数组已满或者新的故障码已存在,则不添加。
*/
void AddNewFaultCode(_st_FaultCode *faultCodes, uint16_t *count, uint32_t faultCode, uint16_t len)
{
if (*count >= MaxFaultCode || FaultCode_Check(faultCode, faultCodes, len) != 1)
{
return; // 数组已满或故障码已存在,不进行添加
}
faultCodes[*count].u16FaultCode = faultCode;
(*count)++;
}
/**
* @brief 故障码服务函数
* @param Cycle 建议10ms调用 防止故障码数量过多 接收缓慢
*/
void FaultCode_Service(uint16_t Cycle)
{
uint32_t Dtc1 = 0XFFFF;
uint32_t Dtc2 = 0XFFFF;
uint32_t Dtc3 = 0XFFFF;
uint16_t FaultCodeSum = 0;
uint16_t i = 0;
uint32_t tempFaultCode = 0;
uint16_t Vaild = 0;
if (FaultCodeInit.callbacks[DTC1] != NULL)
{
Dtc1 = FaultCodeInit.callbacks[DTC1]();
}
if (FaultCodeInit.callbacks[DTC2] != NULL)
{
Dtc2 = FaultCodeInit.callbacks[DTC2]();
}
if (FaultCodeInit.callbacks[DTC3] != NULL)
{
Dtc3 = FaultCodeInit.callbacks[DTC3]();
}
if (FaultCodeInit.FaultCodeVaildCbk != NULL)
{
Vaild = FaultCodeInit.FaultCodeVaildCbk();
}
if (FaultCodeInit.FaultCodeNumCbk != NULL)
{
FaultCodeSum = FaultCodeInit.FaultCodeNumCbk();
}
if (FaultCodeSum > MaxFaultCode)
{
FaultCodeSum = MaxFaultCode;
}
if ((Vaild) && (FaultCodeSum > 0))
{
if (u16FaultCodeDtcCountBack < FaultCodeSum) /* 当前存储故障码是否小于实际故障码数量 */
{
/* 存储故障码并检查数组中是否存在 */
AddNewFaultCode(stFaultCodeBack, &u16FaultCodeDtcCountBack, Dtc1, FaultCodeSum);
AddNewFaultCode(stFaultCodeBack, &u16FaultCodeDtcCountBack, Dtc2, FaultCodeSum);
}
/* 接收故障码大于0后进行显示 */
if (u16FaultCodeDtcCountBack > 0)
{
/* 当前存储故障码等于实际故障码数量 用于实时更新故障码*/
if (u16FaultCodeDtcCountBack == FaultCodeSum)
{
u16FaultCodeDtcCountBack = 0;
}
/* 更新故障码显示 */
for (i = 0; i < FaultCodeSum; i++)
{
if (stFaultCodetemp[i].u16FaultCode != stFaultCodeBack[i].u16FaultCode)
{
stFaultCodetemp[i].u16FaultCode = stFaultCodeBack[i].u16FaultCode;
stFaultCode[i].u16FaultCode = stFaultCodetemp[i].u16FaultCode;
}
}
u8FaultCodeValid = 1;
/* 大于故障码数量的数组进行清0处理 */
for (i = FaultCodeSum; i < MaxFaultCode; i++)
{
stFaultCode[i].u16FaultCode = 0;
stFaultCodetemp[i].u16FaultCode = 0;
stFaultCodeBack[i].u16FaultCode = 0;
}
}
if (stFaultCode[0].u16FaultCode != 0XFFFF)
{
/* 故障码计时 */
if (stFaultCode[0].u16FaultCodeCount < FaultCodeCount)
{
stFaultCode[0].u16FaultCodeCount += Cycle;
}
else
{
/* 计时结束 更新位置 */
stFaultCode[0].u16FaultCodeCount = 0;
tempFaultCode = stFaultCode[0].u16FaultCode;
if (FaultCodeSum > 1)
{
for (i = 0; i < FaultCodeSum - 1; i++)
{
stFaultCode[i].u16FaultCode = stFaultCode[i + 1].u16FaultCode;
}
stFaultCode[FaultCodeSum - 1].u16FaultCode = tempFaultCode;
}
}
}
}
else
{
u8FaultCodeValid = 0;
for (i = 0; i < MaxFaultCode; i++)
{
stFaultCode[i].u16FaultCode = 0;
stFaultCode[i].u16FaultCodeCount = 0;
stFaultCodeBack[i].u16FaultCode = 0;
stFaultCodeBack[i].u16FaultCodeCount = 0;
stFaultCodetemp[i].u16FaultCode = 0;
stFaultCodetemp[i].u16FaultCodeCount = 0;
}
u16FaultCodeDtcCountBack = 0;
}
}
/**
* @brief 获取当前故障码
*/
uint32_t Get_Current_FaultCode(void)
{
return stFaultCode[0].u16FaultCode;
}
uint8_t Get_FaultCode_Valid(void)
{
return u8FaultCodeValid;
}
#ifndef CODE_H
#define CODE_H
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Application.h"
/*故障码类型A can报文轮询发送方式*/
#define FaultCodeType_A 1
#define FaultCodeType FaultCodeType_A
#define MaxFaultCode 72
#define FaultCodeCount 5000
typedef enum
{
DTC1,
DTC2,
DTC3,
NUM_FAULT_TYPES,
} FaultCodeType_Num;
typedef uint32_t (*FaultCodeCallback)(void); /* 故障码回调函数 */
typedef uint16_t (*FaultCodeNumback)(void); /* 故障码个数回调函数 */
typedef uint16_t (*FaultCodeValidback)(void); /* 故障码有效回调函数 */
typedef struct
{
uint32_t u16FaultCode; /* 故障码 */
uint16_t u16FaultCodeCount; /* 故障码总数 */
} _st_FaultCode;
typedef struct
{
FaultCodeCallback callbacks[NUM_FAULT_TYPES];
FaultCodeNumback FaultCodeNumCbk;
FaultCodeValidback FaultCodeVaildCbk;
} _st_Init;
extern void FaultCode_Service(uint16_t Cycle);
extern void FaultCode_Init(void);
extern uint32_t Get_Current_FaultCode(void);
extern uint8_t Get_FaultCode_Valid(void);
#endif
\ No newline at end of file
...@@ -3854,7 +3854,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint ...@@ -3854,7 +3854,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
else if (Get_Current_PageMenu() == Page_DTC) else if (Get_Current_PageMenu() == Page_DTC)
{ {
IC1_SEG076 = IC_SEG_OFF; IC1_SEG076 = IC_SEG_OFF;
if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x402_Msg_Count) == CAN_SIG_LOST) if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x402_Msg_Count) == CAN_SIG_LOST) //|| (Get_FaultCode_Valid() == 0))
{ {
SEG_SET_DTC_NUM(0x0B0B0B0B); SEG_SET_DTC_NUM(0x0B0B0B0B);
IC1_SEG071 = IC_SEG_OFF; IC1_SEG071 = IC_SEG_OFF;
...@@ -3867,7 +3867,53 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint ...@@ -3867,7 +3867,53 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
} }
else else
{ {
DTC_DISTimer ++; //DTC_DISTimer ++;
//IC1_SEG071 = IC_SEG_ON;
//IC1_SEG070 = IC_SEG_ON;
//IC1_SEG068 = IC_SEG_OFF;
//IC1_SEG075 = IC_SEG_OFF;
//IC1_SEG074 = IC_SEG_ON;
//IC1_SEG073 = IC_SEG_ON;
//IC1_SEG069 = IC_SEG_ON;
//if((FaultCode_Number == 0) && (FaultCode_Data[0] == 0))
//{
// SEG_SET_DTC_NUM(0);
// DTC_DISTimer = 0;
// Current_DTC_CODE = 0;
// Current_DTC_CODE_BACK = 0;
//}
//else
//{
// if(DTC_DISTimer < 100)
// {
// if (DTC_DISCount >= FaultCode_Number)
// {
// DTC_DISCount = FaultCode_Number -1;
// }
// if((FaultCode_Compare(Current_DTC_CODE, &FaultCode_Data[0], FaultCode_Number) == 0) && (FaultCode_Data[DTC_DISCount] != 0))
// {
// Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
// DTC_DISTimer = 0;
// }
// Current_DTC_CODE_BACK = Current_DTC_CODE;
// }
// else if (DTC_DISTimer >= 100)
// {
// DTC_DISCount ++ ;
// if (DTC_DISCount >= FaultCode_Number)
// {
// DTC_DISCount = 0;
// }
// Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
// DTC_DISTimer = 0;
// if((Current_DTC_CODE == Current_DTC_CODE_BACK) && (DTC_DISCount < (FaultCode_Number - 1)))
// {
// DTC_DISCount ++ ;
// Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
// }
// }
// SEG_SET_DTC_NUM(Current_DTC_CODE);
//}
IC1_SEG071 = IC_SEG_ON; IC1_SEG071 = IC_SEG_ON;
IC1_SEG070 = IC_SEG_ON; IC1_SEG070 = IC_SEG_ON;
IC1_SEG068 = IC_SEG_OFF; IC1_SEG068 = IC_SEG_OFF;
...@@ -3875,45 +3921,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint ...@@ -3875,45 +3921,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
IC1_SEG074 = IC_SEG_ON; IC1_SEG074 = IC_SEG_ON;
IC1_SEG073 = IC_SEG_ON; IC1_SEG073 = IC_SEG_ON;
IC1_SEG069 = IC_SEG_ON; IC1_SEG069 = IC_SEG_ON;
if((FaultCode_Number == 0) && (FaultCode_Data[0] == 0)) SEG_SET_DTC_NUM(Get_Current_FaultCode());
{
SEG_SET_DTC_NUM(0);
DTC_DISTimer = 0;
Current_DTC_CODE = 0;
Current_DTC_CODE_BACK = 0;
}
else
{
if(DTC_DISTimer < 100)
{
if (DTC_DISCount >= FaultCode_Number)
{
DTC_DISCount = FaultCode_Number -1;
}
if((FaultCode_Compare(Current_DTC_CODE, &FaultCode_Data[0], FaultCode_Number) == 0) && (FaultCode_Data[DTC_DISCount] != 0))
{
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
DTC_DISTimer = 0;
}
Current_DTC_CODE_BACK = Current_DTC_CODE;
}
else if (DTC_DISTimer >= 100)
{
DTC_DISCount ++ ;
if (DTC_DISCount >= FaultCode_Number)
{
DTC_DISCount = 0;
}
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
DTC_DISTimer = 0;
if((Current_DTC_CODE == Current_DTC_CODE_BACK) && (DTC_DISCount < (FaultCode_Number - 1)))
{
DTC_DISCount ++ ;
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
}
}
SEG_SET_DTC_NUM(Current_DTC_CODE);
}
} }
} }
else if (Get_Current_PageMenu() == Page_TCS) else if (Get_Current_PageMenu() == Page_TCS)
......
...@@ -90,6 +90,7 @@ static void Power_KL30_Init(void) ...@@ -90,6 +90,7 @@ static void Power_KL30_Init(void)
g_stRTCInformation.u8RTCYear = 20; g_stRTCInformation.u8RTCYear = 20;
RTE_RTC_Init(g_stRTCInformation); RTE_RTC_Init(g_stRTCInformation);
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(WAKEUP_KL15_In,Trigger_Rising); RTE_DEEPSLEEP_GPIO_Interrupt_Enable(WAKEUP_KL15_In,Trigger_Rising);
FaultCode_Init();
} }
extern uint32_t PowerIgnOffTimeLine; extern uint32_t PowerIgnOffTimeLine;
...@@ -135,6 +136,7 @@ static void Power_Wakeup_Init(void) ...@@ -135,6 +136,7 @@ static void Power_Wakeup_Init(void)
Telltales_UserInit(); Telltales_UserInit();
Data_TPMS_KL15_WAKE_UP_Init(); Data_TPMS_KL15_WAKE_UP_Init();
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(WAKEUP_KL15_In,Trigger_Rising); RTE_DEEPSLEEP_GPIO_Interrupt_Enable(WAKEUP_KL15_In,Trigger_Rising);
FaultCode_Init();
} }
static void Power_LVP_Init(void) static void Power_LVP_Init(void)
...@@ -168,6 +170,7 @@ static void Power_IG_ON_Init(void) ...@@ -168,6 +170,7 @@ static void Power_IG_ON_Init(void)
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable); CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
DFlash_init(); DFlash_init();
Data_Read_DiagPara(); Data_Read_DiagPara();
FaultCode_Init();
} }
static void Power_Sleep_Init(void) static void Power_Sleep_Init(void)
......
...@@ -38,10 +38,10 @@ void Sys_5ms_Tasks(void) ...@@ -38,10 +38,10 @@ void Sys_5ms_Tasks(void)
} }
uint8_t ljs_buf[200] = {0}; //uint8_t ljs_buf[200] = {0};
void Sys_10ms_Tasks(void) void Sys_10ms_Tasks(void)
{ {
memset(ljs_buf, 0x55, 200); //memset(ljs_buf, 0x55, 200);
Line_In_Debounce_Service(10u); Line_In_Debounce_Service(10u);
Key_Service(); Key_Service();
Data_Mileage_Write_EEPROM(); Data_Mileage_Write_EEPROM();
...@@ -53,6 +53,7 @@ void Sys_10ms_Tasks(void) ...@@ -53,6 +53,7 @@ void Sys_10ms_Tasks(void)
Protocol_Service(); Protocol_Service();
Protocol_Send_Service(); Protocol_Send_Service();
//Uart0_IntSend(ljs_buf, 200) ; //Uart0_IntSend(ljs_buf, 200) ;
FaultCode_Service(10u);
} }
void Sys_20ms_Tasks(void) void Sys_20ms_Tasks(void)
...@@ -111,6 +112,7 @@ void Sys_100ms_Tasks(void) ...@@ -111,6 +112,7 @@ void Sys_100ms_Tasks(void)
* @brief 50us中断服务 尽可能的减少中断使用 * @brief 50us中断服务 尽可能的减少中断使用
* *
*/ */
void Sys_Exact_50us_Tasks(void) void Sys_Exact_50us_Tasks(void)
{ {
static uint32_t task_1ms = 0u; static uint32_t task_1ms = 0u;
...@@ -122,5 +124,5 @@ void Sys_Exact_50us_Tasks(void) ...@@ -122,5 +124,5 @@ void Sys_Exact_50us_Tasks(void)
task_1ms =0U; task_1ms =0U;
eeprom_1ms_timeCount( ); eeprom_1ms_timeCount( );
} }
//u32YZHDCount++;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment