48 boolean result =
FALSE;
52 stat.U = hwObj->STAT.U;
54 if ((stat.B.TXRQ != 0) && (stat.B.NEWDAT != 0))
83 hwObj->CTR.U = 0x0000FFFFUL;
85 hwObj->FCR.U = 0x00000000UL;
86 hwObj->FGPR.U = 0x00000000UL;
87 hwObj->IPR.U = 0x00000000UL;
88 hwObj->AMR.U = 0x3FFFFFFFUL;
89 hwObj->DATAL.U = 0x00000000UL;
90 hwObj->DATAH.U = 0x00000000UL;
91 hwObj->AR.U = 0x00000000UL;
101 msg->
data[0] = hwObj->DATAL.U;
102 msg->
data[1] = hwObj->DATAH.U;
114 uint32 index = mcan->MSID[msgObjGroup].U;
119 mcan->MSPND[msgObjGroup].U = ~(1UL << index);
120 msgObjId = index + (msgObjGroup << 5);
131 status.
U = hwObj->STAT.U;
139 uint32 shift = (1U << flag);
141 return (hwObj->STAT.U & shift) ?
TRUE :
FALSE;
150 if (hwObj->STAT.B.NEWDAT != 0)
152 Ifx_CAN_MO_STAT stat;
153 IfxMultican_MsgObj_doReadMessage(hwObj, msg);
156 if (stat.B.RXUPD != 0)
160 else if (stat.B.NEWDAT != 0)
162 Ifx_CAN_MO_STAT stat2;
165 IfxMultican_MsgObj_doReadMessage(hwObj, msg);
169 if ((stat2.B.NEWDAT == 0) && (stat2.B.RXUPD == 0))
182 if (stat.B.MSGLST != 0)
201 if (hwObj->STAT.B.TXRQ)
211 hwObj->DATAL.U = msg->
data[0];
212 hwObj->DATAH.U = msg->
data[1];
250 hwObj->CTR.U = ctr.U;
252 hwObj->AMR.B.AM = accMask << ((extend != 0) ? 0 : 18);
253 hwObj->AR.B.IDE = (
id << ((extend != 0) ? 0 : 18)) | (extend << 29);
257 hwObj->CTR.U = ctr.U;
266 ctr.U = 1U << (flag + 16);
268 hwObj->CTR.U = ctr.U;
274 hwNode->CR.U = 0x00000001;
275 hwNode->SR.U = 0x00000000;
276 hwNode->IPR.U = 0x00000000;
277 hwNode->PCR.U = 0x00000000;
278 hwNode->BTR.U = 0x00000000;
279 hwNode->ECNT.U = 0x00600000;
280 hwNode->FCR.U = 0x00000000;
287 hwNode->PCR.B.RXSEL = rxd->
select;
306 boolean busOffState = hwNode->SR.B.BOFF;
307 boolean errorWarningStatus = hwNode->SR.B.EWRN;
310 if ((busOffState != 0) && (hwNode->ECNT.B.TEC > 254))
315 hwNode->ECNT.B.TEC = 0x01;
316 hwNode->ECNT.B.REC = 0x01;
319 hwNode->SR.B.EWRN = 0;
322 hwNode->SR.B.ALERT = 0;
329 else if ((busOffState != 0) && (errorWarningStatus != 0))
335 else if ((busOffState == 0) && (errorWarningStatus == 0))
349 sint32 tempBRP, tempSJW, tempTSEG1 = 12;
350 sint32 bestBRP = 0, bestSJW = 0, bestTBAUD = 0, bestTSEG1 = 1, bestTSEG2;
372 for (tempBRP = 1; tempBRP <= (0x3F + 1); tempBRP++)
374 float32 Fquanta = moduleFreq / tempBRP;
375 sint32 tempTBAUD = Fquanta / baudrate;
376 float32 tempBaudrate = Fquanta / tempTBAUD;
379 if ((tempTBAUD <= 20) && (bestError > error))
382 bestTBAUD = tempTBAUD;
395 for (tempTSEG1 = 16; tempTSEG1 >= 3; tempTSEG1--)
397 sint32 tempSamplePoint = ((tempTSEG1 + 1) * 10000) / bestTBAUD;
398 sint32 error =
__abs(tempSamplePoint - samplePoint);
400 if (bestError > error)
402 bestTSEG1 = tempTSEG1;
406 if (tempSamplePoint < samplePoint)
412 bestTSEG2 = bestTBAUD - bestTSEG1 - 1;
417 for (tempSJW = 1; tempSJW <= 4; tempSJW++)
419 sint32 tempSynchJumpWidth = (tempSJW * 10000) / bestTBAUD;
420 sint32 error =
__abs(tempSynchJumpWidth - synchJumpWidth);
422 if (bestError > error)
432 nbtr.B.BRP = bestBRP - 1;
433 nbtr.B.SJW = bestSJW - 1;
434 nbtr.B.TSEG1 = bestTSEG1 - 1;
435 nbtr.B.TSEG2 = bestTSEG2 - 1;
439 hwNode->BTR.U = nbtr.U;
446 Ifx_CAN_N_BTR nbtr = {.U = btr};
447 uint32 tempBRP = 1U + nbtr.B.BRP;
448 uint32 tempSJW = 1U + nbtr.B.SJW;
449 uint32 tempTSEG1 = 1U + nbtr.B.TSEG1;
450 uint32 tempTSEG2 = 1U + nbtr.B.TSEG2;
451 uint32 tempDIV8 = (nbtr.B.DIV8 != 0) ? 8U : 1U;
453 uint32 tempTSEG = 1 + tempTSEG1 + tempTSEG2;
455 *baudrate = (
uint32)(moduleFreq / (
float32)(tempDIV8 * tempBRP * tempTSEG));
481 MODULE_SRC.CAN.CAN[0].INT[i].U = 0x00000000;
484 for (i = 0; i < 8; i++)
486 mcan->MSPND[i].U = 0x00000000;
489 mcan->MSIMASK.U = 0x00000000;
490 mcan->MCR.U = 0x00000000;
494 mcan->FDR.U = 0x00000000;
497 mcan->CLC.U = 0x00000001;
505 return &(MODULE_SRC.CAN.CAN[0].INT[srcId]);
514 can->KRST0.B.RST = 1;
515 can->KRST1.B.RST = 1;
518 while (0 == can->KRST0.B.RSTSTAT)
523 can->KRSTCLR.B.CLR = 1;
530 Ifx_CAN_PANCTR panctr;
532 panctr.B.PANAR1 = arg1;
533 panctr.B.PANAR2 = arg2;
534 panctr.B.PANCMD = cmd;
537 mcan->PANCTR.U = panctr.U;