|
@@ -49,7 +49,7 @@ void CANNet_Init(void)
|
|
|
CANNet_InfoRxMsgConfSA[0].infoMsgParU.B.IDE = _MCAN_IDE_EXT;
|
|
|
MCANDrv_SetMsgObj(CANNet_InfoRxMsgConfSA[0], CANNet_RecvMsgCAN2);
|
|
|
|
|
|
- CANNet_InfoRxMsgConfSA[1].infoMsgIDUI = 0x1CEF00F1UL;
|
|
|
+ CANNet_InfoRxMsgConfSA[1].infoMsgIDUI = 0x1C00ECEAUL;
|
|
|
CANNet_InfoRxMsgConfSA[1].infoMsgParU.B.CAN = 2;
|
|
|
CANNet_InfoRxMsgConfSA[1].infoMsgParU.B.MO = 4;
|
|
|
CANNet_InfoRxMsgConfSA[1].infoMsgParU.B.DIR = _MCAN_DIR_RX;
|
|
@@ -85,67 +85,17 @@ void CANNet_Init(void)
|
|
|
// CAN0接收消息处理函数 VCU
|
|
|
void CANNet_RecvMsgCAN0(MCANDrv_infoMsgS_TYPE infoMsgS)
|
|
|
{
|
|
|
- // CAN接收样例
|
|
|
- // uint8 idxIncUB, idxByteUB;
|
|
|
- // for (idxIncUB = 0; idxIncUB < 128; idxIncUB++)
|
|
|
- // {
|
|
|
- // if (infoMsgS.infoConfS.infoMsgIDUI == CANNet_InfoRxMsgConfSA[idxIncUB].infoMsgIDUI)
|
|
|
- // {
|
|
|
- // for (idxByteUB = 0; idxByteUB < 8; idxByteUB++)
|
|
|
- // {
|
|
|
- // CANNet_datRxMsgBufM[idxIncUB][idxByteUB] = infoMsgS.datMsgUBA[idxByteUB];
|
|
|
- // }
|
|
|
- // CANNet_datRxMsgBufM[idxIncUB][8]++;
|
|
|
- // }
|
|
|
- // }
|
|
|
VcuDecodeFunction(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
|
|
|
}
|
|
|
// CAN1接收消息处理函数
|
|
|
void CANNet_RecvMsgCAN1(MCANDrv_infoMsgS_TYPE infoMsgS)
|
|
|
{
|
|
|
- // CAN接收样例
|
|
|
- // uint8 idxIncUB, idxByteUB;
|
|
|
- // for (idxIncUB = 0; idxIncUB < 128; idxIncUB++)
|
|
|
- // {
|
|
|
- // if (infoMsgS.infoConfS.infoMsgIDUI == CANNet_InfoRxMsgConfSA[idxIncUB].infoMsgIDUI)
|
|
|
- // {
|
|
|
- // for (idxByteUB = 0; idxByteUB < 8; idxByteUB++)
|
|
|
- // {
|
|
|
- // CANNet_datRxMsgBufM[idxIncUB][idxByteUB] = infoMsgS.datMsgUBA[idxByteUB];
|
|
|
- // }
|
|
|
- //
|
|
|
- // CANNet_datRxMsgBufM[idxIncUB][8]++;
|
|
|
- // }
|
|
|
- // }
|
|
|
BcuDecodeFunction(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
|
|
|
}
|
|
|
/*备注,CAN2接收报文时,需要配置接收报文的MO号,如果不配置,将进入不了CAN中断*/
|
|
|
void CANNet_RecvMsgCAN2(MCANDrv_infoMsgS_TYPE infoMsgS)
|
|
|
{
|
|
|
-#ifdef _APP_RELEASE_CODE
|
|
|
Can2ProtocolDecode(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
|
|
|
-#endif
|
|
|
-#ifdef _APP_TEST_MOTOR_CODE
|
|
|
- switch (infoMsgS.infoConfS.infoMsgIDUI)
|
|
|
- {
|
|
|
- case 0x0000007E3:
|
|
|
- {
|
|
|
- MotorControlEnable = infoMsgS.datMsgUBA[0] & 0x0F;
|
|
|
- MotorControlCmd = (infoMsgS.datMsgUBA[0] & 0xF0) >> 4;
|
|
|
- MotorDebugCmd = infoMsgS.datMsgUBA[1] & 0xFF;
|
|
|
- MotorLifeTestCmd = infoMsgS.datMsgUBA[2] & 0xFF;
|
|
|
- break;
|
|
|
- }
|
|
|
- case 0x0000007E4:
|
|
|
- {
|
|
|
- LockDelay = MAX((UINT16)((infoMsgS.datMsgUBA[1] << 8) | (infoMsgS.datMsgUBA[0])), 100);
|
|
|
- RunFailedDelay = MAX((UINT16)(((infoMsgS.datMsgUBA[3] << 8) | infoMsgS.datMsgUBA[2])), 1000);
|
|
|
- break;
|
|
|
- }
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-#endif
|
|
|
}
|
|
|
//发送消息管理
|
|
|
void CAN0Net_Manage1ms(void)
|
|
@@ -211,7 +161,7 @@ void CAN2Net_Manage1ms(void)
|
|
|
MCANDrv_infoMsgS_TYPE infoMsgS;
|
|
|
static UINT32 Can2TimerCounter = 0;
|
|
|
Can2TimerCounter = Can2TimerCounter + 1;
|
|
|
-#ifdef _APP_RELEASE_CODE
|
|
|
+
|
|
|
uint8 cmdIdx = 0x00;
|
|
|
uint8 DataIdx = 0x00;
|
|
|
static uint8 AnsNum = 0x00; //应答次数
|
|
@@ -235,111 +185,4 @@ void CAN2Net_Manage1ms(void)
|
|
|
ebcd_flg_Can2SendEnbale = FALSE;
|
|
|
}
|
|
|
}
|
|
|
- else if (Can2TimerCounter % 100 == 1)
|
|
|
- {
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x1CEE00F0;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = (uint8)(ebcd_st_lockSensor | (ebcd_st_unlockSensor << 4));
|
|
|
- infoMsgS.datMsgUBA[1] = ebcd_st_pedstSensor;
|
|
|
- infoMsgS.datMsgUBA[2] = ebcd_P_airSensor;
|
|
|
- infoMsgS.datMsgUBA[3] = ebcd_flg_ebcEolDone;
|
|
|
- infoMsgS.datMsgUBA[4] = ebcd_T_plugin[0];
|
|
|
- infoMsgS.datMsgUBA[5] = ebcd_T_plugin[1];
|
|
|
- infoMsgS.datMsgUBA[6] = ebcd_T_plugin[2];
|
|
|
- infoMsgS.datMsgUBA[7] = ebcd_T_plugin[3];
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- }
|
|
|
- else if (Can2TimerCounter % 100 == 2)
|
|
|
- {
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x1CEE00F1;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = Control_Times;
|
|
|
- infoMsgS.datMsgUBA[1] = Control_Times>>8;
|
|
|
- infoMsgS.datMsgUBA[2] = Control_Times>>16;
|
|
|
- infoMsgS.datMsgUBA[3] = Control_Times>>24;
|
|
|
- infoMsgS.datMsgUBA[4] = Test_LockPressure;
|
|
|
- infoMsgS.datMsgUBA[5] = Test_LockPressure>>8;
|
|
|
- infoMsgS.datMsgUBA[6] = 0;
|
|
|
- infoMsgS.datMsgUBA[7] = 0;
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- }
|
|
|
-#endif
|
|
|
-#ifdef _APP_TEST_MOTOR_CODE
|
|
|
- if (Can2TimerCounter % 100 == 1)
|
|
|
- {
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x7F3;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = (uint8)(ebcd_st_lockSensor | (ebcd_st_unlockSensor << 4));
|
|
|
- infoMsgS.datMsgUBA[1] = MotorControlEnable;
|
|
|
- infoMsgS.datMsgUBA[2] = MotorControlCmd;
|
|
|
- infoMsgS.datMsgUBA[3] = MotorDebugCmd;
|
|
|
- infoMsgS.datMsgUBA[4] = MotorControlLockNum;
|
|
|
- infoMsgS.datMsgUBA[5] = MotorControlunLockNum;
|
|
|
- infoMsgS.datMsgUBA[6] = ebcd_P_airSensor;
|
|
|
- infoMsgS.datMsgUBA[7] = ebcd_P_airSensor >> 8;
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- }
|
|
|
- else if (Can2TimerCounter % 100 == 2)
|
|
|
- {
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x7F4;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = LockDelay;
|
|
|
- infoMsgS.datMsgUBA[1] = LockDelay >> 8;
|
|
|
- infoMsgS.datMsgUBA[2] = RunFailedDelay;
|
|
|
- infoMsgS.datMsgUBA[3] = RunFailedDelay >> 8;
|
|
|
- infoMsgS.datMsgUBA[4] = LifeTestCounter;
|
|
|
- infoMsgS.datMsgUBA[5] = LifeTestCounter >> 8;
|
|
|
- infoMsgS.datMsgUBA[6] = 0x00;
|
|
|
- infoMsgS.datMsgUBA[7] = 0x00;
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- }
|
|
|
- Can2TimerCounter = Can2TimerCounter + 1;
|
|
|
-#endif
|
|
|
-#ifdef _APP_TEST_CODE
|
|
|
- switch (CANNet_idxSchedUB)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x7F0;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = (uint8)(PressureValue >> 24);
|
|
|
- infoMsgS.datMsgUBA[1] = (uint8)(PressureValue >> 16);
|
|
|
- infoMsgS.datMsgUBA[2] = (uint8)(PressureValue >> 8);
|
|
|
- infoMsgS.datMsgUBA[3] = (uint8)(PressureValue >> 0);
|
|
|
- infoMsgS.datMsgUBA[4] = (uint8)(Distence1 >> 8);
|
|
|
- infoMsgS.datMsgUBA[5] = (uint8)(Distence1);
|
|
|
- infoMsgS.datMsgUBA[6] = (uint8)(Distence2 >> 8);
|
|
|
- infoMsgS.datMsgUBA[7] = (uint8)(Distence2);
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x7F1;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = (uint8)(Switch1);
|
|
|
- infoMsgS.datMsgUBA[1] = (uint8)(Switch2);
|
|
|
- infoMsgS.datMsgUBA[2] = 0xFF;
|
|
|
- infoMsgS.datMsgUBA[3] = 0xFF;
|
|
|
- infoMsgS.datMsgUBA[4] = (uint8)(PressureValue >> 24);
|
|
|
- infoMsgS.datMsgUBA[5] = (uint8)(PressureValue >> 16);
|
|
|
- infoMsgS.datMsgUBA[6] = (uint8)(PressureValue >> 8);
|
|
|
- infoMsgS.datMsgUBA[7] = (uint8)(PressureValue >> 0);
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- CANNet_infoMsgTxConfSA[2].infoMsgIDUI = 0x7F2;
|
|
|
- infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
|
|
|
- infoMsgS.datMsgUBA[0] = ControlState;
|
|
|
- infoMsgS.datMsgUBA[1] = 0xFF;
|
|
|
- infoMsgS.datMsgUBA[2] = 0xFF;
|
|
|
- infoMsgS.datMsgUBA[3] = 0xFF;
|
|
|
- infoMsgS.datMsgUBA[4] = (uint8)(Control_Times >> 24);
|
|
|
- infoMsgS.datMsgUBA[5] = (uint8)(Control_Times >> 16);
|
|
|
- infoMsgS.datMsgUBA[6] = (uint8)(Control_Times >> 8);
|
|
|
- infoMsgS.datMsgUBA[7] = (uint8)(Control_Times);
|
|
|
- MCANDrv_SendMsg(infoMsgS);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- CANNet_idxSchedUB = (uint16)((CANNet_idxSchedUB + 1) % 100); // 100ms一个完整循环
|
|
|
-#endif
|
|
|
}
|