|
@@ -3,7 +3,7 @@
|
|
* @Date : 2021-12-15 10:40:06
|
|
* @Date : 2021-12-15 10:40:06
|
|
* @Version : V3.0
|
|
* @Version : V3.0
|
|
* @LastEditors : ChenJie
|
|
* @LastEditors : ChenJie
|
|
- * @LastEditTime : 2022-05-09 16:20:39
|
|
|
|
|
|
+ * @LastEditTime : 2022-05-10 19:26:35
|
|
* @Description : AppFunc
|
|
* @Description : AppFunc
|
|
* @FilePath : \VehicleControl\VehicleControl\src\System\Vehicle\AppFunc.c
|
|
* @FilePath : \VehicleControl\VehicleControl\src\System\Vehicle\AppFunc.c
|
|
*/
|
|
*/
|
|
@@ -22,7 +22,6 @@ void LockAndUnlockCtrl()
|
|
{
|
|
{
|
|
static uint16 LockDelay = 0;
|
|
static uint16 LockDelay = 0;
|
|
static uint16 UnlockDelay = 0;
|
|
static uint16 UnlockDelay = 0;
|
|
- static uint8 CtrlFlg = 0;
|
|
|
|
static uint16 BleConCounter = 0;
|
|
static uint16 BleConCounter = 0;
|
|
static uint16 battSwpeModeCounter = 0;
|
|
static uint16 battSwpeModeCounter = 0;
|
|
if (ebcd_flg_ebcManCtrlEn) //手动控制使能
|
|
if (ebcd_flg_ebcManCtrlEn) //手动控制使能
|
|
@@ -36,7 +35,7 @@ void LockAndUnlockCtrl()
|
|
{
|
|
{
|
|
ManuControlTimes++;
|
|
ManuControlTimes++;
|
|
LockDelay = 0;
|
|
LockDelay = 0;
|
|
- CtrlFlg = Unlock;
|
|
|
|
|
|
+ ebcd_st_SwitchCtrlFlg = Unlock;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (ebcd_st_unlockSensor == 1) //处于解锁状态,传感器判定一个
|
|
else if (ebcd_st_unlockSensor == 1) //处于解锁状态,传感器判定一个
|
|
@@ -45,17 +44,17 @@ void LockAndUnlockCtrl()
|
|
if (UnlockDelay > UnlockDelayTime)
|
|
if (UnlockDelay > UnlockDelayTime)
|
|
{
|
|
{
|
|
UnlockDelay = 0;
|
|
UnlockDelay = 0;
|
|
- CtrlFlg = Lock;
|
|
|
|
|
|
+ ebcd_st_SwitchCtrlFlg = Lock;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (ebcd_flg_ebcManCtrlMode == 2) //控制锁紧
|
|
else if (ebcd_flg_ebcManCtrlMode == 2) //控制锁紧
|
|
{
|
|
{
|
|
- CtrlFlg = Lock;
|
|
|
|
|
|
+ ebcd_st_SwitchCtrlFlg = Lock;
|
|
}
|
|
}
|
|
else if (ebcd_flg_ebcManCtrlMode == 3) //控制解锁
|
|
else if (ebcd_flg_ebcManCtrlMode == 3) //控制解锁
|
|
{
|
|
{
|
|
- CtrlFlg = Unlock;
|
|
|
|
|
|
+ ebcd_st_SwitchCtrlFlg = Unlock;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else //正常工作模式
|
|
else //正常工作模式
|
|
@@ -131,12 +130,12 @@ void LockAndUnlockCtrl()
|
|
}
|
|
}
|
|
if (bled_flg_unlockCmdForce)
|
|
if (bled_flg_unlockCmdForce)
|
|
{
|
|
{
|
|
- CtrlFlg = Unlock;
|
|
|
|
|
|
+ ebcd_st_SwitchCtrlFlg = Unlock;
|
|
bled_flg_unlockCmdForce = 0;
|
|
bled_flg_unlockCmdForce = 0;
|
|
}
|
|
}
|
|
if (bled_flg_lockCmdForce)
|
|
if (bled_flg_lockCmdForce)
|
|
{
|
|
{
|
|
- CtrlFlg = Lock;
|
|
|
|
|
|
+ ebcd_st_SwitchCtrlFlg = Lock;
|
|
bled_flg_lockCmdForce = 0;
|
|
bled_flg_lockCmdForce = 0;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -145,7 +144,7 @@ void LockAndUnlockCtrl()
|
|
}
|
|
}
|
|
|
|
|
|
//锁紧解锁执行
|
|
//锁紧解锁执行
|
|
- if (CtrlFlg)
|
|
|
|
|
|
+ if (ebcd_st_SwitchCtrlFlg == Unlock)
|
|
{
|
|
{
|
|
UnlockCtrl();
|
|
UnlockCtrl();
|
|
}
|
|
}
|
|
@@ -219,44 +218,6 @@ void GetDIOState(void)
|
|
temp[0] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR1);
|
|
temp[0] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR1);
|
|
temp[1] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR2);
|
|
temp[1] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR2);
|
|
ebcd_st_pedstSensor = (getbit(temp[1], 0) << 1) | (getbit(temp[0], 0) << 0);
|
|
ebcd_st_pedstSensor = (getbit(temp[1], 0) << 1) | (getbit(temp[0], 0) << 0);
|
|
-
|
|
|
|
- //根据上述量得到,运动状态值
|
|
|
|
- if (ebcd_st_lockSensor == 0x0F)
|
|
|
|
- {
|
|
|
|
- ebcd_st_lockSucJug = 1;
|
|
|
|
- }
|
|
|
|
- else if (ebcd_st_lockSensor == 0x00)
|
|
|
|
- {
|
|
|
|
- ebcd_st_lockSucJug = 0;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- ebcd_st_lockSucJug = 2;
|
|
|
|
- }
|
|
|
|
- if (ebcd_st_unlockSensor == 0x0F)
|
|
|
|
- {
|
|
|
|
- ebcd_st_unlockSucJug = 1;
|
|
|
|
- }
|
|
|
|
- else if (ebcd_st_unlockSensor == 0x00)
|
|
|
|
- {
|
|
|
|
- ebcd_st_unlockSucJug = 2;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- ebcd_st_unlockSucJug = 0;
|
|
|
|
- }
|
|
|
|
- if (ebcd_st_pedstSucJug == 0x03)
|
|
|
|
- {
|
|
|
|
- ebcd_st_pedstSucJug = 1;
|
|
|
|
- }
|
|
|
|
- else if (ebcd_st_pedstSucJug == 0x00)
|
|
|
|
- {
|
|
|
|
- ebcd_st_pedstSucJug = 0;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- ebcd_st_pedstSucJug = 2;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -364,3 +325,276 @@ uint16 Look1_u32u8(uint32 u0, uint32 *bp0, uint8 *table, uint16 MaxLen)
|
|
}
|
|
}
|
|
return y;
|
|
return y;
|
|
}
|
|
}
|
|
|
|
+/**
|
|
|
|
+ * @brief : 故障诊断函数,运行时间100ms
|
|
|
|
+ * @param {*}
|
|
|
|
+ * @return {*}
|
|
|
|
+ */
|
|
|
|
+void FaultDiagnosisFunc(void)
|
|
|
|
+{
|
|
|
|
+ UINT8 ErrorNumTemp = 0, ErrRank = 0;
|
|
|
|
+ static BOOL FuncFirstRun = TRUE;
|
|
|
|
+ static BOOL sfmd_flg_Temp1Over2;
|
|
|
|
+ static BOOL sfmd_flg_Temp2Over2;
|
|
|
|
+ static BOOL sfmd_flg_Temp3Over2;
|
|
|
|
+ static BOOL sfmd_flg_Temp4Over2;
|
|
|
|
+ static BOOL sfmd_flg_Temp1Over3;
|
|
|
|
+ static BOOL sfmd_flg_Temp2Over3;
|
|
|
|
+ static BOOL sfmd_flg_Temp3Over3;
|
|
|
|
+ static BOOL sfmd_flg_Temp4Over3;
|
|
|
|
+ BOOL sfmd_flg_Temp1Openflt = FALSE;
|
|
|
|
+ BOOL sfmd_flg_Temp2Openflt = FALSE;
|
|
|
|
+ BOOL sfmd_flg_Temp3Openflt = FALSE;
|
|
|
|
+ BOOL sfmd_flg_Temp4Openflt = FALSE;
|
|
|
|
+ if (FuncFirstRun)
|
|
|
|
+ {
|
|
|
|
+ FuncFirstRun = FALSE;
|
|
|
|
+ sfmd_flg_Temp1Over2 = FALSE;
|
|
|
|
+ sfmd_flg_Temp2Over2 = FALSE;
|
|
|
|
+ sfmd_flg_Temp3Over2 = FALSE;
|
|
|
|
+ sfmd_flg_Temp4Over2 = FALSE;
|
|
|
|
+ sfmd_flg_Temp1Over3 = getbit(sfmv_Num_FltEEsave,0);
|
|
|
|
+ sfmd_flg_Temp2Over3 = getbit(sfmv_Num_FltEEsave,1);
|
|
|
|
+ sfmd_flg_Temp3Over3 = getbit(sfmv_Num_FltEEsave,2);
|
|
|
|
+ sfmd_flg_Temp4Over3 = getbit(sfmv_Num_FltEEsave,3);
|
|
|
|
+ }
|
|
|
|
+ /*锁紧与解锁诊断*/
|
|
|
|
+ if (ebcd_st_SwitchCtrlFlg == Unlock) //解锁诊断
|
|
|
|
+ {
|
|
|
|
+ if (ebcd_st_unlockSensor == 0x0F)
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_unlockSucJug = 1;
|
|
|
|
+ }
|
|
|
|
+ else if (ebcd_st_unlockSensor == 0x00)
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_unlockSucJug = 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_unlockSucJug = 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else //锁紧诊断
|
|
|
|
+ {
|
|
|
|
+ if (ebcd_st_lockSensor == 0x0F)
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_lockSucJug = 1;
|
|
|
|
+ }
|
|
|
|
+ else if (ebcd_st_lockSensor == 0x00)
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_lockSucJug = 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_lockSucJug = 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*底座到位判断*/
|
|
|
|
+ if (ebcd_st_pedstSucJug == 0x03)
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_pedstSucJug = 1;
|
|
|
|
+ }
|
|
|
|
+ else if (ebcd_st_pedstSucJug == 0x00)
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_pedstSucJug = 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ebcd_st_pedstSucJug = 2;
|
|
|
|
+ }
|
|
|
|
+ /*温度传感器开路诊断*/
|
|
|
|
+ sfmd_flg_Temp1Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[0] == 0), DiagErrFaulNum.DiagErrFaulN25, 5U);
|
|
|
|
+ sfmd_flg_Temp2Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[1] == 0), DiagErrFaulNum.DiagErrFaulN26, 5U);
|
|
|
|
+ sfmd_flg_Temp3Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[2] == 0), DiagErrFaulNum.DiagErrFaulN27, 5U);
|
|
|
|
+ sfmd_flg_Temp4Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[3] == 0), DiagErrFaulNum.DiagErrFaulN28, 5U);
|
|
|
|
+ /*温度传感器三级过温诊断*/
|
|
|
|
+ sfmd_flg_Temp1Over3 = DiagThrSystem1(1, !sfmd_flg_Temp1Openflt, ebcd_T_plugin[0], sfmd_Th_Temp1Over3Faul, sfmd_Th_Temp1Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN17, DiagErrRecoNum.DiagErrRecoN17, sfmd_flg_Temp1Over3);
|
|
|
|
+ sfmd_flg_Temp2Over3 = DiagThrSystem1(1, !sfmd_flg_Temp2Openflt, ebcd_T_plugin[1], sfmd_Th_Temp2Over3Faul, sfmd_Th_Temp2Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN18, DiagErrRecoNum.DiagErrRecoN18, sfmd_flg_Temp2Over3);
|
|
|
|
+ sfmd_flg_Temp3Over3 = DiagThrSystem1(1, !sfmd_flg_Temp3Openflt, ebcd_T_plugin[2], sfmd_Th_Temp3Over3Faul, sfmd_Th_Temp3Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN19, DiagErrRecoNum.DiagErrRecoN19, sfmd_flg_Temp3Over3);
|
|
|
|
+ sfmd_flg_Temp4Over3 = DiagThrSystem1(1, !sfmd_flg_Temp4Openflt, ebcd_T_plugin[3], sfmd_Th_Temp4Over3Faul, sfmd_Th_Temp4Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN20, DiagErrRecoNum.DiagErrRecoN20, sfmd_flg_Temp4Over3);
|
|
|
|
+ /*温度传感器二级过温诊断*/
|
|
|
|
+ sfmd_flg_Temp1Over2 = DiagThrSystem1(1, !sfmd_flg_Temp1Over3 && !sfmd_flg_Temp1Openflt, ebcd_T_plugin[0], sfmd_Th_Temp1Over2Faul, sfmd_Th_Temp1Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN9, DiagErrRecoNum.DiagErrRecoN9, sfmd_flg_Temp1Over2);
|
|
|
|
+ sfmd_flg_Temp2Over2 = DiagThrSystem1(1, !sfmd_flg_Temp2Over3 && !sfmd_flg_Temp2Openflt, ebcd_T_plugin[1], sfmd_Th_Temp2Over2Faul, sfmd_Th_Temp2Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN10, DiagErrRecoNum.DiagErrRecoN10, sfmd_flg_Temp2Over2);
|
|
|
|
+ sfmd_flg_Temp3Over2 = DiagThrSystem1(1, !sfmd_flg_Temp3Over3 && !sfmd_flg_Temp3Openflt, ebcd_T_plugin[2], sfmd_Th_Temp3Over2Faul, sfmd_Th_Temp3Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN11, DiagErrRecoNum.DiagErrRecoN11, sfmd_flg_Temp3Over2);
|
|
|
|
+ sfmd_flg_Temp4Over2 = DiagThrSystem1(1, !sfmd_flg_Temp4Over3 && !sfmd_flg_Temp4Openflt, ebcd_T_plugin[3], sfmd_Th_Temp4Over2Faul, sfmd_Th_Temp4Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN12, DiagErrRecoNum.DiagErrRecoN12, sfmd_flg_Temp4Over2);
|
|
|
|
+
|
|
|
|
+ sfmv_Num_FltEEsave = ((sfmd_flg_Temp4Over3&0x01)<<3)|((sfmd_flg_Temp3Over3&0x01)<<2)|((sfmd_flg_Temp2Over3&0x01)<<1)|(sfmd_flg_Temp1Over3);
|
|
|
|
+ /*故障代码写入*/
|
|
|
|
+ if (sfmd_flg_Temp1Openflt)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 25;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp2Openflt)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 26;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp3Openflt)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 27;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp4Openflt)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 28;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp1Over3)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 17;
|
|
|
|
+ ErrRank = 3;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp2Over3)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 18;
|
|
|
|
+ ErrRank = 3;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp3Over3)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 19;
|
|
|
|
+ ErrRank = 3;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp4Over3)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 20;
|
|
|
|
+ ErrRank = 3;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp1Over2)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 9;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp2Over2)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 10;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp3Over2)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 11;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+ if (sfmd_flg_Temp4Over2)
|
|
|
|
+ {
|
|
|
|
+ ErrorNumTemp = 12;
|
|
|
|
+ ErrRank = 2;
|
|
|
|
+ PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * @brief : 故障判断函数
|
|
|
|
+ * @param {BOOL} Enable 使能状态
|
|
|
|
+ * @param {BOOL} Input 判断输入
|
|
|
|
+ * @param {UINT16} *N 判断次数累计
|
|
|
|
+ * @param {UINT16} Thr 判断次数阈值
|
|
|
|
+ * @return {*}
|
|
|
|
+ */
|
|
|
|
+BOOL JudgeTimeSystem(BOOL Enable, BOOL Input, UINT8 *N, UINT8 Thr)
|
|
|
|
+{
|
|
|
|
+ BOOL Flg = FALSE;
|
|
|
|
+ if (Input && Enable)
|
|
|
|
+ {
|
|
|
|
+ *N = (*N + 1) > 2008 ? 2008 : (*N + 1);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *N = 0;
|
|
|
|
+ }
|
|
|
|
+ if (*N > Thr && Enable)
|
|
|
|
+ {
|
|
|
|
+ Flg = TRUE;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Flg = FALSE;
|
|
|
|
+ }
|
|
|
|
+ return Flg;
|
|
|
|
+}
|
|
|
|
+BOOL DiagThrSystem1(BOOL Enable, BOOL precondition, UINT16 Input, UINT16 fltThr, UINT16 recThr, UINT16 fltNumThr, UINT16 recNumThr, UINT16 *fltNum, UINT16 *recNum, UINT8 *fitFlg)
|
|
|
|
+{
|
|
|
|
+ if (Enable && precondition && Input > fltThr)
|
|
|
|
+ {
|
|
|
|
+ *fltNum = (*fltNum + 1) > 20000 ? 20000 : (*fltNum + 1);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *fltNum = 0;
|
|
|
|
+ }
|
|
|
|
+ if (Enable && precondition && Input < recThr)
|
|
|
|
+ {
|
|
|
|
+ *recNum = (*recNum + 1) > 20000 ? 20000 : (*recNum + 1);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *recNum = 0;
|
|
|
|
+ }
|
|
|
|
+ if ((*fltNum > fltNumThr || (*fitFlg && *recNum < recNumThr)) && precondition)
|
|
|
|
+ {
|
|
|
|
+ *fitFlg = TRUE;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *fitFlg = FALSE;
|
|
|
|
+ }
|
|
|
|
+ return *fitFlg;
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * @brief : 获取故障码函数,从故障数组中获取故障码,并将之前的故障码向前移动
|
|
|
|
+ * @param {UINT16} *ErrorArray
|
|
|
|
+ * @param {UINT8} Errorlen
|
|
|
|
+ * @return {*}
|
|
|
|
+ */
|
|
|
|
+UINT16 GetErrorNum(UINT16 *ErrorArray, UINT8 Errorlen)
|
|
|
|
+{
|
|
|
|
+ UINT16 OutNum;
|
|
|
|
+ OutNum = *(ErrorArray);
|
|
|
|
+ for (UINT8 i = 0; i < Errorlen - 1; i++)
|
|
|
|
+ {
|
|
|
|
+ *(ErrorArray + i) = *(ErrorArray + i + 1);
|
|
|
|
+ if (*(ErrorArray + i + 1) == 0)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return OutNum;
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * @brief : 故障码注入函数,将故障码写入到故障数组中,如果存在则不写入,如果存在则不写入
|
|
|
|
+ * @param {UINT16} *ErrorArray
|
|
|
|
+ * @param {UINT8} Errorlen
|
|
|
|
+ * @param {UINT16} ErrorNum
|
|
|
|
+ * @return {*}
|
|
|
|
+ */
|
|
|
|
+UINT8 PutErrorNum(UINT16 *ErrorArray, UINT8 Errorlen, UINT16 ErrorNum)
|
|
|
|
+{
|
|
|
|
+ for (UINT8 i = 0; i < Errorlen; i++)
|
|
|
|
+ {
|
|
|
|
+ if (*(ErrorArray + i) == 0)
|
|
|
|
+ {
|
|
|
|
+ *(ErrorArray + i) = ErrorNum;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (*(ErrorArray + i) == ErrorNum)
|
|
|
|
+ {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 2;
|
|
|
|
+}
|