日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

XScuGic_Connect分析

發布時間:2024/10/14 编程问答 92 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。