fix: add bus ack error handling

- Add FC instead of 100% soc
stable
heezes 2024-11-18 12:16:36 +05:30
parent 3d3b39960e
commit a3ac0f2a1a
4 changed files with 30 additions and 7 deletions

View File

@ -67,4 +67,4 @@ IVEC_EcuCommonErr_e xECU_CANDeInit(MCAN_Regs* MCAN);
IVEC_EcuCommonErr_e xECU_WriteDataOverCAN(uint8_t* pucBuf, uint32_t ulId, int retCode, uint32_t BufNum); IVEC_EcuCommonErr_e xECU_WriteDataOverCAN(uint8_t* pucBuf, uint32_t ulId, int retCode, uint32_t BufNum);
IVEC_EcuCommonErr_e xECU_CANGetData(can_buff_t *xBuff); IVEC_EcuCommonErr_e xECU_CANGetData(can_buff_t *xBuff);
IVEC_EcuCommonErr_e xECU_CanReInit(MCAN_Regs* MCAN,uint16_t speed); IVEC_EcuCommonErr_e xECU_CanReInit(MCAN_Regs* MCAN,uint16_t speed);
IVEC_EcuCommonErr_e xECU_GetCanStatus(MCAN_Regs* MCAN, uint16_t speed);

View File

@ -97,3 +97,9 @@ IVEC_EcuCommonErr_e xECU_CANDeInit(MCAN_Regs* MCAN)
return l_xFuncStatus; return l_xFuncStatus;
} }
IVEC_EcuCommonErr_e xECU_GetCanStatus(MCAN_Regs* MCAN, uint16_t speed)
{
char l_ucErrorString[32] = {0};
if( xMCAL_getMCAN_ErrorStatus(&l_ucErrorString) == IVEC_MCAL_STATUS_ERROR )
xECU_CanReInit(MCAN, speed);
}

View File

@ -103,9 +103,23 @@ void vRTE_MatlabRun(void)
tm1650_showDot(TM_1650_DIG_2,false); tm1650_showDot(TM_1650_DIG_2,false);
tm1650_showDot(TM_1650_DIG_3,false); tm1650_showDot(TM_1650_DIG_3,false);
tm1650_showNum(TM_1650_DIG_3, socTouchDisplay_Y.op_u8OnesPlace); if( socTouchDisplay_Y.op_u8HundredsPlace == 1 && \
tm1650_showNum(TM_1650_DIG_2, socTouchDisplay_Y.op_u8TensPlace); socTouchDisplay_Y.op_u8TensPlace == 0 && \
tm1650_showNum(TM_1650_DIG_1, socTouchDisplay_Y.op_u8HundredsPlace); socTouchDisplay_Y.op_u8OnesPlace == 0)
{
char l_cData = 'F';
tm1650_showAlphabet(TM_1650_DIG_2, (char*)&l_cData);
l_cData = 'C';
tm1650_showAlphabet(TM_1650_DIG_3, (char*)&l_cData);
}
else
{
tm1650_showNum(TM_1650_DIG_3, socTouchDisplay_Y.op_u8OnesPlace);
tm1650_showNum(TM_1650_DIG_2, socTouchDisplay_Y.op_u8TensPlace);
}
// tm1650_showNum(TM_1650_DIG_1, socTouchDisplay_Y.op_u8HundredsPlace);
} }
if( socTouchDisplay_Y.op_bErrorStatus ) if( socTouchDisplay_Y.op_bErrorStatus )
{ {
@ -124,7 +138,6 @@ void vRTE_MatlabRun(void)
{ {
tm1650_displaySwitch(TM_1650_Screen_OFF); tm1650_displaySwitch(TM_1650_Screen_OFF);
} }
} }
void vRTE_InitUARTCANEcho(void) void vRTE_InitUARTCANEcho(void)
@ -163,7 +176,9 @@ void vRTE_UARTDataProcess(void)
else if (mode == 100) else if (mode == 100)
{ {
g_u32CanId = baudrate; g_u32CanId = baudrate;
return;
} }
vMCAL_DelayTicks(100); vMCAL_DelayTicks(100);
vECU_InitiateUartToCanTransmit(&g_xUartHandle, 0x01, g_pu8Buf, 0); vECU_InitiateUartToCanTransmit(&g_xUartHandle, 0x01, g_pu8Buf, 0);
} }
@ -176,8 +191,8 @@ void vRTE_UARTDataProcess(void)
xECU_WriteDataOverCAN(&g_pu8Buf[PKT_HEADER], ulId, retCode, __gprv_u8Buf); xECU_WriteDataOverCAN(&g_pu8Buf[PKT_HEADER], ulId, retCode, __gprv_u8Buf);
} }
} }
} }
void vRTE_CANDataProcess(void) void vRTE_CANDataProcess(void)
{ {
can_buff_t xBuff = { 0x00 }; can_buff_t xBuff = { 0x00 };
@ -186,7 +201,9 @@ void vRTE_CANDataProcess(void)
{ {
if( (xBuff.id == 0x16) && (xBuff.data[0] = 'V') && \ if( (xBuff.id == 0x16) && (xBuff.data[0] = 'V') && \
(xBuff.data[1] == 'E') && (xBuff.data[2] == 'C')) (xBuff.data[1] == 'E') && (xBuff.data[2] == 'C'))
{
xMCAL_SoftReset(); xMCAL_SoftReset();
}
vECU_InitiateUartToCanTransmit(&g_xUartHandle, (uint32_t)xBuff.id, (uint8_t*)&xBuff.data[0], (uint8_t)xBuff.length); vECU_InitiateUartToCanTransmit(&g_xUartHandle, (uint32_t)xBuff.id, (uint8_t*)&xBuff.data[0], (uint8_t)xBuff.length);
socTouchDisplay_U.Input[__gprv_u8Idx].ID = xBuff.id; socTouchDisplay_U.Input[__gprv_u8Idx].ID = xBuff.id;
socTouchDisplay_U.Input[__gprv_u8Idx].Length = xBuff.length; socTouchDisplay_U.Input[__gprv_u8Idx].Length = xBuff.length;
@ -197,4 +214,5 @@ void vRTE_CANDataProcess(void)
else else
break; break;
} }
xECU_GetCanStatus(CANFD0, g_u16CanSpeed);
} }

1
main.c
View File

@ -21,7 +21,6 @@ void vMCAL_TimerCallback(void)
{ {
vRTE_MatlabRun(); vRTE_MatlabRun();
DL_TimerA_clearInterruptStatus(TIMER_1_INST, GPTIMER_CPU_INT_IMASK_Z_SET); DL_TimerA_clearInterruptStatus(TIMER_1_INST, GPTIMER_CPU_INT_IMASK_Z_SET);
// DL_GPIO_togglePins(GPIOB, DL_GPIO_PIN_17);
} }
static void __prv_TimerConfig(void) static void __prv_TimerConfig(void)