]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/scutimer_v2_0/src/xscutimer_hw.h
423744cf81e7fa3a306120e98eae2adb9b727bd9
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / scutimer_v2_0 / src / xscutimer_hw.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 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 xscutimer_hw.h
36 *
37 * This file contains the hardware interface to the Timer.
38 *
39 * <pre>
40 * MODIFICATION HISTORY:
41 *
42 * Ver   Who Date     Changes
43 * ----- --- -------- ---------------------------------------------
44 * 1.00a nm  03/10/10 First release
45 * 1.01a sdm 02/02/12 Added low level macros to read/write load, counter, control
46 *                    and interrupt registers
47 * 1.02a  sg 07/17/12 Included xil_assert.h for CR 667947. This is an issue
48 *                    when the xstatus.h in the common driver overwrites
49 *                    the xstatus.h of the standalone BSP during the
50 *                    libgen.
51 * </pre>
52 *
53 ******************************************************************************/
54 #ifndef XSCUTIMER_HW_H          /* prevent circular inclusions */
55 #define XSCUTIMER_HW_H          /* by using protection macros */
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 /***************************** Include Files *********************************/
62 #include "xil_types.h"
63 #include "xil_io.h"
64 #include "xil_assert.h"
65 /************************** Constant Definitions *****************************/
66
67 /** @name Register Map
68  * Offsets of registers from the start of the device
69  * @{
70  */
71
72 #define XSCUTIMER_LOAD_OFFSET           0x00 /**< Timer Load Register */
73 #define XSCUTIMER_COUNTER_OFFSET        0x04 /**< Timer Counter Register */
74 #define XSCUTIMER_CONTROL_OFFSET        0x08 /**< Timer Control Register */
75 #define XSCUTIMER_ISR_OFFSET            0x0C /**< Timer Interrupt
76                                                   Status Register */
77 /* @} */
78
79 /** @name Timer Control register
80  * This register bits control the prescaler, Intr enable,
81  * auto-reload and timer enable.
82  * @{
83  */
84
85 #define XSCUTIMER_CONTROL_PRESCALER_MASK        0x0000FF00 /**< Prescaler */
86 #define XSCUTIMER_CONTROL_PRESCALER_SHIFT       8
87 #define XSCUTIMER_CONTROL_IRQ_ENABLE_MASK       0x00000004 /**< Intr enable */
88 #define XSCUTIMER_CONTROL_AUTO_RELOAD_MASK      0x00000002 /**< Auto-reload */
89 #define XSCUTIMER_CONTROL_ENABLE_MASK           0x00000001 /**< Timer enable */
90 /* @} */
91
92 /** @name Interrupt Status register
93  * This register indicates the Timer counter register has reached zero.
94  * @{
95  */
96
97 #define XSCUTIMER_ISR_EVENT_FLAG_MASK           0x00000001 /**< Event flag */
98 /*@}*/
99
100 /**************************** Type Definitions *******************************/
101
102 /***************** Macros (Inline Functions) Definitions *********************/
103
104 /****************************************************************************/
105 /**
106 *
107 * Write to the timer load register. This will also update the
108 * timer counter register with the new value. This macro can be used to
109 * change the time-out value.
110 *
111 * @param        BaseAddr is the base address of the scu timer.
112 * @param        Value is the count to be loaded in to the load register.
113 *
114 * @return       None.
115 *
116 * @note         C-style signature:
117 *               void XScuTimer_SetLoadReg(u32 BaseAddr, u32 Value)
118 *
119 ******************************************************************************/
120 #define XScuTimer_SetLoadReg(BaseAddr, Value)                           \
121         XScuTimer_WriteReg(BaseAddr, XSCUTIMER_LOAD_OFFSET, Value)
122
123 /****************************************************************************/
124 /**
125 *
126 * Returns the current timer load register value.
127 *
128 * @param        BaseAddr is the base address of the scu timer.
129 *
130 * @return       Contents of the timer load register.
131 *
132 * @note         C-style signature:
133 *               u32 XScuTimer_GetLoadReg(u32 BaseAddr)
134 *
135 ******************************************************************************/
136 #define XScuTimer_GetLoadReg(BaseAddr)                                  \
137         XScuTimer_ReadReg(BaseAddr, XSCUTIMER_LOAD_OFFSET)
138
139 /****************************************************************************/
140 /**
141 *
142 * Write to the timer counter register.
143 *
144 * @param        BaseAddr is the base address of the scu timer.
145 * @param        Value is the count to be loaded in to the counter register.
146 *
147 * @return       None.
148 *
149 * @note         C-style signature:
150 *               void XScuTimer_SetCounterReg(u32 BaseAddr, u32 Value)
151 *
152 ******************************************************************************/
153 #define XScuTimer_SetCounterReg(BaseAddr, Value)                        \
154         XScuTimer_WriteReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET, Value)
155
156 /****************************************************************************/
157 /**
158 *
159 * Returns the current timer counter register value.
160 *
161 * @param        BaseAddr is the base address of the scu timer.
162 *
163 * @return       Contents of the timer counter register.
164 *
165 * @note         C-style signature:
166                 u32 XScuTimer_GetCounterReg(u32 BaseAddr)
167 *
168 ******************************************************************************/
169 #define XScuTimer_GetCounterReg(BaseAddr)                               \
170         XScuTimer_ReadReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET)
171
172 /****************************************************************************/
173 /**
174 *
175 * Write to the timer load register. This will also update the
176 * timer counter register with the new value. This macro can be used to
177 * change the time-out value.
178 *
179 * @param        BaseAddr is the base address of the scu timer.
180 * @param        Value is the count to be loaded in to the load register.
181 *
182 * @return       None.
183 *
184 * @note         C-style signature:
185 *               void XScuTimer_SetControlReg(u32 BaseAddr, u32 Value)
186 *
187 ******************************************************************************/
188 #define XScuTimer_SetControlReg(BaseAddr, Value)                        \
189         XScuTimer_WriteReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET, Value)
190
191 /****************************************************************************/
192 /**
193 *
194 * Returns the current timer load register value.
195 *
196 * @param        BaseAddr is the base address of the scu timer.
197 *
198 * @return       Contents of the timer load register.
199 *
200 * @note         C-style signature:
201                 u32 XScuTimer_GetControlReg(u32 BaseAddr)
202 *
203 ******************************************************************************/
204 #define XScuTimer_GetControlReg(BaseAddr)                               \
205         XScuTimer_ReadReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET)
206
207 /****************************************************************************/
208 /**
209 *
210 * Write to the timer counter register.
211 *
212 * @param        BaseAddr is the base address of the scu timer.
213 * @param        Value is the count to be loaded in to the counter register.
214 *
215 * @return       None.
216 *
217 * @note         C-style signature:
218 *               void XScuTimer_SetIntrReg(u32 BaseAddr, u32 Value)
219 *
220 ******************************************************************************/
221 #define XScuTimer_SetIntrReg(BaseAddr, Value)                           \
222         XScuTimer_WriteReg(BaseAddr, XSCUTIMER_ISR_OFFSET, Value)
223
224 /****************************************************************************/
225 /**
226 *
227 * Returns the current timer counter register value.
228 *
229 * @param        BaseAddr is the base address of the scu timer.
230 *
231 * @return       Contents of the timer counter register.
232 *
233 * @note         C-style signature:
234                 u32 XScuTimer_GetIntrReg(u32 BaseAddr)
235 *
236 ******************************************************************************/
237 #define XScuTimer_GetIntrReg(BaseAddr)                                  \
238         XScuTimer_ReadReg(BaseAddr, XSCUTIMER_ISR_OFFSET)
239
240 /****************************************************************************/
241 /**
242 *
243 * Read from the given Timer register.
244 *
245 * @param        BaseAddr is the base address of the device
246 * @param        RegOffset is the register offset to be read
247 *
248 * @return       The 32-bit value of the register
249 *
250 * @note         C-style signature:
251 *               u32 XScuTimer_ReadReg(u32 BaseAddr, u32 RegOffset)
252 *
253 *****************************************************************************/
254 #define XScuTimer_ReadReg(BaseAddr, RegOffset)          \
255         Xil_In32((BaseAddr) + (RegOffset))
256
257 /****************************************************************************/
258 /**
259 *
260 * Write to the given Timer register.
261 *
262 * @param        BaseAddr is the base address of the device
263 * @param        RegOffset is the register offset to be written
264 * @param        Data is the 32-bit value to write to the register
265 *
266 * @return       None.
267 *
268 * @note         C-style signature:
269 *               void XScuTimer_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)
270 *
271 *****************************************************************************/
272 #define XScuTimer_WriteReg(BaseAddr, RegOffset, Data)   \
273         Xil_Out32((BaseAddr) + (RegOffset), (Data))
274
275 /************************** Function Prototypes ******************************/
276
277 /************************** Variable Definitions *****************************/
278
279 #ifdef __cplusplus
280 }
281 #endif
282
283 #endif  /* end of protection macro */