#include "x_int13.h" #include <281xEvTimersInit.h> #include #include "DSP281x_Examples.h" // DSP281x Examples Include File #include "DSP281x_SWPrioritizedIsrLevels.h" // DSP281x Examples Include File #include "DSP281x_Device.h" #include "MemoryFunctions.h" #include "Spartan2E_Adr.h" #include "TuneUpPlane.h" #include "xp_write_xpwm_time.h" #include "params.h" #include "pwm_test_lines.h" #include "sync_tools.h" #include "profile_interrupt.h" //Pointers to handler functions void (*int13_handler)() = NULL; ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// //unsigned int enable_profile_led1_pwm = 1; //unsigned int enable_profile_led2_pwm = 1; int InitXilinxSpartan2E(void (*int_handler)()) { int err; project.controller.status = component_NotReady; err = load_xilinx_new(0x130000, SIZE_XILINX200); if (err) return err; err = test_xilinx_live(); #ifdef ENABLE_XINTC_INT13 if (int_handler) XIntcInterruptSetup(int_handler); else err = 1; #endif if (err == 0) project.controller.status = component_Ready; return err; } #pragma CODE_SECTION(XIntc_INT13_Handler,".fast_run2"); interrupt void XIntc_INT13_Handler(void) { static int l2; IER &= MINT13; // Set "global" priority if (xpwm_time.disable_sync_out==0) { if (xpwm_time.do_sync_out) { i_sync_pin_on(); #if(_ENABLE_PWM_LINES_FOR_TESTS_SYNC) PWM_LINES_TK_17_ON; #endif } else { i_sync_pin_off(); #if(_ENABLE_PWM_LINES_FOR_TESTS_SYNC) PWM_LINES_TK_17_OFF; #endif } } if (xpwm_time.what_next_interrupt==PWM_LOW_LEVEL_INTERRUPT) { l2 = 1; } else l2 = 0; #if (_ENABLE_INTERRUPT_PROFILE_LED1) if (profile_interrupt.for_led1.bits.pwm && l2) i_led1_on_off_special(1); #endif #if (_ENABLE_INTERRUPT_PROFILE_LED2) if (profile_interrupt.for_led2.bits.pwm && l2) i_led2_on_off_special(1); #endif EINT; // Insert ISR Code here....... // i_led2_on_off(1); // IER &= 0xEFFF; if (project.controller.write.setup.bit.use_int13 == 1) { // EnableInterrupts(); //Останавливаем прерывание, в котором производим расчёты, из-за которых плавало прерывание ШИМ // stop_eva_timer1(); if(int13_handler) { int13_handler(); } //Запускаем обратно //// start_eva_timer1(); // DINT; // // IFR &= 0xefff; // очистим если вдруг прерывание уже пришло! // IER |= M_INT13; } else { // IFR &= 0xefff; // очистим если вдруг прерывание уже пришло! // IER |= M_INT13; } // EnableInterrupts(); // c = IFR; // & 0x0100 // if (c) // { // count_lost_interrupt++; // IFR &= 0xfeff; // очистим если вдруг прерывание уже пришло! // } // EnableInterrupts(); // i_led2_on_off(0); // IFR &= 0xfeff; // очистим если вдруг прерывание уже пришло! // EINT; #if (_ENABLE_INTERRUPT_PROFILE_LED1) if (profile_interrupt.for_led1.bits.pwm) i_led1_on_off_special(0); #endif #if (_ENABLE_INTERRUPT_PROFILE_LED2) if (profile_interrupt.for_led2.bits.pwm) if (l2) i_led2_on_off_special(0); #endif } int XIntcInterruptSetup(void (*int_handler)()) { int result = 0; EALLOW; GpioMuxRegs.GPEMUX.bit.XNMI_XINT13_GPIOE2=1; // GpioMuxRegs.GPEDIR.bit.GPIOE2 = 0; // GpioDataRegs.GPESET.bit.GPIOE2 = 1; PieVectTable.XINT13=&XIntc_INT13_Handler; int13_handler = int_handler; // PieCtrlRegs.PIECRTL.bit. XIntruptRegs.XNMICR.bit.POLARITY=0; XIntruptRegs.XNMICR.bit.SELECT=1; XIntruptRegs.XNMICR.bit.ENABLE=0; // Enable interrupt 13 // IER |= M_INT13; project.controller.read.status.bit.int13_inited = 1; // EDIS; // EnableInterrupts(); /* * Start the interrupt controller in simulation mode. */ // result = XIntc_Start(Ptr, intc_mode_is_Sim); // sim mode // if (!(result == status_Success)) return result; // return status_Success; } void start_int13_interrupt(void) { // Enable interrupt 13 IER |= M_INT13; } void stop_int13_interrupt(void) { // Disable interrupt 13 // IER &= ~(M_INT13); IER &= MINT13; // Set "global" priority }