XScuGic_Connect分析
生活随笔
收集整理的這篇文章主要介紹了
XScuGic_Connect分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
說明
最近在研究ZYNQ中斷的事情,感覺搞清楚Xilinx的一些官方函數或許有幫助吧。
一下是筆者對XScuGic_Connect的分析。
源代碼
XScuGic_Connect函數代碼如下,
/*****************************************************************************/ /** * * Makes the connection between the Int_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 XScuGic instance. * @param Int_Id contains the ID of the interrupt source and should be * in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1 * @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. * ****************************************************************************/ s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,Xil_InterruptHandler Handler, void *CallBackRef) {/** Assert the arguments*/Xil_AssertNonvoid(InstancePtr != NULL);Xil_AssertNonvoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);Xil_AssertNonvoid(Handler != NULL);Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);/** The Int_Id is used as an index into the table to select the proper* handler*/InstancePtr->Config->HandlerTable[Int_Id].Handler = (Xil_InterruptHandler)Handler;InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = CallBackRef;return XST_SUCCESS; }代碼分析
結合XScuGic_Connect函數代碼,分析如下,
/*****************************************************************************/ /** * * 該函數用于將識別中斷的函數(handler)與中斷源的中斷ID(Int_Id)。 * 該函數中的Callbackref參數作為調用中斷函數(handler)時的參數。 * * @參數 InstancePtr 為XScuGic實例的指針。 * @參數 Int_Id包含中斷源的ID,其取值應該在 0 到 XSCUGIC_MAX_NUM_INTR_INPUTS - 1 * @參數 中斷的處理函數 * @參數 CallBackRef為回調參考,通常為所連接驅動的實例指針。 * * @返回 * * - XST_SUCCESS 如果處理函數(handler)正確連接 * * @說明 * * 警告: 作為參數提供的處理函數handler,它將覆蓋之前連接的所有處理函數handler。 * ****************************************************************************/ s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,Xil_InterruptHandler Handler, void *CallBackRef) {/** 檢查輸入是否合法*/Xil_AssertNonvoid(InstancePtr != NULL); //指針非空Xil_AssertNonvoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS); //中斷ID取值合法Xil_AssertNonvoid(Handler != NULL); //處理函數非空Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); //指針就緒/** 參數Int_Id作為中斷表的索引,用于選擇相應的中斷處理函數handler*/InstancePtr->Config->HandlerTable[Int_Id].Handler = (Xil_InterruptHandler)Handler; //處理函數InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = CallBackRef; //回調參數return XST_SUCCESS; }總結
以上是生活随笔為你收集整理的XScuGic_Connect分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Matalab类定义
- 下一篇: MATLAB数字信号处理函数