//*************************************************************** //******************* INTERRUPT FUNCTIONS *********************** //*************************************************************** void Interrupt_Init(void) { //PUSH BUTTON INTERRUPT /* Code */ XIntc_Initialize(&Intc, INTC_DEVICE_ID); XGpio_Initialize(&Gpio, GPIO_DEVICE_ID); XIntc_Connect(&Intc, INTR_ID, GpioIsr, &Gpio); /* Buttons are all inputs */ XGpio_SetDataDirection(&Gpio, BUTTON_CHANNEL, GPIO_ALL_BUTTONS); XGpio_InterruptEnable(&Gpio, BUTTON_INTERRUPT); XGpio_InterruptGlobalEnable(&Gpio); /* Enable the Interrupt vector at the interrupt controller */ XIntc_Enable(&Intc, INTR_ID); XExc_Init(); /***************************************************************** * Initialize the PPC405 exception table and register the interrupt * controller handler with the exception table ******************************************************************/ XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)XIntc_InterruptHandler, &Intc); /* Now Register Timer Interrupt */ XExc_RegisterHandler(XEXC_ID_PIT_INT, (XExceptionHandler)TimerIsr, (void *)0); /* Enable non-critical exceptions in the PowerPC */ XExc_mEnableExceptions(XEXC_NON_CRITICAL); /******************************************************************* * Start the interrput controller such that interrupts are recognized * and handled by the processor. ********************************************************************/ XIntc_Start(&Intc, XIN_REAL_MODE); //TIMER INTERRUPT /* Set Timer Interval (1 Sec) */ XTime_PITSetInterval(0x0F000000); /* Automatically Restarts Timer */ XTime_PITEnableAutoReload(); /* Clear Timer Reg */ XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL); /* Clear Queued Timer Interrupts */ XTime_PITClearInterrupt(); /* Enable Interrupt */ XTime_PITEnableInterrupt(); }
BaseType_t xPortStartScheduler( void ) { prvSetupTimerInterrupt(); XExc_RegisterHandler( XEXC_ID_SYSTEM_CALL, ( XExceptionHandler ) vPortYield, ( void * ) 0 ); vPortStartFirstTask(); /* Should not get here as the tasks are now running! */ return pdFALSE; }
void platform_setup_timer() { #ifdef XPAR_CPU_PPC440_CORE_CLOCK_FREQ_HZ XExc_RegisterHandler(XEXC_ID_DEC_INT, (XExceptionHandler)xadapter_timer_handler, NULL); /* Set DEC to interrupt every 250 mseconds */ XTime_DECSetInterval(PIT_INTERVAL); XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL); XTime_DECEnableAutoReload(); #else XExc_RegisterHandler(XEXC_ID_PIT_INT, (XExceptionHandler)xadapter_timer_handler, NULL); /* Set PIT to interrupt every 250 mseconds */ XTime_PITSetInterval(PIT_INTERVAL); XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL); XTime_PITEnableAutoReload(); XTime_PITEnableInterrupt(); #endif }
/* * Hardware initialisation to generate the RTOS tick. */ static void prvSetupTimerInterrupt( void ) { const uint32_t ulInterval = ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL ); XTime_DECClearInterrupt(); XTime_FITClearInterrupt(); XTime_WDTClearInterrupt(); XTime_WDTDisableInterrupt(); XTime_FITDisableInterrupt(); XExc_RegisterHandler( XEXC_ID_DEC_INT, ( XExceptionHandler ) vPortTickISR, ( void * ) 0 ); XTime_DECEnableAutoReload(); XTime_DECSetInterval( ulInterval ); XTime_DECEnableInterrupt(); }
void vPortSetupInterruptController( void ) { extern void vPortISRWrapper( void ); /* Perform all library calls necessary to initialise the exception table and interrupt controller. This assumes only one interrupt controller is in use. */ XExc_mDisableExceptions( XEXC_NON_CRITICAL ); XExc_Init(); /* The library functions save the context - we then jump to a wrapper to save the stack into the TCB. The wrapper then calls the handler defined above. */ XExc_RegisterHandler( XEXC_ID_NON_CRITICAL_INT, ( XExceptionHandler ) vPortISRWrapper, NULL ); XIntc_Initialize( &xInterruptController, XPAR_XPS_INTC_0_DEVICE_ID ); XIntc_Start( &xInterruptController, XIN_REAL_MODE ); }
/** * * Initialize exception handling for the PowerPC. The exception vector table * is setup with the stub handler for all exceptions. * * @param None. * * @return None. * * @note * * None. * *****************************************************************************/ void XExc_Init(void) { unsigned short index; void (*vectorbase)() = (void (*)()) _vectorbase; /* * Store the offset of the beginning of the exception handling code * (xvectors.S) in the IVPR register (Interrupt Vector Prefix Register). * Also uses inline assembly defined in "xpseudo_asm.h". */ mtivpr(vectorbase); /* * Initialize interrupt vector offset registers to vectorbase + 0x10, 0x20, * ... 0xf0. Each offset is 16 bytes apart. */ mtivor0(vectorbase); mtivor1(vectorbase + 0x10); mtivor2(vectorbase + 0x20); mtivor3(vectorbase + 0x30); mtivor4(vectorbase + 0x40); mtivor5(vectorbase + 0x50); mtivor6(vectorbase + 0x60); mtivor7(vectorbase + 0x70); mtivor8(vectorbase + 0x80); mtivor9(vectorbase + 0x90); mtivor10(vectorbase + 0xa0); mtivor11(vectorbase + 0xb0); mtivor12(vectorbase + 0xc0); mtivor13(vectorbase + 0xd0); mtivor14(vectorbase + 0xe0); mtivor15(vectorbase + 0xf0); /* * Initialize the vector table. Register the stub handler for each exception * Initialize the IVOR registers */ for(index = XEXC_ID_FIRST; index <= XEXC_ID_LAST; index++) { XExc_RegisterHandler(index, (XExceptionHandler)NullHandler, XNULL); } }
XStatus GpioSetupIntrSystem(XIntc* IntcInstancePtr, XGpio* InstancePtr, Xuint16 DeviceId, Xuint16 IntrId, Xuint16 IntrMask) { XStatus Result; GlobalIntrMask = IntrMask; #ifndef TESTAPP_GEN /* * Initialize the interrupt controller driver so that it's ready to use. * specify the device ID that was generated in xparameters.h */ Result = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID); if (Result != XST_SUCCESS) { return Result; } #endif /* Hook up simple interrupt service routine for TestApp*/ Result = XIntc_Connect(IntcInstancePtr, IntrId, (XInterruptHandler)GpioDriverHandler, InstancePtr); /* * Enable the GPIO channel interrupts so that push button can be detected * and enable interrupts for the GPIO device */ XGpio_InterruptEnable(InstancePtr, IntrMask); XGpio_InterruptGlobalEnable(InstancePtr); /* Enable the interrupt vector at the interrupt controller */ XIntc_Enable(IntcInstancePtr, IntrId); #ifndef TESTAPP_GEN /* * Initialize the PPC405 exception table and register the interrupt * controller handler with the exception table */ XExc_Init(); XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)XIntc_InterruptHandler,IntcInstancePtr); /* Enable non-critical exceptions in the PowerPC */ XExc_mEnableExceptions(XEXC_NON_CRITICAL); /* * Start the interrupt controller such that interrupts are recognized * and handled by the processor. */ Result = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE); #endif if (Result != XST_SUCCESS) { return Result; } return XST_SUCCESS; }
void InitInterrupts() { // Initialize wireless uart XUartLite_Initialize(&(wireless.uart), XPAR_WIRELESS_UART_DEVICE_ID); XUartLite_ResetFifos(&(wireless.uart)); Wireless_Init(&wireless); // Initialize gameboard uart XUartLite_Initialize(&gameboard_uart, XPAR_GAMEBOARD_UART_DEVICE_ID); XUartLite_ResetFifos(&gameboard_uart); // Initialize the interrupt controller XIntc_Initialize(&InterruptController, XPAR_INTC_0_DEVICE_ID); // Connect the wireless uart to the interrupt controller XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_WIRELESS_UART_INTERRUPT_INTR, (XInterruptHandler)XUartLite_InterruptHandler, (void *)&(wireless.uart)); // Connect the gameboard uart to the interrupt controller XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_GAMEBOARD_UART_INTERRUPT_INTR, (XInterruptHandler)XUartLite_InterruptHandler, (void *)&gameboard_uart); //XIntc_Connect(&InterruptController, XPAR_INTC_0_GPIO_0_VEC_ID, // (Xil_ExceptionHandler)GpioHandler, &Gpio); XIntc_Start(&InterruptController, XIN_REAL_MODE); // Enable interrupts for serial controllers XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_WIRELESS_UART_INTERRUPT_INTR); XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_GAMEBOARD_UART_INTERRUPT_INTR); // Enable interrupts for the GPIO //XIntc_Enable(&InterruptController, XPAR_INTC_0_GPIO_0_VEC_ID); Xil_ExceptionInit(); Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_InterruptHandler, &InterruptController); Xil_ExceptionEnable(); // Set up send/receive handlers for wireless uart XUartLite_SetSendHandler(&(wireless.uart), WirelessSendHandler, &(wireless.uart)); XUartLite_SetRecvHandler(&(wireless.uart), WirelessRecvHandler, &(wireless.uart)); //XUartLite_SetRecvHandler(&(wireless.uart), WirelessRecvHandlerNonBlocking, &(wireless.uart)); Wireless_Debug("Wireless should be set up now"); // Set up send/receive handlers for gameboard uart XUartLite_SetSendHandler(&gameboard_uart, GameboardSendHandler, &gameboard_uart); XUartLite_SetRecvHandler(&gameboard_uart, GameboardRecvHandler, &gameboard_uart); XUartLite_EnableInterrupt(&(wireless.uart)); XUartLite_EnableInterrupt(&gameboard_uart); // Enable interrupts for GPIO //XGpio_InterruptEnable(&Gpio, XGPIO_IR_CH2_MASK); //XGpio_InterruptGlobalEnable(&Gpio); // Set up PIT XExceptionHandler pithandler = &my_pitHandler; XExc_RegisterHandler(XEXC_ID_PIT_INT, pithandler, 0); XTime_PITEnableAutoReload(); // PIT should be set to 1ms XTime_PITSetInterval(300000); XExc_mEnableExceptions(XEXC_ALL); XTime_PITEnableInterrupt(); XTime_PITClearInterrupt(); }
/** * * Removes the handler for a specific exception Id. The stub handler is then * registered for this exception Id. * * @param Exception Id contains the ID of the exception source and should * be in the range of 0 to XEXC_ID_LAST. See xexception_l.h for further information. * @return None. * * @note * * None. * ****************************************************************************/ void XExc_RemoveHandler(Xuint8 ExceptionId) { XExc_RegisterHandler(ExceptionId, (XExceptionHandler)NullHandler, XNULL); }
/** * * This function setups the interrupt system so interrupts can occur for the * TEMAC. This function is application-specific since the actual system may or * may not have an interrupt controller. The TEMAC could be directly connected * to a processor without an interrupt controller. The user should modify this * function to fit the application. * * @param IntcInstancePtr is a pointer to the instance of the Intc component. * @param TemacInstancePtr is a pointer to the instance of the Temac * component. * @param TemacIntrId is the Interrupt ID and is typically * XPAR_<INTC_instance>_<TEMAC_instance>_IP2INTC_IRPT_INTR * value from xparameters.h. * * @return XST_SUCCESS if successful, otherwise XST_FAILURE. * * @note None. * ******************************************************************************/ static int TemacSetupIntrSystem(XIntc *IntcInstancePtr, XLlTemac *TemacInstancePtr, XLlDma *DmaInstancePtr, u16 TemacIntrId, u16 DmaRxIntrId, u16 DmaTxIntrId) { XLlDma_BdRing * TxRingPtr = &XLlDma_GetTxRing(DmaInstancePtr); XLlDma_BdRing * RxRingPtr = &XLlDma_GetRxRing(DmaInstancePtr); int Status; #ifndef TESTAPP_GEN /* * Initialize the interrupt controller and connect the ISR */ Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID); if (Status != XST_SUCCESS) { TemacUtilErrorTrap("Unable to intialize the interrupt controller"); return XST_FAILURE; } #endif Status = XIntc_Connect(IntcInstancePtr, TemacIntrId, (XInterruptHandler) TemacErrorHandler, TemacInstancePtr); Status |= XIntc_Connect(IntcInstancePtr, DmaTxIntrId, (XInterruptHandler) TxIntrHandler, TxRingPtr); Status |= XIntc_Connect(IntcInstancePtr, DmaRxIntrId, (XInterruptHandler) RxIntrHandler, RxRingPtr); if (Status != XST_SUCCESS) { TemacUtilErrorTrap("Unable to connect ISR to interrupt controller"); return XST_FAILURE; } #ifndef TESTAPP_GEN /* * Start the interrupt controller */ Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE); if (Status != XST_SUCCESS) { TemacUtilErrorTrap("Error starting intc"); return XST_FAILURE; } #endif /* * Enable interrupts from the hardware */ XIntc_Enable(IntcInstancePtr, TemacIntrId); XIntc_Enable(IntcInstancePtr, DmaTxIntrId); XIntc_Enable(IntcInstancePtr, DmaRxIntrId); #ifndef TESTAPP_GEN #ifdef __PPC__ /* * Initialize the PPC exception table */ XExc_Init(); /* * Register the interrupt controller with the exception table */ XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler) XIntc_InterruptHandler, IntcInstancePtr); /* * Enable non-critical exceptions */ XExc_mEnableExceptions(XEXC_NON_CRITICAL); #else /* * Connect the interrupt controller interrupt handler to the hardware * interrupt handling logic in the microblaze processor. */ microblaze_register_handler((XInterruptHandler) XIntc_InterruptHandler, IntcInstancePtr); /* * Enable interrupts in the Microblaze */ microblaze_enable_interrupts(); #endif #endif return XST_SUCCESS; }
/** * * This function setups the interrupt system such that interrupts can occur * for the UART. This function is application specific since the actual * system may or may not have an interrupt controller. The UART could be * directly connected to a processor without an interrupt controller. The * user should modify this function to fit the application. * * @param IntcInstancePtr is a pointer to the instance of the INTC component. * @param UartInstancePtr is a pointer to the instance of the UART component. * @param UartIntrId is the interrupt Id and is typically * XPAR_<INTC_instance>_<UARTNS550_instance>_IP2INTC_IRPT_INTR * value from xparameters.h. * * @return XST_SUCCESS if successful, otherwise XST_FAILURE * * * @note None * *******************************************************************************/ static XStatus UartNs550SetupIntrSystem(XIntc *IntcInstancePtr, XUartNs550 *UartInstancePtr, Xuint16 UartIntrId) { XStatus Status; #ifndef TESTAPP_GEN /* * Initialize the interrupt controller driver so that it is ready to use. */ Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } #endif /* * Connect a device driver handler that will be called when an interrupt * for the device occurs, the device driver handler performs the specific * interrupt processing for the device. */ Status = XIntc_Connect(IntcInstancePtr, UartIntrId, (XInterruptHandler)XUartNs550_InterruptHandler, (void *)UartInstancePtr); if (Status != XST_SUCCESS) { return XST_FAILURE; } #ifndef TESTAPP_GEN /* * Start the interrupt controller such that interrupts are enabled for * all devices that cause interrupts, specific real mode so that * the UART can cause interrupts thru the interrupt controller. */ Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE); if (Status != XST_SUCCESS) { return XST_FAILURE; } #endif /* * Enable the interrupt for the UartNs550. */ XIntc_Enable(IntcInstancePtr, UartIntrId); #ifndef TESTAPP_GEN /* * Initialize the PPC exception table. */ XExc_Init(); /* * Register the interrupt controller handler with the exception table. */ XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)XIntc_InterruptHandler, IntcInstancePtr); /* * Enable non-critical exceptions. */ XExc_mEnableExceptions(XEXC_NON_CRITICAL); #endif /* TESTAPP_GEN */ return XST_SUCCESS; }