Commit beb5f293 authored by 陈家乐's avatar 陈家乐

🐞 fix:52817 AliveCounter信号,仪表重新上电,第一帧发送到数据错误

parent bce3dc21
......@@ -8,10 +8,10 @@ st_CanMsgTxOp CAN_CH0_CanMsgTxOp;
const st_CAN_SendAttribute CAN_CH0_CANSendAttr[CAN_CH0_ID_SEND_TOTAL] =
{
{0x220ul, 50ul * 1000ul, 7ul * 1000ul, 0u, MSG_STD, 1u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_220, (void *)0},
{0x6EEul, 100ul * 1000ul, 8ul * 1000ul, 0u, MSG_STD, 2u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_6EE, (void *)0},
{0x6EFul, 100ul * 1000ul, 9ul * 1000ul, 0u, MSG_STD, 3u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_6EF, (void *)0},
{0x450ul, 100ul * 1000ul, 10ul * 1000ul, 0u, MSG_STD, 4u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_450, (void *)0},
{0x220ul, 50ul * 1000ul, 49ul * 1000ul, 0u, MSG_STD, 1u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_220, (void *)0},
{0x6EEul, 100ul * 1000ul, 98ul * 1000ul, 0u, MSG_STD, 2u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_6EE, (void *)0},
{0x6EFul, 100ul * 1000ul, 97ul * 1000ul, 0u, MSG_STD, 3u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_6EF, (void *)0},
{0x450ul, 100ul * 1000ul, 96ul * 1000ul, 0u, MSG_STD, 4u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_450, (void *)0},
#if (IC_Current == TY200_080000b_ty)
{0x580ul, 8ul * 1000ul, 0ul * 1000ul, 0u, MSG_STD, 1u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_580, (void *)0},
#endif
......
......@@ -6,7 +6,7 @@
#include "RTE.h"
__align(4)
uint32_t pRXBuff[CAN_RX_MSG_Block * CAN_CH0_ID_TOTAL_MAX];
uint32_t pRXBuff[CAN_RX_MSG_Block * CAN_CH0_ID_TOTAL_MAX];
uint32_t pTXBuff[CAN_TX_MSG_Block * CAN_CH0_ID_SEND_TOTAL];
static RSCAN0BusoffMonitorStruct RSCAN0Busoff;
......@@ -26,8 +26,7 @@ void Can_Init(void)
Can_Tx_Apply_Buff();
Can_RX_Apply_Buff();
RTE_GPIO_Set_Level(RTE_GPIO_PORT05_PIN02,RTE_GPIO_LEVEL_LOW);
RTE_GPIO_Set_Level(RTE_GPIO_PORT05_PIN02, RTE_GPIO_LEVEL_LOW);
}
/**
......@@ -79,7 +78,7 @@ void Can_RX_Apply_Buff(void)
CAN_RecvMsg.Interrupt = ENABLE;
CAN_MessageCache_DeInit(CAN0MSG07);
CAN_MessageCache_Init(CAN0MSG07, &CAN_RecvMsg);
CAN_MessageCache_OverWriteConfig(CAN0MSG07, ENABLE);
CAN_MessageCache_OverWriteConfig(CAN0MSG07, ENABLE);
CAN_RecvMsg.Id = 0x120;
CAN_RecvMsg.IDE = CAN_Id_Standard;
......@@ -126,12 +125,12 @@ void Can_Tx_Apply_Buff(void)
{
CanTxRxMsg CAN_SendMsg;
CanTxRxMsg CAN_SendMsg_Diag_Tx;
CAN_SendMsg.Id = 0x6EE;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
CAN_SendMsg.Id = 0x6EE;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
for (uint8_t i = 0; i < CAN_SendMsg.DLC; i++)
{
CAN_SendMsg.Data[i] = 0;
......@@ -141,11 +140,11 @@ void Can_Tx_Apply_Buff(void)
CAN_MessageCache_Init(CAN0MSG08, &CAN_SendMsg);
CAN_SendMsg.Id = 0x6EF;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
for (uint8_t i = 0; i < CAN_SendMsg.DLC; i++)
{
CAN_SendMsg.Data[i] = 0;
......@@ -155,11 +154,11 @@ void Can_Tx_Apply_Buff(void)
CAN_MessageCache_Init(CAN0MSG12, &CAN_SendMsg);
CAN_SendMsg.Id = 0x450;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
for (uint8_t i = 0; i < CAN_SendMsg.DLC; i++)
{
CAN_SendMsg.Data[i] = 0;
......@@ -169,11 +168,11 @@ void Can_Tx_Apply_Buff(void)
CAN_MessageCache_Init(CAN0MSG13, &CAN_SendMsg);
CAN_SendMsg.Id = 0x220;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
for (uint8_t i = 0; i < CAN_SendMsg.DLC; i++)
{
CAN_SendMsg.Data[i] = 0;
......@@ -183,11 +182,11 @@ void Can_Tx_Apply_Buff(void)
CAN_MessageCache_Init(CAN0MSG10, &CAN_SendMsg);
CAN_SendMsg.Id = 0x580;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
CAN_SendMsg.IDE = CAN_Id_Standard;
CAN_SendMsg.CacheType = CAN_CacheType_Tx;
CAN_SendMsg.RTR = CAN_RTR_Data;
CAN_RecvMsg.Interrupt = DISABLE;
CAN_SendMsg.DLC = 8;
for (uint8_t i = 0; i < CAN_SendMsg.DLC; i++)
{
CAN_SendMsg.Data[i] = 0;
......@@ -196,14 +195,12 @@ void Can_Tx_Apply_Buff(void)
CAN_MessageCache_DeInit(CAN0MSG14);
CAN_MessageCache_Init(CAN0MSG14, &CAN_SendMsg);
CAN_SendMsg_Diag_Tx.Id = DIAG_ID_Tx;
CAN_SendMsg_Diag_Tx.IDE = CAN_Id_Standard;
CAN_SendMsg_Diag_Tx.CacheType = CAN_CacheType_Tx;
CAN_SendMsg_Diag_Tx.RTR = CAN_RTR_Data;
CAN_SendMsg_Diag_Tx.Interrupt = DISABLE;
CAN_SendMsg_Diag_Tx.DLC = 8;
CAN_SendMsg_Diag_Tx.Id = DIAG_ID_Tx;
CAN_SendMsg_Diag_Tx.IDE = CAN_Id_Standard;
CAN_SendMsg_Diag_Tx.CacheType = CAN_CacheType_Tx;
CAN_SendMsg_Diag_Tx.RTR = CAN_RTR_Data;
CAN_SendMsg_Diag_Tx.Interrupt = DISABLE;
CAN_SendMsg_Diag_Tx.DLC = 8;
for (uint8_t i = 0; i < CAN_SendMsg_Diag_Tx.DLC; i++)
{
CAN_SendMsg_Diag_Tx.Data[i] = 0;
......@@ -222,7 +219,7 @@ void Can_Rx_Cak(CanTxRxMsg *Msg)
if ((Msg->Id == DIAG_ID_Rx_FUN) || (Msg->Id == DIAG_ID_Rx_PHY))
{
DoCAN_L_Data_Indication(Msg->Id, Msg->DLC, Msg->Data);
DoCAN_L_Data_Indication(Msg->Id, Msg->DLC, Msg->Data);
}
}
/**
......@@ -244,7 +241,14 @@ void COM_CAN_Init(void)
Can_TX_BuffInit(&CAN_CH0_CanMsgTxOp, CAN_CH0_CANSendAttr, CAN_CH0_ID_SEND_TOTAL, COM_APP_Process);
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Disable);
}
void Can_QuickTimer_Init(void)
{
uint32_t i = 0u;
for (i = 0u; i < CAN_CH0_ID_SEND_TOTAL; i++)
{
Can_Msg_TX_FastInitCycle(&CAN_CH0_CanMsgTxOp, i, CAN_CH0_CANSendAttr[i].u32MsgCycleOffset);
}
}
/**
* @brief Buff恢复函数
......@@ -254,6 +258,7 @@ void Can_BusOff_Recover(uint8_t deltaTime)
{
if (get_can_busoff(CAN_CH_0) == 2)
{
CAN_TX_Count_Init();
if (RSCAN0Busoff.Status == RSCAN0_BUS_STABLE)
{
RSCAN0Busoff.Status = RSCAN0_BUS_OFF_LV1;
......@@ -262,18 +267,21 @@ void Can_BusOff_Recover(uint8_t deltaTime)
if (RSCAN0Busoff.Status == RSCAN0_BUS_OFF_LV1)
{
RSCAN0Busoff.Timer++;
if (RSCAN0Busoff.Timer >= RSCAN0_BUS_OFF_LV1_RECOVERY_TIME / deltaTime)
if (RSCAN0Busoff.Timer >= RSCAN0_BUS_OFF_LV1_RECOVERY_TIME / deltaTime)/**/
{
RSCAN0Busoff.Timer = 0U;
RSCAN0Busoff.Cnt++;
if (RSCAN0Busoff.Cnt >= 10U)
if (RSCAN0Busoff.Cnt >= 10U)/**/
{
RSCAN0Busoff.Cnt = 0U;
RSCAN0Busoff.Status = RSCAN0_BUS_OFF_LV2;
}
//需调用CAN中止函数,中止所有硬件buf内要发送的数据
CAN_TX_Count_Init();
Can_QuickTimer_Init();
reset_busoff(CAN_CH_0);
}
}
......@@ -281,9 +289,12 @@ void Can_BusOff_Recover(uint8_t deltaTime)
{
RSCAN0Busoff.Timer++;
if (RSCAN0Busoff.Timer >= RSCAN0_BUS_OFF_LV2_RECOVERY_TIME / deltaTime)
if (RSCAN0Busoff.Timer >= RSCAN0_BUS_OFF_LV2_RECOVERY_TIME / deltaTime)/**/
{
RSCAN0Busoff.Timer = 0U;
//需调用CAN中止函数,中止所有硬件buf内要发送的数据
CAN_TX_Count_Init();
Can_QuickTimer_Init();
reset_busoff(CAN_CH_0);
}
}
......@@ -293,7 +304,15 @@ void Can_BusOff_Recover(uint8_t deltaTime)
}
else /* 总线正常,没有Bus-off发生*/
{
RSCAN0Busoff.RecoverTimer++;
if (RSCAN0Busoff.RecoverTimer >= 4)
{
RSCAN0Busoff.RecoverTimer = 0;
RSCAN0Busoff.Status = RSCAN0_BUS_STABLE;
RSCAN0Busoff.Timer = 0;
RSCAN0Busoff.Cnt = 0;
}
}
}
......@@ -310,12 +329,12 @@ uint8_t Get_Busoff_Status(void)
extern uint8_t Can_341_Flg;
uint8_t COM_APP_Process(st_CAN_Msg *Msg)
{
// Can_Write((st_CAN_Msg *)Msg);
// return 0;
// }
// Can_Write((st_CAN_Msg *)Msg);
// return 0;
// }
// void Can_Write(st_CAN_Msg *Msg)
// {
// void Can_Write(st_CAN_Msg *Msg)
// {
uint32_t i = 0;
CanTxRxMsg CAN_SendMsg;
uint8_t CAN_result = 0;
......@@ -341,15 +360,15 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg)
break;
case 0x450:
//if(Can_341_Flg == 1 || Common_GetIgnOnTime() > 2000)
{
CAN_result = CAN_Transmit(CAN0MSG13, &CAN_SendMsg);
}
// if(Can_341_Flg == 1 || Common_GetIgnOnTime() > 2000)
{
CAN_result = CAN_Transmit(CAN0MSG13, &CAN_SendMsg);
}
break;
case 0x220:
CAN_result = CAN_Transmit(CAN0MSG10, &CAN_SendMsg);
if(AliveCountTimer < 7)
if (AliveCountTimer < 7)
{
AliveCountTimer++;
}
......@@ -360,11 +379,11 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg)
break;
#if (IC_Current == TY200_080000b_ty)
case 0x580:
if(Get_Tpms_TX_Flag() != 0 )
{
CAN_result = CAN_Transmit(CAN0MSG14, &CAN_SendMsg);
}
if (Get_Tpms_TX_Flag() != 0)
{
CAN_result = CAN_Transmit(CAN0MSG14, &CAN_SendMsg);
}
break;
#endif
default:
......
......@@ -27,7 +27,7 @@ typedef struct
uint8_t Status;
uint8_t Timer;
uint8_t Cnt;
uint8_t ReportDTCCnt;
uint8_t RecoverTimer;
} RSCAN0BusoffMonitorStruct;
......
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