]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/xadcps_v2_0/src/xadcps_intr.c
9002e7ccadb669247a0c868b2de14562a1f12582
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / xadcps_v2_0 / src / xadcps_intr.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2011 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xadcps_intr.c
36 * @addtogroup xadcps_v2_0
37 * @{
38 *
39 * This file contains interrupt handling API functions of the XADC
40 * device.
41 *
42 * The device must be configured at hardware build time to support interrupt
43 * for all the functions in this file to work.
44 *
45 * Refer to xadcps.h header file and device specification for more information.
46 *
47 * @note
48 *
49 * Calling the interrupt functions without including the interrupt component will
50 * result in asserts if asserts are enabled, and will result in a unpredictable
51 * behavior if the asserts are not enabled.
52 *
53 * <pre>
54 *
55 * MODIFICATION HISTORY:
56 *
57 * Ver   Who    Date     Changes
58 * ----- -----  -------- -----------------------------------------------------
59 * 1.00a ssb    12/22/11 First release based on the XPS/AXI xadc driver
60 *
61 * </pre>
62 *
63 ******************************************************************************/
64
65 /***************************** Include Files *********************************/
66
67 #include "xadcps.h"
68
69 /************************** Constant Definitions *****************************/
70
71 /**************************** Type Definitions *******************************/
72
73 /***************** Macros (Inline Functions) Definitions *********************/
74
75 /************************** Function Prototypes ******************************/
76
77 /************************** Variable Definitions *****************************/
78
79
80 /****************************************************************************/
81 /**
82 *
83 * This function enables the specified interrupts in the device.
84 *
85 * @param        InstancePtr is a pointer to the XAdcPs instance.
86 * @param        Mask is the bit-mask of the interrupts to be enabled.
87 *               Bit positions of 1 will be enabled. Bit positions of 0 will
88 *               keep the previous setting. This mask is formed by OR'ing
89 *               XADCPS_INTX_* bits defined in xadcps_hw.h.
90 *
91 * @return       None.
92 *
93 * @note         None.
94 *
95 *****************************************************************************/
96 void XAdcPs_IntrEnable(XAdcPs *InstancePtr, u32 Mask)
97 {
98         u32 RegValue;
99
100         /*
101          * Assert the arguments.
102          */
103         Xil_AssertVoid(InstancePtr != NULL);
104         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
105
106         /*
107          * Disable the specified interrupts in the IPIER.
108          */
109         RegValue = XAdcPs_ReadReg(InstancePtr->Config.BaseAddress,
110                                     XADCPS_INT_MASK_OFFSET);
111         RegValue &= ~(Mask & XADCPS_INTX_ALL_MASK);
112         XAdcPs_WriteReg(InstancePtr->Config.BaseAddress,
113                                 XADCPS_INT_MASK_OFFSET,
114                                 RegValue);
115 }
116
117
118 /****************************************************************************/
119 /**
120 *
121 * This function disables the specified interrupts in the device.
122 *
123 * @param        InstancePtr is a pointer to the XAdcPs instance.
124 * @param        Mask is the bit-mask of the interrupts to be disabled.
125 *               Bit positions of 1 will be disabled. Bit positions of 0 will
126 *               keep the previous setting. This mask is formed by OR'ing
127 *               XADCPS_INTX_* bits defined in xadcps_hw.h.
128 *
129 * @return       None.
130 *
131 * @note         None
132 *
133 *****************************************************************************/
134 void XAdcPs_IntrDisable(XAdcPs *InstancePtr, u32 Mask)
135 {
136         u32 RegValue;
137
138         /*
139          * Assert the arguments.
140          */
141         Xil_AssertVoid(InstancePtr != NULL);
142         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
143
144         /*
145          * Enable the specified interrupts in the IPIER.
146          */
147         RegValue = XAdcPs_ReadReg(InstancePtr->Config.BaseAddress,
148                                     XADCPS_INT_MASK_OFFSET);
149         RegValue |= (Mask & XADCPS_INTX_ALL_MASK);
150         XAdcPs_WriteReg(InstancePtr->Config.BaseAddress,
151                                 XADCPS_INT_MASK_OFFSET,
152                                 RegValue);
153 }
154 /****************************************************************************/
155 /**
156 *
157 * This function returns the enabled interrupts read from the Interrupt Mask
158 * Register (IPIER). Use the XADCPS_IPIXR_* constants defined in xadcps_hw.h to
159 * interpret the returned value.
160 *
161 * @param        InstancePtr is a pointer to the XAdcPs instance.
162 *
163 * @return       A 32-bit value representing the contents of the I.
164 *
165 * @note         None.
166 *
167 *****************************************************************************/
168 u32 XAdcPs_IntrGetEnabled(XAdcPs *InstancePtr)
169 {
170         /*
171          * Assert the arguments.
172          */
173         Xil_AssertNonvoid(InstancePtr != NULL);
174         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
175
176         /*
177          * Return the value read from the Interrupt Enable Register.
178          */
179         return (~ XAdcPs_ReadReg(InstancePtr->Config.BaseAddress,
180                                 XADCPS_INT_MASK_OFFSET) & XADCPS_INTX_ALL_MASK);
181 }
182
183 /****************************************************************************/
184 /**
185 *
186 * This function returns the interrupt status read from Interrupt Status
187 * Register(IPISR). Use the XADCPS_IPIXR_* constants defined in xadcps_hw.h
188 * to interpret the returned value.
189 *
190 * @param        InstancePtr is a pointer to the XAdcPs instance.
191 *
192 * @return       A 32-bit value representing the contents of the IPISR.
193 *
194 * @note         The device must be configured at hardware build time to include
195 *               interrupt component for this function to work.
196 *
197 *****************************************************************************/
198 u32 XAdcPs_IntrGetStatus(XAdcPs *InstancePtr)
199 {
200         /*
201          * Assert the arguments.
202          */
203         Xil_AssertNonvoid(InstancePtr != NULL);
204         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
205
206         /*
207          * Return the value read from the Interrupt Status register.
208          */
209         return XAdcPs_ReadReg(InstancePtr->Config.BaseAddress,
210                                 XADCPS_INT_STS_OFFSET) & XADCPS_INTX_ALL_MASK;
211 }
212
213 /****************************************************************************/
214 /**
215 *
216 * This function clears the specified interrupts in the Interrupt Status
217 * Register (IPISR).
218 *
219 * @param        InstancePtr is a pointer to the XAdcPs instance.
220 * @param        Mask is the bit-mask of the interrupts to be cleared.
221 *               Bit positions of 1 will be cleared. Bit positions of 0 will not
222 *               change the previous interrupt status. This mask is formed by
223 *               OR'ing XADCPS_IPIXR_* bits which are defined in xadcps_hw.h.
224 *
225 * @return       None.
226 *
227 * @note         None.
228 *
229 *****************************************************************************/
230 void XAdcPs_IntrClear(XAdcPs *InstancePtr, u32 Mask)
231 {
232         u32 RegValue;
233
234         /*
235          * Assert the arguments.
236          */
237         Xil_AssertVoid(InstancePtr != NULL);
238         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
239
240         /*
241          * Clear the specified interrupts in the Interrupt Status register.
242          */
243         RegValue = XAdcPs_ReadReg(InstancePtr->Config.BaseAddress,
244                                     XADCPS_INT_STS_OFFSET);
245         RegValue &= (Mask & XADCPS_INTX_ALL_MASK);
246         XAdcPs_WriteReg(InstancePtr->Config.BaseAddress, XADCPS_INT_STS_OFFSET,
247                           RegValue);
248
249 }
250 /** @} */