xscugic-凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
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; }总结
以上是凯发k8官方网为你收集整理的xscugic_connect分析的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: