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

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

parent bce3dc21
...@@ -8,10 +8,10 @@ st_CanMsgTxOp CAN_CH0_CanMsgTxOp; ...@@ -8,10 +8,10 @@ st_CanMsgTxOp CAN_CH0_CanMsgTxOp;
const st_CAN_SendAttribute CAN_CH0_CANSendAttr[CAN_CH0_ID_SEND_TOTAL] = 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}, {0x220ul, 50ul * 1000ul, 49ul * 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}, {0x6EEul, 100ul * 1000ul, 98ul * 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}, {0x6EFul, 100ul * 1000ul, 97ul * 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}, {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) #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}, {0x580ul, 8ul * 1000ul, 0ul * 1000ul, 0u, MSG_STD, 1u, 8u, CAN_MSG_TX_CYCLE, Can_Set_Buff_580, (void *)0},
#endif #endif
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "RTE.h" #include "RTE.h"
__align(4) __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]; uint32_t pTXBuff[CAN_TX_MSG_Block * CAN_CH0_ID_SEND_TOTAL];
static RSCAN0BusoffMonitorStruct RSCAN0Busoff; static RSCAN0BusoffMonitorStruct RSCAN0Busoff;
...@@ -26,8 +26,7 @@ void Can_Init(void) ...@@ -26,8 +26,7 @@ void Can_Init(void)
Can_Tx_Apply_Buff(); Can_Tx_Apply_Buff();
Can_RX_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);
} }
/** /**
...@@ -196,8 +195,6 @@ void Can_Tx_Apply_Buff(void) ...@@ -196,8 +195,6 @@ void Can_Tx_Apply_Buff(void)
CAN_MessageCache_DeInit(CAN0MSG14); CAN_MessageCache_DeInit(CAN0MSG14);
CAN_MessageCache_Init(CAN0MSG14, &CAN_SendMsg); CAN_MessageCache_Init(CAN0MSG14, &CAN_SendMsg);
CAN_SendMsg_Diag_Tx.Id = DIAG_ID_Tx; CAN_SendMsg_Diag_Tx.Id = DIAG_ID_Tx;
CAN_SendMsg_Diag_Tx.IDE = CAN_Id_Standard; CAN_SendMsg_Diag_Tx.IDE = CAN_Id_Standard;
CAN_SendMsg_Diag_Tx.CacheType = CAN_CacheType_Tx; CAN_SendMsg_Diag_Tx.CacheType = CAN_CacheType_Tx;
...@@ -244,7 +241,14 @@ void COM_CAN_Init(void) ...@@ -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_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); 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恢复函数 * @brief Buff恢复函数
...@@ -254,6 +258,7 @@ void Can_BusOff_Recover(uint8_t deltaTime) ...@@ -254,6 +258,7 @@ void Can_BusOff_Recover(uint8_t deltaTime)
{ {
if (get_can_busoff(CAN_CH_0) == 2) if (get_can_busoff(CAN_CH_0) == 2)
{ {
CAN_TX_Count_Init();
if (RSCAN0Busoff.Status == RSCAN0_BUS_STABLE) if (RSCAN0Busoff.Status == RSCAN0_BUS_STABLE)
{ {
RSCAN0Busoff.Status = RSCAN0_BUS_OFF_LV1; RSCAN0Busoff.Status = RSCAN0_BUS_OFF_LV1;
...@@ -262,18 +267,21 @@ void Can_BusOff_Recover(uint8_t deltaTime) ...@@ -262,18 +267,21 @@ void Can_BusOff_Recover(uint8_t deltaTime)
if (RSCAN0Busoff.Status == RSCAN0_BUS_OFF_LV1) if (RSCAN0Busoff.Status == RSCAN0_BUS_OFF_LV1)
{ {
RSCAN0Busoff.Timer++; 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.Timer = 0U;
RSCAN0Busoff.Cnt++; RSCAN0Busoff.Cnt++;
if (RSCAN0Busoff.Cnt >= 10U) if (RSCAN0Busoff.Cnt >= 10U)/**/
{ {
RSCAN0Busoff.Cnt = 0U; RSCAN0Busoff.Cnt = 0U;
RSCAN0Busoff.Status = RSCAN0_BUS_OFF_LV2; RSCAN0Busoff.Status = RSCAN0_BUS_OFF_LV2;
} }
//需调用CAN中止函数,中止所有硬件buf内要发送的数据
CAN_TX_Count_Init();
Can_QuickTimer_Init();
reset_busoff(CAN_CH_0); reset_busoff(CAN_CH_0);
} }
} }
...@@ -281,9 +289,12 @@ void Can_BusOff_Recover(uint8_t deltaTime) ...@@ -281,9 +289,12 @@ void Can_BusOff_Recover(uint8_t deltaTime)
{ {
RSCAN0Busoff.Timer++; 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; RSCAN0Busoff.Timer = 0U;
//需调用CAN中止函数,中止所有硬件buf内要发送的数据
CAN_TX_Count_Init();
Can_QuickTimer_Init();
reset_busoff(CAN_CH_0); reset_busoff(CAN_CH_0);
} }
} }
...@@ -293,7 +304,15 @@ void Can_BusOff_Recover(uint8_t deltaTime) ...@@ -293,7 +304,15 @@ void Can_BusOff_Recover(uint8_t deltaTime)
} }
else /* 总线正常,没有Bus-off发生*/ 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) ...@@ -310,12 +329,12 @@ uint8_t Get_Busoff_Status(void)
extern uint8_t Can_341_Flg; extern uint8_t Can_341_Flg;
uint8_t COM_APP_Process(st_CAN_Msg *Msg) uint8_t COM_APP_Process(st_CAN_Msg *Msg)
{ {
// Can_Write((st_CAN_Msg *)Msg); // Can_Write((st_CAN_Msg *)Msg);
// return 0; // return 0;
// } // }
// void Can_Write(st_CAN_Msg *Msg) // void Can_Write(st_CAN_Msg *Msg)
// { // {
uint32_t i = 0; uint32_t i = 0;
CanTxRxMsg CAN_SendMsg; CanTxRxMsg CAN_SendMsg;
uint8_t CAN_result = 0; uint8_t CAN_result = 0;
...@@ -341,7 +360,7 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg) ...@@ -341,7 +360,7 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg)
break; break;
case 0x450: case 0x450:
//if(Can_341_Flg == 1 || Common_GetIgnOnTime() > 2000) // if(Can_341_Flg == 1 || Common_GetIgnOnTime() > 2000)
{ {
CAN_result = CAN_Transmit(CAN0MSG13, &CAN_SendMsg); CAN_result = CAN_Transmit(CAN0MSG13, &CAN_SendMsg);
} }
...@@ -349,7 +368,7 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg) ...@@ -349,7 +368,7 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg)
break; break;
case 0x220: case 0x220:
CAN_result = CAN_Transmit(CAN0MSG10, &CAN_SendMsg); CAN_result = CAN_Transmit(CAN0MSG10, &CAN_SendMsg);
if(AliveCountTimer < 7) if (AliveCountTimer < 7)
{ {
AliveCountTimer++; AliveCountTimer++;
} }
...@@ -360,7 +379,7 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg) ...@@ -360,7 +379,7 @@ uint8_t COM_APP_Process(st_CAN_Msg *Msg)
break; break;
#if (IC_Current == TY200_080000b_ty) #if (IC_Current == TY200_080000b_ty)
case 0x580: case 0x580:
if(Get_Tpms_TX_Flag() != 0 ) if (Get_Tpms_TX_Flag() != 0)
{ {
CAN_result = CAN_Transmit(CAN0MSG14, &CAN_SendMsg); CAN_result = CAN_Transmit(CAN0MSG14, &CAN_SendMsg);
} }
......
...@@ -27,7 +27,7 @@ typedef struct ...@@ -27,7 +27,7 @@ typedef struct
uint8_t Status; uint8_t Status;
uint8_t Timer; uint8_t Timer;
uint8_t Cnt; uint8_t Cnt;
uint8_t ReportDTCCnt; uint8_t RecoverTimer;
} RSCAN0BusoffMonitorStruct; } 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