1 /******************************************************************************
3 * Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /****************************************************************************/
35 * @file xscutimer_hw.h
37 * This file contains the hardware interface to the Timer.
40 * MODIFICATION HISTORY:
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
53 ******************************************************************************/
54 #ifndef XSCUTIMER_HW_H /* prevent circular inclusions */
55 #define XSCUTIMER_HW_H /* by using protection macros */
61 /***************************** Include Files *********************************/
62 #include "xil_types.h"
64 #include "xil_assert.h"
65 /************************** Constant Definitions *****************************/
67 /** @name Register Map
68 * Offsets of registers from the start of the device
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
79 /** @name Timer Control register
80 * This register bits control the prescaler, Intr enable,
81 * auto-reload and timer enable.
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 */
92 /** @name Interrupt Status register
93 * This register indicates the Timer counter register has reached zero.
97 #define XSCUTIMER_ISR_EVENT_FLAG_MASK 0x00000001 /**< Event flag */
100 /**************************** Type Definitions *******************************/
102 /***************** Macros (Inline Functions) Definitions *********************/
104 /****************************************************************************/
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.
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.
116 * @note C-style signature:
117 * void XScuTimer_SetLoadReg(u32 BaseAddr, u32 Value)
119 ******************************************************************************/
120 #define XScuTimer_SetLoadReg(BaseAddr, Value) \
121 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_LOAD_OFFSET, Value)
123 /****************************************************************************/
126 * Returns the current timer load register value.
128 * @param BaseAddr is the base address of the scu timer.
130 * @return Contents of the timer load register.
132 * @note C-style signature:
133 * u32 XScuTimer_GetLoadReg(u32 BaseAddr)
135 ******************************************************************************/
136 #define XScuTimer_GetLoadReg(BaseAddr) \
137 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_LOAD_OFFSET)
139 /****************************************************************************/
142 * Write to the timer counter register.
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.
149 * @note C-style signature:
150 * void XScuTimer_SetCounterReg(u32 BaseAddr, u32 Value)
152 ******************************************************************************/
153 #define XScuTimer_SetCounterReg(BaseAddr, Value) \
154 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET, Value)
156 /****************************************************************************/
159 * Returns the current timer counter register value.
161 * @param BaseAddr is the base address of the scu timer.
163 * @return Contents of the timer counter register.
165 * @note C-style signature:
166 u32 XScuTimer_GetCounterReg(u32 BaseAddr)
168 ******************************************************************************/
169 #define XScuTimer_GetCounterReg(BaseAddr) \
170 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET)
172 /****************************************************************************/
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.
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.
184 * @note C-style signature:
185 * void XScuTimer_SetControlReg(u32 BaseAddr, u32 Value)
187 ******************************************************************************/
188 #define XScuTimer_SetControlReg(BaseAddr, Value) \
189 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET, Value)
191 /****************************************************************************/
194 * Returns the current timer load register value.
196 * @param BaseAddr is the base address of the scu timer.
198 * @return Contents of the timer load register.
200 * @note C-style signature:
201 u32 XScuTimer_GetControlReg(u32 BaseAddr)
203 ******************************************************************************/
204 #define XScuTimer_GetControlReg(BaseAddr) \
205 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET)
207 /****************************************************************************/
210 * Write to the timer counter register.
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.
217 * @note C-style signature:
218 * void XScuTimer_SetIntrReg(u32 BaseAddr, u32 Value)
220 ******************************************************************************/
221 #define XScuTimer_SetIntrReg(BaseAddr, Value) \
222 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_ISR_OFFSET, Value)
224 /****************************************************************************/
227 * Returns the current timer counter register value.
229 * @param BaseAddr is the base address of the scu timer.
231 * @return Contents of the timer counter register.
233 * @note C-style signature:
234 u32 XScuTimer_GetIntrReg(u32 BaseAddr)
236 ******************************************************************************/
237 #define XScuTimer_GetIntrReg(BaseAddr) \
238 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_ISR_OFFSET)
240 /****************************************************************************/
243 * Read from the given Timer register.
245 * @param BaseAddr is the base address of the device
246 * @param RegOffset is the register offset to be read
248 * @return The 32-bit value of the register
250 * @note C-style signature:
251 * u32 XScuTimer_ReadReg(u32 BaseAddr, u32 RegOffset)
253 *****************************************************************************/
254 #define XScuTimer_ReadReg(BaseAddr, RegOffset) \
255 Xil_In32((BaseAddr) + (RegOffset))
257 /****************************************************************************/
260 * Write to the given Timer register.
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
268 * @note C-style signature:
269 * void XScuTimer_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)
271 *****************************************************************************/
272 #define XScuTimer_WriteReg(BaseAddr, RegOffset, Data) \
273 Xil_Out32((BaseAddr) + (RegOffset), (Data))
275 /************************** Function Prototypes ******************************/
277 /************************** Variable Definitions *****************************/
283 #endif /* end of protection macro */