57 boolean result =
FALSE;
61 stat.U = hwObj->STAT.U;
63 if ((stat.B.TXRQ != 0) && (stat.B.NEWDAT != 0))
92 hwObj->CTR.U = 0x0000FFFFUL;
94 hwObj->FCR.U = 0x00000000UL;
95 hwObj->FGPR.U = 0x00000000UL;
96 hwObj->IPR.U = 0x00000000UL;
97 hwObj->AMR.U = 0x3FFFFFFFUL;
98 hwObj->DATAL.U = 0x00000000UL;
99 hwObj->DATAH.U = 0x00000000UL;
100 hwObj->AR.U = 0x00000000UL;
123 *data++ = hwObj->DATAL.U;
124 *data++ = hwObj->DATAH.U;
130 *data++ = hwBotObj->EDATA0.U;
135 *data++ = hwBotObj->EDATA1.U;
140 *data++ = hwBotObj->EDATA2.U;
145 *data++ = hwBotObj->EDATA3.U;
150 *data++ = hwBotObj->EDATA4.U;
151 *data++ = hwBotObj->EDATA5.U;
156 *data++ = hwBotObj->EDATA6.U;
158 *data++ = hwTopObj->EDATA0.U;
159 *data++ = hwTopObj->EDATA1.U;
160 *data++ = hwTopObj->EDATA2.U;
165 *data++ = hwTopObj->EDATA3.U;
166 *data++ = hwTopObj->EDATA4.U;
167 *data++ = hwTopObj->EDATA5.U;
168 *data = hwTopObj->EDATA6.U;
186 msg->
data[0] = hwObj->DATAL.U;
187 msg->
data[1] = hwObj->DATAH.U;
199 uint32 index = mcan->MSID[msgObjGroup].U;
204 mcan->MSPND[msgObjGroup].U = ~(1UL << index);
205 msgObjId = index + (msgObjGroup << 5);
216 status.
U = hwObj->STAT.U;
224 uint32 shift = (1U << flag);
226 return (hwObj->STAT.U & shift) ?
TRUE :
FALSE;
235 boolean longFrame = (hwObj->FCR.B.FDF != 0) ?
TRUE :
FALSE;
240 if (hwObj->STAT.B.NEWDAT != 0)
242 Ifx_CAN_MO_STAT stat;
243 IfxMultican_MsgObj_doReadLongFrame(mcan, msgObjId, msg, data);
246 if (stat.B.RXUPD != 0)
250 else if (stat.B.NEWDAT != 0)
252 Ifx_CAN_MO_STAT stat2;
255 IfxMultican_MsgObj_doReadLongFrame(mcan, msgObjId, msg, data);
259 if ((stat2.B.NEWDAT == 0) && (stat2.B.RXUPD == 0))
272 if (stat.B.MSGLST != 0)
297 if (hwObj->STAT.B.NEWDAT != 0)
299 Ifx_CAN_MO_STAT stat;
300 IfxMultican_MsgObj_doReadMessage(hwObj, msg);
303 if (stat.B.RXUPD != 0)
307 else if (stat.B.NEWDAT != 0)
309 Ifx_CAN_MO_STAT stat2;
312 IfxMultican_MsgObj_doReadMessage(hwObj, msg);
316 if ((stat2.B.NEWDAT == 0) && (stat2.B.RXUPD == 0))
329 if (stat.B.MSGLST != 0)
356 boolean longFrame = (hwObj->FCR.B.FDF != 0) ?
TRUE :
FALSE;
363 if (hwObj->STAT.B.TXRQ)
374 hwObj->DATAL.U = *data++;
375 hwObj->DATAH.U = *data++;
381 hwBotObj->EDATA0.U = *data++;
386 hwBotObj->EDATA1.U = *data++;
391 hwBotObj->EDATA2.U = *data++;
396 hwBotObj->EDATA3.U = *data++;
401 hwBotObj->EDATA4.U = *data++;
402 hwBotObj->EDATA5.U = *data++;
407 hwBotObj->EDATA6.U = *data++;
409 hwTopObj->EDATA0.U = *data++;
410 hwTopObj->EDATA1.U = *data++;
411 hwTopObj->EDATA2.U = *data++;
416 hwTopObj->EDATA3.U = *data++;
417 hwTopObj->EDATA4.U = *data++;
418 hwTopObj->EDATA5.U = *data++;
419 hwTopObj->EDATA6.U = *data;
468 if (hwObj->STAT.B.TXRQ)
478 hwObj->DATAL.U = msg->
data[0];
479 hwObj->DATAH.U = msg->
data[1];
518 hwObj->CTR.U = ctr.U;
520 hwObj->AMR.B.AM = accMask << ((extend != 0) ? 0 : 18);
521 hwObj->AR.B.IDE = (
id << ((extend != 0) ? 0 : 18)) | (extend << 29);
525 hwObj->CTR.U = ctr.U;
534 ctr.U = 1U << (flag + 16);
536 hwObj->CTR.U = ctr.U;
542 hwNode->CR.U = 0x00000001;
543 hwNode->SR.U = 0x00000000;
544 hwNode->IPR.U = 0x00000000;
545 hwNode->PCR.U = 0x00000000;
546 hwNode->BTEVR.U = 0x00000000;
547 hwNode->ECNT.U = 0x00600000;
548 hwNode->FCR.U = 0x00000000;
555 hwNode->PCR.B.RXSEL = rxd->
select;
574 boolean busOffState = hwNode->SR.B.BOFF;
575 boolean errorWarningStatus = hwNode->SR.B.EWRN;
578 if ((busOffState != 0) && (hwNode->ECNT.B.TEC > 254))
583 hwNode->ECNT.B.TEC = 0x01;
584 hwNode->ECNT.B.REC = 0x01;
587 hwNode->SR.B.EWRN = 0;
590 hwNode->SR.B.ALERT = 0;
597 else if ((busOffState != 0) && (errorWarningStatus != 0))
603 else if ((busOffState == 0) && (errorWarningStatus == 0))
617 sint32 tempBRP, tempSJW, tempTSEG1 = 12;
618 sint32 bestBRP = 0, bestSJW = 0, bestTBAUD = 0, bestTSEG1 = 1, bestTSEG2;
640 for (tempBRP = 1; tempBRP <= (0x3F + 1); tempBRP++)
642 float32 Fquanta = moduleFreq / tempBRP;
643 sint32 tempTBAUD = Fquanta / baudrate;
644 float32 tempBaudrate = Fquanta / tempTBAUD;
647 if ((tempTBAUD <= 20) && (bestError > error))
650 bestTBAUD = tempTBAUD;
663 for (tempTSEG1 = 16; tempTSEG1 >= 3; tempTSEG1--)
665 sint32 tempSamplePoint = ((tempTSEG1 + 1) * 10000) / bestTBAUD;
666 sint32 error =
__abs(tempSamplePoint - samplePoint);
668 if (bestError > error)
670 bestTSEG1 = tempTSEG1;
674 if (tempSamplePoint < samplePoint)
680 bestTSEG2 = bestTBAUD - bestTSEG1 - 1;
685 for (tempSJW = 1; tempSJW <= 4; tempSJW++)
687 sint32 tempSynchJumpWidth = (tempSJW * 10000) / bestTBAUD;
688 sint32 error =
__abs(tempSynchJumpWidth - synchJumpWidth);
690 if (bestError > error)
700 nbtr.B.BRP = bestBRP - 1;
701 nbtr.B.SJW = bestSJW - 1;
702 nbtr.B.TSEG1 = bestTSEG1 - 1;
703 nbtr.B.TSEG2 = bestTSEG2 - 1;
707 hwNode->BTR.U = nbtr.U;
714 sint32 tempFBRP, tempFSJW, tempFTSEG1 = 12;
715 sint32 bestFBRP = 0, bestFSJW = 0, bestFTBAUD = 0, bestFTSEG1 = 1, bestFTSEG2;
737 for (tempFBRP = 1; tempFBRP <= (0x3F + 1); tempFBRP++)
739 float32 Fquanta = moduleFreq / tempFBRP;
740 sint32 tempTBAUD = Fquanta / baudrate;
741 float32 tempBaudrate = Fquanta / tempTBAUD;
744 if ((tempTBAUD <= 20) && (bestError > error))
747 bestFTBAUD = tempTBAUD;
760 for (tempFTSEG1 = 16; tempFTSEG1 >= 3; tempFTSEG1--)
762 sint32 tempSamplePoint = ((tempFTSEG1 + 1) * 10000) / bestFTBAUD;
763 sint32 error =
__abs(tempSamplePoint - samplePoint);
765 if (bestError > error)
767 bestFTSEG1 = tempFTSEG1;
771 if (tempSamplePoint < samplePoint)
777 bestFTSEG2 = bestFTBAUD - bestFTSEG1 - 1;
782 for (tempFSJW = 1; tempFSJW <= 4; tempFSJW++)
784 sint32 tempSynchJumpWidth = (tempFSJW * 10000) / bestFTBAUD;
785 sint32 error =
__abs(tempSynchJumpWidth - synchJumpWidth);
787 if (bestError > error)
795 Ifx_CAN_N_FBTR nfbtr;
797 nfbtr.B.FBRP = bestFBRP - 1;
798 nfbtr.B.FSJW = bestFSJW - 1;
799 nfbtr.B.FTSEG1 = bestFTSEG1 - 1;
800 nfbtr.B.FTSEG2 = bestFTSEG2 - 1;
802 hwNode->FBTR.U = nfbtr.U;
809 sint32 tempBRP, tempSJW, tempTSEG1 = 12;
810 sint32 bestBRP = 0, bestSJW = 0, bestTBAUD = 0, bestTSEG1 = 1, bestTSEG2;
832 for (tempBRP = 1; tempBRP <= (0x3F + 1); tempBRP++)
834 float32 Fquanta = moduleFreq / tempBRP;
835 sint32 tempTBAUD = Fquanta / baudrate;
836 float32 tempBaudrate = Fquanta / tempTBAUD;
839 if ((tempTBAUD <= 20) && (bestError > error))
842 bestTBAUD = tempTBAUD;
855 for (tempTSEG1 = 64; tempTSEG1 >= 3; tempTSEG1--)
857 sint32 tempSamplePoint = ((tempTSEG1 + 1) * 10000) / bestTBAUD;
858 sint32 error =
__abs(tempSamplePoint - samplePoint);
860 if (bestError > error)
862 bestTSEG1 = tempTSEG1;
866 if (tempSamplePoint < samplePoint)
872 bestTSEG2 = bestTBAUD - bestTSEG1 - 1;
877 for (tempSJW = 1; tempSJW <= 16; tempSJW++)
879 sint32 tempSynchJumpWidth = (tempSJW * 10000) / bestTBAUD;
880 sint32 error =
__abs(tempSynchJumpWidth - synchJumpWidth);
882 if (bestError > error)
890 Ifx_CAN_N_BTEVR nbtevr;
892 nbtevr.B.BRP = bestBRP - 1;
893 nbtevr.B.SJW = bestSJW - 1;
894 nbtevr.B.TSEG1 = bestTSEG1 - 1;
895 nbtevr.B.TSEG2 = bestTSEG2 - 1;
899 hwNode->BTEVR.U = nbtevr.U;
906 Ifx_CAN_N_BTR nbtr = {.U = btr};
907 uint32 tempBRP = 1U + nbtr.B.BRP;
908 uint32 tempSJW = 1U + nbtr.B.SJW;
909 uint32 tempTSEG1 = 1U + nbtr.B.TSEG1;
910 uint32 tempTSEG2 = 1U + nbtr.B.TSEG2;
911 uint32 tempDIV8 = (nbtr.B.DIV8 != 0) ? 8U : 1U;
913 uint32 tempTSEG = 1 + tempTSEG1 + tempTSEG2;
915 *baudrate = (
uint32)(moduleFreq / (
float32)(tempDIV8 * tempBRP * tempTSEG));
941 MODULE_SRC.CAN.CAN[0].INT[i].U = 0x00000000;
944 for (i = 0; i < 8; i++)
946 mcan->MSPND[i].U = 0x00000000;
949 mcan->MSIMASK.U = 0x00000000;
950 mcan->MCR.U = 0x00000000;
954 mcan->FDR.U = 0x00000000;
957 mcan->CLC.U = 0x00000001;
965 return &(MODULE_SRC.CAN.CAN[0].INT[srcId]);
974 can->KRST0.B.RST = 1;
975 can->KRST1.B.RST = 1;
978 while (0 == can->KRST0.B.RSTSTAT)
983 can->KRSTCLR.B.CLR = 1;
990 Ifx_CAN_PANCTR panctr;
992 panctr.B.PANAR1 = arg1;
993 panctr.B.PANAR2 = arg2;
994 panctr.B.PANCMD = cmd;
997 mcan->PANCTR.U = panctr.U;