//########################################################################### // // FILE: DSP2803x_ECan.c // // TITLE: DSP2803x Enhanced CAN Initialization & Support Functions. // //########################################################################### // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V130 $ // $Release Date: May 8, 2015 $ // $Copyright: Copyright (C) 2009-2015 Texas Instruments Incorporated - // http://www.ti.com/ ALL RIGHTS RESERVED $ //########################################################################### #include "DSP2803x_Device.h" // DSP28 Headerfile Include File #include "DSP2803x_Examples.h" // DSP28 Examples Include File //--------------------------------------------------------------------------- // InitECan: //--------------------------------------------------------------------------- // This function initializes the eCAN module to a known state. // void InitECan(void) { InitECana(); } void InitECana(void) // Initialize eCAN-A module { /* Create a shadow register structure for the CAN control registers. This is needed, since only 32-bit access is allowed to these registers. 16-bit access to these registers could potentially corrupt the register contents or return false data. This is especially true while writing to/reading from a bit (or group of bits) among bits 16 - 31 */ struct ECAN_REGS ECanaShadow; EALLOW; // EALLOW enables access to protected bits /* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/ ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all; ECanaShadow.CANTIOC.bit.TXFUNC = 1; ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all; ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all; ECanaShadow.CANRIOC.bit.RXFUNC = 1; ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all; /* Configure eCAN for HECC mode - (reqd to access mailboxes 16 thru 31) */ // HECC mode also enables time-stamping feature ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; ECanaShadow.CANMC.bit.SCB = 1; ECanaShadow.CANMC.bit.ABO = 1; ECanaShadow.CANMC.bit.DBO = 1; ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; /* Initialize all bits of 'Message Control Register' to zero */ // Some bits of MSGCTRL register come up in an unknown state. For proper operation, // all bits (including reserved bits) of MSGCTRL must be initialized to zero ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX17.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX18.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX19.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX20.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX21.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX22.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX23.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX24.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX25.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX26.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX27.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX28.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX29.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX30.MSGCTRL.all = 0x00000000; ECanaMboxes.MBOX31.MSGCTRL.all = 0x00000000; // TAn, RMPn, GIFn bits are all zero upon reset and are cleared again // as a matter of precaution. ECanaRegs.CANTA.all = 0xFFFFFFFF; /* Clear all TAn bits */ ECanaRegs.CANRMP.all = 0xFFFFFFFF; /* Clear all RMPn bits */ ECanaRegs.CANGIF0.all = 0xFFFFFFFF; /* Clear all interrupt flag bits */ ECanaRegs.CANGIF1.all = 0xFFFFFFFF; /* Configure bit timing parameters for eCANA*/ ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; ECanaShadow.CANMC.bit.CCR = 1 ; // Set CCR = 1 ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; ECanaShadow.CANES.all = ECanaRegs.CANES.all; // Wait until the CPU has been granted permission to change the configuration registers do { ECanaShadow.CANES.all = ECanaRegs.CANES.all; } while(ECanaShadow.CANES.bit.CCE != 1 ); // Wait for CCE bit to be set.. ECanaShadow.CANBTC.all = 0; ECanaShadow.CANBTC.bit.BRPREG = 7; ECanaShadow.CANBTC.bit.TSEG2REG = 2; ECanaShadow.CANBTC.bit.TSEG1REG = 10; ECanaShadow.CANBTC.bit.SAM = 1; ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all; //============================================================================================== ECanaRegs.CANME.all = 0; // Required before writing the MSGIDs ECanaRegs.CANGAM.all = 0x80000000; //0x40000000:标准帧;0xC0000000:扩展帧 //接收邮箱设置 ECanaMboxes.MBOX0.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM0.all = 0x9FFFFFFF; ECanaMboxes.MBOX1.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM1.all = 0x9FFFFFFF; ECanaMboxes.MBOX2.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM2.all = 0x9FFFFFFF; ECanaMboxes.MBOX3.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM3.all = 0x9FFFFFFF; ECanaMboxes.MBOX4.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM4.all = 0x9FFFFFFF; ECanaMboxes.MBOX5.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM5.all = 0x9FFFFFFF; ECanaMboxes.MBOX6.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM6.all = 0x9FFFFFFF; ECanaMboxes.MBOX7.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM7.all = 0x9FFFFFFF; ECanaMboxes.MBOX8.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM8.all = 0x9FFFFFFF; ECanaMboxes.MBOX9.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM9.all = 0x9FFFFFFF; ECanaMboxes.MBOX10.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM10.all = 0x9FFFFFFF; ECanaMboxes.MBOX11.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM11.all = 0x9FFFFFFF; ECanaMboxes.MBOX12.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM12.all = 0x9FFFFFFF; ECanaMboxes.MBOX13.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM13.all = 0x9FFFFFFF; ECanaMboxes.MBOX14.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM14.all = 0x9FFFFFFF; ECanaMboxes.MBOX15.MSGID.all = 0xC0000000;//0x40000000; ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000008; ECanaLAMRegs.LAM15.all = 0x9FFFFFFF; //发送邮箱设置 ECanaMboxes.MBOX16.MSGID.all = 0x00040000; ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000008; ECanaShadow.CANMD.all = 0x0000FFFF; //低16位为接收邮箱,高16位为发送邮箱 ECanaRegs.CANMD.all = ECanaShadow.CANMD.all; ECanaShadow.CANME.all = 0xFFFFFFFF; //启用所有邮箱 ECanaRegs.CANME.all = ECanaShadow.CANME.all; //============================================================== ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; ECanaShadow.CANMC.bit.CCR = 0 ; // Set CCR = 0 ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; // Wait until the CPU no longer has permission to change the configuration registers do { ECanaShadow.CANES.all = ECanaRegs.CANES.all; } while(ECanaShadow.CANES.bit.CCE != 0 ); // Wait for CCE bit to be cleared.. /* Disable all Mailboxes */ //ECanaRegs.CANME.all = 0; // Required before writing the MSGIDs EDIS; } //--------------------------------------------------------------------------- // Example: InitECanGpio: //--------------------------------------------------------------------------- // This function initializes GPIO pins to function as eCAN pins // // Each GPIO pin can be configured as a GPIO pin or up to 3 different // peripheral functional pins. By default all pins come up as GPIO // inputs after reset. // // Caution: // Only one GPIO pin should be enabled for CANTXA operation. // Only one GPIO pin shoudl be enabled for CANRXA operation. // Comment out other unwanted lines. void InitECanGpio(void) { InitECanaGpio(); } void InitECanaGpio(void) { EALLOW; /* Enable internal pull-up for the selected CAN pins */ // Pull-ups can be enabled or disabled by the user. // This will enable the pullups for the specified pins. // Comment out other unwanted lines. GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0; // Enable pull-up for GPIO30 (CANRXA) GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0; // Enable pull-up for GPIO31 (CANTXA) /* Set qualification for selected CAN pins to asynch only */ // Inputs are synchronized to SYSCLKOUT by default. // This will select asynch (no qualification) for the selected pins. GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3; // Asynch qual for GPIO30 (CANRXA) /* Configure eCAN-A pins using GPIO regs*/ // This specifies which of the possible GPIO pins will be eCAN functional pins. GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1; // Configure GPIO30 for CANRXA operation GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1; // Configure GPIO31 for CANTXA operation EDIS; } void ECanMboxSend(struct CANMBOX_USER_REGS *pRegs) { struct ECAN_REGS ECanaShadow; volatile struct MBOX *Mailbox; ECanaShadow.CANME.all = ECanaRegs.CANME.all; ECanaShadow.CANME.all &= ~((Uint32)1 << pRegs->MboxNum); ECanaRegs.CANME.all = ECanaShadow.CANME.all; Mailbox = &ECanaMboxes.MBOX0 + pRegs->MboxNum; Mailbox->MSGID.all = pRegs->MboxID | 0x80000000; //扩展帧 // Mailbox->MSGID.all = pRegs->MboxID << 18; //标准帧 // Mailbox->MDH.all = pRegs->MboxDataH; // Mailbox->MDL.all = pRegs->MboxDataL; Mailbox->MDL.word.LOW_WORD = pRegs->MboxWord1; Mailbox->MDL.word.HI_WORD = pRegs->MboxWord2; Mailbox->MDH.word.LOW_WORD = pRegs->MboxWord3; Mailbox->MDH.word.HI_WORD = pRegs->MboxWord4; Mailbox->MSGCTRL.all = pRegs->MboxDLC; ECanaShadow.CANME.all = ECanaRegs.CANME.all; ECanaShadow.CANME.all |= (Uint32)1 << pRegs->MboxNum; ECanaRegs.CANME.all = ECanaShadow.CANME.all; ECanaRegs.CANTRS.all = (Uint32)1 << pRegs->MboxNum; ECanaRegs.CANTA.all = (Uint32)1 << pRegs->MboxNum; } struct CANMBOX_USER_REGS ECanMboxRead(void) { struct CANMBOX_USER_REGS CanMboxUserRegs; if (ECanaRegs.CANRMP.bit.RMP0 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 0; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX0.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX0.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX0.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX0.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX0.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX0.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP0 = 1; }else if (ECanaRegs.CANRMP.bit.RMP1 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 1; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX1.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX1.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX1.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX1.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX1.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX1.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP1 = 1; }else if (ECanaRegs.CANRMP.bit.RMP2 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 2; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX2.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX2.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX2.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX2.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX2.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX2.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP2 = 1; }else if (ECanaRegs.CANRMP.bit.RMP3 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 3; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX3.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX3.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX3.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX3.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX3.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX3.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP3 = 1; }else if (ECanaRegs.CANRMP.bit.RMP4 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 4; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX4.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX4.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX4.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX4.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX4.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX4.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP4 = 1; }else if (ECanaRegs.CANRMP.bit.RMP5 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 5; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX5.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX5.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX5.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX5.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX5.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX5.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP5 = 1; }else if (ECanaRegs.CANRMP.bit.RMP6 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 6; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX6.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX6.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX6.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX6.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX6.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX6.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP6 = 1; }else if (ECanaRegs.CANRMP.bit.RMP7 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 7; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX7.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX7.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX7.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX7.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX7.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX7.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP7 = 1; }else if (ECanaRegs.CANRMP.bit.RMP8 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 8; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX8.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX8.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX8.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX8.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX8.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX8.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP8 = 1; }else if (ECanaRegs.CANRMP.bit.RMP9 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 9; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX9.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX9.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX9.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX9.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX9.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX9.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP9 = 1; }else if (ECanaRegs.CANRMP.bit.RMP10 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 10; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX10.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX10.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX10.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX10.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX10.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX10.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP10 = 1; }else if (ECanaRegs.CANRMP.bit.RMP11 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 11; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX11.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX11.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX11.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX11.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX11.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX11.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP11 = 1; }else if (ECanaRegs.CANRMP.bit.RMP12 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 12; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX12.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX12.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX12.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX12.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX12.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX12.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP12 = 1; }else if (ECanaRegs.CANRMP.bit.RMP13 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 13; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX13.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX13.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX13.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX13.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX13.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX13.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP13 = 1; }else if (ECanaRegs.CANRMP.bit.RMP14 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 14; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX14.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX14.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX14.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX14.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX14.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX14.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP14 = 1; }else if (ECanaRegs.CANRMP.bit.RMP15 == 1) { CanMboxUserRegs.MboxRxFlg = TRUE; CanMboxUserRegs.MboxNum = 15; CanMboxUserRegs.MboxID = ECanaMboxes.MBOX15.MSGID.all & 0x1FFFFFFF; //扩展帧 CanMboxUserRegs.MboxDLC = ECanaMboxes.MBOX15.MSGCTRL.bit.DLC; CanMboxUserRegs.MboxWord1 = ECanaMboxes.MBOX15.MDL.word.LOW_WORD; CanMboxUserRegs.MboxWord2 = ECanaMboxes.MBOX15.MDL.word.HI_WORD; CanMboxUserRegs.MboxWord3 = ECanaMboxes.MBOX15.MDH.word.LOW_WORD; CanMboxUserRegs.MboxWord4 = ECanaMboxes.MBOX15.MDH.word.HI_WORD; ECanaRegs.CANRMP.bit.RMP15 = 1; }else { CanMboxUserRegs.MboxRxFlg = FALSE; } return CanMboxUserRegs; } /* Note: Bit timing parameters must be chosen based on the network parameters such as the sampling point desired and the propagation delay of the network. The propagation delay is a function of length of the cable, delay introduced by the transceivers and opto/galvanic-isolators (if any). The parameters used in this file must be changed taking into account the above mentioned factors in order to arrive at the bit-timing parameters suitable for a network. */ //=========================================================================== // End of file. //===========================================================================