/** * initializes the I2C bus * @return 0 on success */ int Com_CAN_Init() { int i; InitECanGpio(); InitECan(); // Configure the eCAN for self test mode // Enable the enhanced features of the eCAN. //EALLOW; //ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; //ECanaShadow.CANMC.bit.STM = 1; // Configure CAN for self-test mode //ECanaShadow.CANMC.bit. = 1; // Configure CAN for self-test mode //ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; //EDIS; // reset all timestamps for(i = 0; i < 32; i++) { volatile Uint32* mots; mots = &ECanaMOTSRegs.MOTS0 + i; *mots = 0; } Com_CAN_InitReceiveMBoxes(); Com_CAN_InitTransmitMBoxes(); return 0; }
void main(void) { InitSysCtrl(); // Copy time critical code and Flash setup code to RAM // This includes the following ISR functions: epwm1_timer_isr(), epwm2_timer_isr() // epwm3_timer_isr and and InitFlash(); // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart // symbols are created by the linker. Refer to the F28335.cmd file. // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the DSP2833x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP2833x_DefaultIsr.c. // This function is found in DSP2833x_PieVect.c. InitPieVectTable(); // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.SEQ1INT = &PWM_AD_isr; PieVectTable.ECAN0INTA = &Skiip4_CAN_isr; EDIS; // This is needed to disable write to EALLOW protected registers InitFlash(); MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); MemCopy(&IQmathLoadStart, &IQmathLoadEnd, &IQmathRunStart); //ECan-A模块初始化 InitECan(); InitECan1(); InitGpio(); // Skipped for this example InitAdc(); // Initialize necessary ADC module, directly for SVPWM. InitEPwm(); IER |= M_INT1; // Enable SEQ1_INT which is connected to PIE1.1: IER |= M_INT9; // Enable eCAN0-A INT which is connected to PIE9.5: EINT; } // end of main()