fix: Correct CAN RX interrupt to handle extended IDs and remove CAN filters
- Fixed the MCAL layer of CAN where RX interrupts were discarding extended IDs and only processing standard IDs. - Removed CAN filters from the CAN configuration to allow better reception of all messages.stable
parent
9599f1630c
commit
c9482f46bb
|
|
@ -63,10 +63,14 @@ static DL_MCAN_ConfigParams gMCAN0ConfigParams={
|
|||
.timeoutSelect = DL_MCAN_TIMEOUT_SELECT_CONT,
|
||||
.timeoutPreload = 65535,
|
||||
.timeoutCntEnable = false,
|
||||
.filterConfig.rrfs = true,
|
||||
.filterConfig.rrfe = true,
|
||||
.filterConfig.anfe = 1,
|
||||
.filterConfig.anfs = 1,
|
||||
.filterConfig.rrfs = false,
|
||||
.filterConfig.rrfe = false,
|
||||
.filterConfig.anfe = 0,
|
||||
.filterConfig.anfs = 0,
|
||||
// .filterConfig.rrfs = true,
|
||||
// .filterConfig.rrfe = true,
|
||||
// .filterConfig.anfe = 1,
|
||||
// .filterConfig.anfs = 1,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -120,20 +124,23 @@ static DL_MCAN_MsgRAMConfigParams gMCAN0MsgRAMConfigParams ={
|
|||
.rxFIFO1ElemSize = DL_MCAN_ELEM_SIZE_8BYTES,
|
||||
};
|
||||
|
||||
static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem = {
|
||||
.sfec = 0x1, // Store in Rx FIFO 0 if filter matches
|
||||
.sft = 0x11, // Disable filter, receive all IDs
|
||||
.sfid1 = 0, // These values won't be used because filtering is disabled
|
||||
.sfid2 = 0, // These values won't be used because filtering is disabled
|
||||
};
|
||||
//static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem = {
|
||||
// .sfec = 0x1, // Store in Rx FIFO 0 if filter matches
|
||||
// .sft = 0x11, // Disable filter, receive all IDs
|
||||
// .sfid1 = 0, // These values won't be used because filtering is disabled
|
||||
// .sfid2 = 0, // These values won't be used because filtering is disabled
|
||||
//};
|
||||
//
|
||||
//// Static filter element definition to disable filtering
|
||||
//static const DL_MCAN_ExtMsgIDFilterElement gMCAN0ExtFilterElem = {
|
||||
// .efid1 = 0, // These values won't be used because filtering is disabled
|
||||
// .efec = 0x0, // Disable filter element (0b000)
|
||||
// .efid2 = 0xffffffff, // These values won't be used because filtering is disabled
|
||||
// .eft = 0x3, // Set to 0b11 for disabling filtering (no specific filter applied)
|
||||
//};
|
||||
|
||||
|
||||
|
||||
// Static filter element definition to disable filtering
|
||||
static const DL_MCAN_ExtMsgIDFilterElement gMCAN0ExtFilterElem = {
|
||||
.efid1 = 0, // These values won't be used because filtering is disabled
|
||||
.efec = 0x0, // Disable filter element (0b000)
|
||||
.efid2 = 0, // These values won't be used because filtering is disabled
|
||||
.eft = 0x3, // Set to 0b11 for disabling filtering (no specific filter applied)
|
||||
};
|
||||
|
||||
static DL_MCAN_BitTimingParams gMCAN0BitTimes_500 = {
|
||||
/* Arbitration Baud Rate Pre-scaler. */
|
||||
|
|
@ -342,19 +349,16 @@ void CANFD0_IRQHandler(void)
|
|||
}
|
||||
}
|
||||
|
||||
// DL_MCAN_readMsgRam(CANFD0, DL_MCAN_MEM_TYPE_FIFO, 0, rxFS.num, &TempRxMsg);
|
||||
// DL_MCAN_writeRxFIFOAck(CANFD0, rxFS.num, rxFS.getIdx);
|
||||
|
||||
xCanIdType_t idType = ERROR;
|
||||
if (TempRxMsg.id >= 0 && TempRxMsg.id <= 0x7FF)
|
||||
uint64_t idx = 0;
|
||||
idx = TempRxMsg.id;
|
||||
uint32_t value = ((TempRxMsg.id & (uint32_t) 0x1FFC0000) >> (uint32_t) 18);
|
||||
if ((value > 0) && (value <= 0x7FF))
|
||||
{
|
||||
idType = STD_ID;
|
||||
} else if (TempRxMsg.id <= 0x1FFFFFFF)
|
||||
{
|
||||
idType = EXT_ID;
|
||||
idx = value;
|
||||
}
|
||||
|
||||
uint32_t idx = ((TempRxMsg.id & (uint32_t) 0x1FFC0000) >> (uint32_t) 18);
|
||||
|
||||
if(idx)
|
||||
{
|
||||
|
|
@ -366,13 +370,6 @@ void CANFD0_IRQHandler(void)
|
|||
}
|
||||
|
||||
b_ServiceInt = true;
|
||||
// if (rxFS.fifoFull) {
|
||||
// printf("rx fifo fill\n");
|
||||
// DL_MCAN_clearNewDataStatus(CANFD0, &statusLow); // Pass the proper structure
|
||||
// }
|
||||
//DL_MCAN_clearIntrStatus(CANFD0, IntrStatus,DL_MCAN_INTR_SRC_MCAN_LINE_1);
|
||||
// }
|
||||
// else{
|
||||
DL_MCAN_getIntrStatus(CANFD0);
|
||||
DL_MCAN_clearIntrStatus(CANFD0, IntrStatus,DL_MCAN_INTR_SRC_MCAN_LINE_1);
|
||||
}
|
||||
|
|
@ -442,8 +439,10 @@ IVEC_McalStatus_e xMCAL_MCANInit(MCAN_Regs* MCAN, xCAN_baud_t BAUD)
|
|||
/* Configure Message RAM Sections */
|
||||
DL_MCAN_msgRAMConfig(MCAN, (DL_MCAN_MsgRAMConfigParams*) &gMCAN0MsgRAMConfigParams);
|
||||
|
||||
/* Configure Standard ID filter element */
|
||||
DL_MCAN_addStdMsgIDFilter(MCAN, 0U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem);
|
||||
// /* Configure Standard ID filter element */
|
||||
// DL_MCAN_addStdMsgIDFilter(MCAN, 0U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem);
|
||||
//
|
||||
// DL_MCAN_addExtMsgIDFilter(MCAN, 0U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0ExtFilterElem);
|
||||
|
||||
|
||||
/* Set Extended ID Mask. */
|
||||
|
|
|
|||
3
main.c
3
main.c
|
|
@ -170,12 +170,9 @@ void CANDataProcess()
|
|||
int main(void)
|
||||
{
|
||||
xMCAL_McuInit();
|
||||
printf("hii\n");
|
||||
xMCAL_SYSCTL_INIT(HFXT,STANDBY0);
|
||||
xMCAL_SYSTICK_INIT(Period_1ms);
|
||||
|
||||
// Initialize the timer with the desired timeout value
|
||||
//xMCAL_TimerInit(TIMG0); // Initialize your timer instance (e.g., TIMG0)
|
||||
|
||||
xECU_UARTInit(&prvUartHandle);
|
||||
xECU_CANInit(CANFD0,BAUD_500);
|
||||
|
|
|
|||
Loading…
Reference in New Issue