00001 /* $Id: */ 00002 /****************************************************************************** 00003 * (c) Copyright 2009 Xilinx, Inc. All rights reserved. 00004 * 00005 * This file contains confidential and proprietary information 00006 * of Xilinx, Inc. and is protected under U.S. and 00007 * international copyright and other intellectual property 00008 * laws. 00009 * 00010 * DISCLAIMER 00011 * This disclaimer is not a license and does not grant any 00012 * rights to the materials distributed herewith. Except as 00013 * otherwise provided in a valid license issued to you by 00014 * Xilinx, and to the maximum extent permitted by applicable 00015 * law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND 00016 * WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES 00017 * AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING 00018 * BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- 00019 * INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and 00020 * (2) Xilinx shall not be liable (whether in contract or tort, 00021 * including negligence, or under any other theory of 00022 * liability) for any loss or damage of any kind or nature 00023 * related to, arising under or in connection with these 00024 * materials, including for any direct, or any indirect, 00025 * special, incidental, or consequential loss or damage 00026 * (including loss of data, profits, goodwill, or any type of 00027 * loss or damage suffered as a result of any action brought 00028 * by a third party) even if such damage or loss was 00029 * reasonably foreseeable or Xilinx had been advised of the 00030 * possibility of the same. 00031 * 00032 * CRITICAL APPLICATIONS 00033 * Xilinx products are not designed or intended to be fail- 00034 * safe, or for use in any application requiring fail-safe 00035 * performance, such as life-support or safety devices or 00036 * systems, Class III medical devices, nuclear facilities, 00037 * applications related to the deployment of airbags, or any 00038 * other applications that could lead to death, personal 00039 * injury, or severe property or environmental damage 00040 * (individually and collectively, "Critical 00041 * Applications"). Customer assumes the sole risk and 00042 * liability of any use of Xilinx products in Critical 00043 * Applications, subject only to applicable laws and 00044 * regulations governing limitations on product liability. 00045 * 00046 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS 00047 * PART OF THIS FILE AT ALL TIMES. 00048 * 00049 * All rights reserved. 00050 * 00051 ******************************************************************************/ 00052 /*****************************************************************************/ 00053 /** 00054 * 00055 * @file xtimebase_intr.c 00056 * 00057 * This code contains interrupt related functions of Xilinx MVI Video TimeBase 00058 * device driver. Please see xtimebase.h for more details of the driver. 00059 * 00060 * <pre> 00061 * MODIFICATION HISTORY: 00062 * 00063 * Ver Who Date Changes 00064 * ----- ---- -------- ----------------------------------------------- 00065 * 1.00a xd 08/05/08 First release 00066 * 1.01a xd 07/23/10 Added GIER; Added more h/w generic info into 00067 * xparameters.h; Feed callbacks with pending 00068 * interrupt info. Added Doxygen & Version support 00069 * </pre> 00070 * 00071 ******************************************************************************/ 00072 00073 #include "xtimebase.h" 00074 00075 /*****************************************************************************/ 00076 /** 00077 * 00078 * This function is the interrupt handler for the TimeBase driver. 00079 * 00080 * This handler reads the pending interrupt from the IER/ISR, determines the 00081 * source of the interrupts, calls according callbacks, and finally clears the 00082 * interrupts. 00083 * 00084 * The application is responsible for connecting this function to the interrupt 00085 * system. Application beyond this driver is also responsible for providing 00086 * callbacks to handle interrupts and installing the callbacks using 00087 * XTimeBase_SetCallBack() during initialization phase. An example delivered 00088 * with this driver demonstrates how this could be done. 00089 * 00090 * @param InstancePtr is a pointer to the XTimeBase instance that just 00091 * interrupted. 00092 * @return None. 00093 * @note None. 00094 * 00095 ******************************************************************************/ 00096 void XTimeBase_IntrHandler(void *InstancePtr) 00097 { 00098 u32 PendingIntr; 00099 u32 ErrorStatus; 00100 XTimeBase *XTimeBasePtr = (XTimeBase *) InstancePtr; 00101 00102 /* Validate parameters */ 00103 XASSERT_VOID(XTimeBasePtr != NULL); 00104 XASSERT_VOID(XTimeBasePtr->IsReady == XCOMPONENT_IS_READY); 00105 00106 /* Get pending interrupts */ 00107 PendingIntr = XTimeBase_IntrGetPending(XTimeBasePtr); 00108 00109 /* Clear pending interrupt(s) */ 00110 XTimeBase_IntrClear(XTimeBasePtr, PendingIntr); 00111 00112 /* Spurious interrupt has happened */ 00113 if (0 == (PendingIntr | XTB_IXR_ALLINTR_MASK)) { 00114 ErrorStatus = 0; 00115 XTimeBasePtr->ErrCallBack(XTimeBasePtr->ErrRef, ErrorStatus); 00116 return; 00117 } 00118 00119 /* A generator event has happened */ 00120 if ((PendingIntr & XTB_IXR_G_ALL_MASK)) 00121 XTimeBasePtr->GeneratorCallBack(XTimeBasePtr->GeneratorRef, 00122 PendingIntr); 00123 00124 /* A detector event has happened */ 00125 if ((PendingIntr & XTB_IXR_D_ALL_MASK)) 00126 XTimeBasePtr->DetectorCallBack(XTimeBasePtr->DetectorRef, 00127 PendingIntr); 00128 00129 /* A frame sync is done */ 00130 if ((PendingIntr & XTB_IXR_FSYNCALL_MASK)) 00131 XTimeBasePtr->FrameSyncCallBack(XTimeBasePtr->FrameSyncRef, 00132 PendingIntr); 00133 00134 /* A signal lock is detected */ 00135 if ((PendingIntr & XTB_IXR_LOCKALL_MASK)) 00136 XTimeBasePtr->LockCallBack(XTimeBasePtr->LockRef, 00137 PendingIntr); 00138 } 00139 00140 00141 /*****************************************************************************/ 00142 /** 00143 * 00144 * This routine installs an asynchronous callback function for the given 00145 * HandlerType: 00146 * 00147 * <pre> 00148 * HandlerType Callback Function Type 00149 * ----------------------- --------------------------- 00150 * XTB_HANDLER_FRAMESYNC XTimeBase_FrameSyncCallBack 00151 * XTB_HANDLER_LOCK XTimeBase_LockCallBack 00152 * XTB_HANDLER_DETECTOR XTimeBase_DetectorCallBack 00153 * XTB_HANDLER_GENERATOR XTimeBase_GeneratorCallBack 00154 * XTB_HANDLER_ERROR XTimeBase_ErrCallBack 00155 * 00156 * HandlerType Invoked by this driver when: 00157 * ----------------------- -------------------------------------------------- 00158 * XTB_HANDLER_FRAMESYNC A frame sync event happens 00159 * XTB_HANDLER_LOCK A signal lock event happens 00160 * XTB_HANDLER_DETECTOR A detector related event happens 00161 * XTB_HANDLER_GENERATOR A generator related event happens 00162 * XTB_HANDLER_ERROR An error condition happens 00163 * 00164 * </pre> 00165 * 00166 * @param InstancePtr is a pointer to the XTimeBase instance to be worked 00167 * on. 00168 * @param HandlerType specifies which callback is to be attached. 00169 * @param CallbackFunc is the address of the callback function. 00170 * @param CallbackRef is a user data item that will be passed to the 00171 * callback function when it is invoked. 00172 * 00173 * @return 00174 * - XST_SUCCESS when handler is installed. 00175 * - XST_INVALID_PARAM when HandlerType is invalid. 00176 * 00177 * @note 00178 * Invoking this function for a handler that already has been installed replaces 00179 * it with the new handler. 00180 * 00181 ******************************************************************************/ 00182 int XTimeBase_SetCallBack(XTimeBase *InstancePtr, u32 HandlerType, 00183 void *CallBackFunc, void *CallBackRef) 00184 { 00185 XASSERT_NONVOID(InstancePtr != NULL); 00186 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); 00187 00188 switch (HandlerType) { 00189 case XTB_HANDLER_FRAMESYNC: 00190 InstancePtr->FrameSyncCallBack = 00191 (XTimeBase_CallBack) CallBackFunc; 00192 InstancePtr->FrameSyncRef = CallBackRef; 00193 break; 00194 00195 case XTB_HANDLER_LOCK: 00196 InstancePtr->LockCallBack = (XTimeBase_CallBack) CallBackFunc; 00197 InstancePtr->LockRef = CallBackRef; 00198 break; 00199 00200 case XTB_HANDLER_DETECTOR: 00201 InstancePtr->DetectorCallBack = 00202 (XTimeBase_CallBack) CallBackFunc; 00203 InstancePtr->DetectorRef = CallBackRef; 00204 break; 00205 00206 case XTB_HANDLER_GENERATOR: 00207 InstancePtr->GeneratorCallBack = 00208 (XTimeBase_CallBack) CallBackFunc; 00209 InstancePtr->GeneratorRef = CallBackRef; 00210 break; 00211 00212 case XTB_HANDLER_ERROR: 00213 InstancePtr->ErrCallBack = 00214 (XTimeBase_ErrorCallBack) CallBackFunc; 00215 InstancePtr->ErrRef = CallBackRef; 00216 break; 00217 00218 default: 00219 return XST_INVALID_PARAM; 00220 00221 } 00222 return XST_SUCCESS; 00223 }