?? xintc.c
字號:
* @param InstancePtr is a pointer to the XIntc instance to be worked on.* @param Id contains the ID of the interrupt source and should be in the* range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the* highest priority interrupt.* @param Handler to the handler for that interrupt.* @param CallBackRef is the callback reference, usually the instance pointer* of the connecting driver.** @return** - XST_SUCCESS if the handler was connected correctly.** @note** WARNING: The handler provided as an argument will overwrite any handler* that was previously connected.*****************************************************************************/XStatus XIntc_Connect(XIntc *InstancePtr, Xuint8 Id, XInterruptHandler Handler, void *CallBackRef){ /* * assert the arguments */ XASSERT_NONVOID(InstancePtr != XNULL); XASSERT_NONVOID(Id < XPAR_INTC_MAX_NUM_INTR_INPUTS); XASSERT_NONVOID(Handler != XNULL); XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); /* * the Id is used as an index into the table to select the proper handler */ InstancePtr->CfgPtr->HandlerTable[Id].Handler = Handler; InstancePtr->CfgPtr->HandlerTable[Id].CallBackRef = CallBackRef; return XST_SUCCESS;}/*****************************************************************************//**** Updates the interrupt table with the Null Handler and XNULL arguments at the* location pointed at by the Id. This effectively disconnects that interrupt* source from any handler. The interrupt is disabled also.** @param InstancePtr is a pointer to the XIntc instance to be worked on.* @param Id contains the ID of the interrupt source and should be in the* range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the* highest priority interrupt.** @return** None.** @note** None.*****************************************************************************/void XIntc_Disconnect(XIntc *InstancePtr, Xuint8 Id){ Xuint32 CurrentIER; Xuint32 Mask; /* * assert the arguments */ XASSERT_VOID(InstancePtr != XNULL); XASSERT_VOID(Id < XPAR_INTC_MAX_NUM_INTR_INPUTS); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); /* disable the interrupt such that it won't occur while disconnecting * the handler, only disable the specified interrupt id without modifying * the other interrupt ids */ CurrentIER = XIntc_In32(InstancePtr->BaseAddress + XIN_IER_OFFSET); Mask = XIntc_BitPosMask[Id]; /* convert from integer id to bit mask */ XIntc_Out32(InstancePtr->BaseAddress + XIN_IER_OFFSET, (CurrentIER & ~Mask)); /* disconnect the handler and connect a stub, the callback reference * must be set to this instance to allow unhandled interrupts to be * tracked */ InstancePtr->CfgPtr->HandlerTable[Id].Handler = StubHandler; InstancePtr->CfgPtr->HandlerTable[Id].CallBackRef = InstancePtr;}/*****************************************************************************//**** Enables the interrupt source provided as the argument Id. Any pending* interrupt condition for the specified Id will occur after this function is* called.** @param InstancePtr is a pointer to the XIntc instance to be worked on.* @param Id contains the ID of the interrupt source and should be in the* range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the* highest priority interrupt.** @return** None.** @note** None.*****************************************************************************/void XIntc_Enable(XIntc *InstancePtr, Xuint8 Id){ Xuint32 CurrentIER; Xuint32 Mask; /* * assert the arguments */ XASSERT_VOID(InstancePtr != XNULL); XASSERT_VOID(Id < XPAR_INTC_MAX_NUM_INTR_INPUTS); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); /* * the Id is used to create the appropriate mask for the * desired bit position. Id currently limited to 0 - 31 */ Mask = XIntc_BitPosMask[Id]; /* * enable the selected interrupt source by reading the interrupt enable * register and then modifying only the specified interrupt id enable */ CurrentIER = XIntc_In32(InstancePtr->BaseAddress + XIN_IER_OFFSET); XIntc_Out32(InstancePtr->BaseAddress + XIN_IER_OFFSET, (CurrentIER | Mask));}/*****************************************************************************//**** Disables the interrupt source provided as the argument Id such that the* interrupt controller will not cause interrupts for the specified Id. The* interrupt controller will continue to hold an interrupt condition for the* Id, but will not cause an interrupt.** @param InstancePtr is a pointer to the XIntc instance to be worked on.* @param Id contains the ID of the interrupt source and should be in the* range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the* highest priority interrupt.** @return** None.** @note** None.*****************************************************************************/void XIntc_Disable(XIntc *InstancePtr, Xuint8 Id){ Xuint32 CurrentIER; Xuint32 Mask; /* * assert the arguments */ XASSERT_VOID(InstancePtr != XNULL); XASSERT_VOID(Id < XPAR_INTC_MAX_NUM_INTR_INPUTS); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); /* * the Id is used to create the appropriate mask for the * desired bit position. Id currently limited to 0 - 31 */ Mask = XIntc_BitPosMask[Id]; /* * disable the selected interrupt source by reading the interrupt enable * register and then modifying only the specified interrupt id */ CurrentIER = XIntc_In32(InstancePtr->BaseAddress + XIN_IER_OFFSET); XIntc_Out32(InstancePtr->BaseAddress + XIN_IER_OFFSET, (CurrentIER & ~Mask));}/*****************************************************************************//**** Acknowledges the interrupt source provided as the argument Id. When the* interrupt is acknowledged, it causes the interrupt controller to clear its* interrupt condition.** @param InstancePtr is a pointer to the XIntc instance to be worked on.* @param Id contains the ID of the interrupt source and should be in the* range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the* highest priority interrupt.** @return** None.** @note** None.*****************************************************************************/void XIntc_Acknowledge(XIntc *InstancePtr, Xuint8 Id){ Xuint32 Mask; /* * assert the arguments */ XASSERT_VOID(InstancePtr != XNULL); XASSERT_VOID(Id < XPAR_INTC_MAX_NUM_INTR_INPUTS); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); /* * the Id is used to create the appropriate mask for the * desired bit position. Id currently limited to 0 - 31 */ Mask = XIntc_BitPosMask[Id]; /* * acknowledge the selected interrupt source, no read of the acknowledge * register is necessary since only the bits set in the mask will be * affected by the write */ XIntc_Out32(InstancePtr->BaseAddress + XIN_IAR_OFFSET, Mask);}/*****************************************************************************//**** A stub for the asynchronous callback. The stub is here in case the upper* layers forget to set the handler.** @param CallBackRef is a pointer to the upper layer callback reference** @return** None.** @note** None.*******************************************************************************/static void StubHandler(void *CallBackRef){ /* * verify that the inputs are valid */ XASSERT_VOID(CallBackRef != XNULL); /* * indicate another unhandled interrupt for stats */ ((XIntc *)CallBackRef)->UnhandledInterrupts++;}/*****************************************************************************//**** Looks up the device configuration based on the unique device ID. A table* contains the configuration info for each device in the system.** @param DeviceId is the unique identifier for a device.** @return** A pointer to the XIntc configuration structure for the specified device, or* XNULL if the device was not found.** @note** None.*******************************************************************************/XIntc_Config *XIntc_LookupConfig(Xuint16 DeviceId){ XIntc_Config *CfgPtr = XNULL; int i; for (i=0; i < XPAR_XINTC_NUM_INSTANCES; i++) { if (XIntc_ConfigTable[i].DeviceId == DeviceId) { CfgPtr = &XIntc_ConfigTable[i]; break; } } return CfgPtr;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -