#include "DSP28x_Project.h" // Device Headerfile and Examples Include File void mailbox_chec(int32 T1, int32 T2, int32 T3); void mailbox_rea(int16 i); // Global variable for this example Uint32 ErrorCoun; Uint32 PassCoun; Uint32 MessageReceivedCoun; Uint32 TestMbo1 = 0; Uint32 TestMbo2 = 0; Uint32 TestMbo3 = 0; void main(void) { Uint16 j; // struct ECAN_REGS ECanaShadow; InitSysCtrl(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); MessageReceivedCoun = 0; ErrorCoun = 0; PassCoun = 0; setcans(); // Initialize eCAN-A module for(;;) { //Read from Receive mailboxes and begin checking for data */ for(j=0; j<16; j++) // Read & check 16 mailboxes { mailbox_rea(j); // This func reads the indicated mailbox data mailbox_chec(TestMbo1,TestMbo2,TestMbo3); // Checks the received data } } } // This function reads out the contents of the indicated // by the Mailbox number (MBXnbr). void mailbox_rea(int16 MBXnb) { volatile struct MBOX *Mailbo; Mailbo = &ECanaMboxes.MBOX0 + MBXnb; TestMbo1 = Mailbo->MDL.all; // = 0x9555AAAn (n is the MBX number) TestMbo2 = Mailbo->MDH.all; // = 0x89ABCDEF (a constant) TestMbo3 = Mailbo->MSGID.all;// = 0x9555AAAn (n is the MBX number) } // MSGID of a rcv MBX is transmitted as the MDL data. void mailbox_chec(int32 T1, int32 T2, int32 T3) { if((T1 != T3) || ( T2 != 0x89ABCDEF)) { ErrorCoun++; } else { PassCoun++; } }