📄 xintc.c
字号:
InstancePtr->IsStarted = 0;}/*****************************************************************************//**** Makes the connection between the Id of the interrupt source and the* associated handler that is to run when the interrupt is recognized. The* argument provided in this call as the Callbackref is used as the argument* for the handler when it 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.* @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.*****************************************************************************/int XIntc_Connect(XIntc * InstancePtr, u8 Id, XInterruptHandler Handler, void *CallBackRef){ /* * Assert the arguments */ XASSERT_NONVOID(InstancePtr != NULL); XASSERT_NONVOID(Id < XPAR_INTC_MAX_NUM_INTR_INPUTS); XASSERT_NONVOID(Handler != NULL); 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 NULL 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, u8 Id){ u32 CurrentIER; u32 Mask; /* * Assert the arguments */ XASSERT_VOID(InstancePtr != NULL); 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, u8 Id){ u32 CurrentIER; u32 Mask; /* * Assert the arguments */ XASSERT_VOID(InstancePtr != NULL); 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, u8 Id){ u32 CurrentIER; u32 Mask; /* * Assert the arguments */ XASSERT_VOID(InstancePtr != NULL); 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, u8 Id){ u32 Mask; /* * Assert the arguments */ XASSERT_VOID(InstancePtr != NULL); 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 != NULL); /* * 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 NULL if the device was not found.** @note None.*******************************************************************************/XIntc_Config *XIntc_LookupConfig(u16 DeviceId){ XIntc_Config *CfgPtr = NULL; 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 + -