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