1 /******************************************************************************
3 * (c) Copyright 2010-12 Xilinx, Inc. All rights reserved.
5 * This file contains confidential and proprietary information of Xilinx, Inc.
6 * and is protected under U.S. and international copyright and other
7 * intellectual property laws.
10 * This disclaimer is not a license and does not grant any rights to the
11 * materials distributed herewith. Except as otherwise provided in a valid
12 * license issued to you by Xilinx, and to the maximum extent permitted by
13 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
14 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
15 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
16 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
17 * and (2) Xilinx shall not be liable (whether in contract or tort, including
18 * negligence, or under any other theory of liability) for any loss or damage
19 * of any kind or nature related to, arising under or in connection with these
20 * materials, including for any direct, or any indirect, special, incidental,
21 * or consequential loss or damage (including loss of data, profits, goodwill,
22 * or any type of loss or damage suffered as a result of any action brought by
23 * a third party) even if such damage or loss was reasonably foreseeable or
24 * Xilinx had been advised of the possibility of the same.
26 * CRITICAL APPLICATIONS
27 * Xilinx products are not designed or intended to be fail-safe, or for use in
28 * any application requiring fail-safe performance, such as life-support or
29 * safety devices or systems, Class III medical devices, nuclear facilities,
30 * applications related to the deployment of airbags, or any other applications
31 * that could lead to death, personal injury, or severe property or
32 * environmental damage (individually and collectively, "Critical
33 * Applications"). Customer assumes the sole risk and liability of any use of
34 * Xilinx products in Critical Applications, subject only to applicable laws
35 * and regulations governing limitations on product liability.
37 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
40 ******************************************************************************/
41 /****************************************************************************/
44 * @file xscutimer_hw.h
46 * This file contains the hardware interface to the Timer.
49 * MODIFICATION HISTORY:
51 * Ver Who Date Changes
52 * ----- --- -------- ---------------------------------------------
53 * 1.00a nm 03/10/10 First release
54 * 1.01a sdm 02/02/12 Added low level macros to read/write load, counter, control
55 * and interrupt registers
56 * 1.02a sg 07/17/12 Included xil_assert.h for CR 667947. This is an issue
57 * when the xstatus.h in the common driver overwrites
58 * the xstatus.h of the standalone BSP during the
62 ******************************************************************************/
63 #ifndef XSCUTIMER_HW_H /* prevent circular inclusions */
64 #define XSCUTIMER_HW_H /* by using protection macros */
70 /***************************** Include Files *********************************/
71 #include "xil_types.h"
73 #include "xil_assert.h"
74 /************************** Constant Definitions *****************************/
76 /** @name Register Map
77 * Offsets of registers from the start of the device
81 #define XSCUTIMER_LOAD_OFFSET 0x00 /**< Timer Load Register */
82 #define XSCUTIMER_COUNTER_OFFSET 0x04 /**< Timer Counter Register */
83 #define XSCUTIMER_CONTROL_OFFSET 0x08 /**< Timer Control Register */
84 #define XSCUTIMER_ISR_OFFSET 0x0C /**< Timer Interrupt
88 /** @name Timer Control register
89 * This register bits control the prescaler, Intr enable,
90 * auto-reload and timer enable.
94 #define XSCUTIMER_CONTROL_PRESCALER_MASK 0x0000FF00 /**< Prescaler */
95 #define XSCUTIMER_CONTROL_PRESCALER_SHIFT 8
96 #define XSCUTIMER_CONTROL_IRQ_ENABLE_MASK 0x00000004 /**< Intr enable */
97 #define XSCUTIMER_CONTROL_AUTO_RELOAD_MASK 0x00000002 /**< Auto-reload */
98 #define XSCUTIMER_CONTROL_ENABLE_MASK 0x00000001 /**< Timer enable */
101 /** @name Interrupt Status register
102 * This register indicates the Timer counter register has reached zero.
106 #define XSCUTIMER_ISR_EVENT_FLAG_MASK 0x00000001 /**< Event flag */
109 /**************************** Type Definitions *******************************/
111 /***************** Macros (Inline Functions) Definitions *********************/
113 /****************************************************************************/
116 * Write to the timer load register. This will also update the
117 * timer counter register with the new value. This macro can be used to
118 * change the time-out value.
120 * @param BaseAddr is the base address of the scu timer.
121 * @param Value is the count to be loaded in to the load register.
125 * @note C-style signature:
126 * void XScuTimer_SetLoadReg(u32 BaseAddr, u32 Value)
128 ******************************************************************************/
129 #define XScuTimer_SetLoadReg(BaseAddr, Value) \
130 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_LOAD_OFFSET, Value)
132 /****************************************************************************/
135 * Returns the current timer load register value.
137 * @param BaseAddr is the base address of the scu timer.
139 * @return Contents of the timer load register.
141 * @note C-style signature:
142 * u32 XScuTimer_GetLoadReg(u32 BaseAddr)
144 ******************************************************************************/
145 #define XScuTimer_GetLoadReg(BaseAddr) \
146 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_LOAD_OFFSET)
148 /****************************************************************************/
151 * Write to the timer counter register.
153 * @param BaseAddr is the base address of the scu timer.
154 * @param Value is the count to be loaded in to the counter register.
158 * @note C-style signature:
159 * void XScuTimer_SetCounterReg(u32 BaseAddr, u32 Value)
161 ******************************************************************************/
162 #define XScuTimer_SetCounterReg(BaseAddr, Value) \
163 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET, Value)
165 /****************************************************************************/
168 * Returns the current timer counter register value.
170 * @param BaseAddr is the base address of the scu timer.
172 * @return Contents of the timer counter register.
174 * @note C-style signature:
175 u32 XScuTimer_GetCounterReg(u32 BaseAddr)
177 ******************************************************************************/
178 #define XScuTimer_GetCounterReg(BaseAddr) \
179 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET)
181 /****************************************************************************/
184 * Write to the timer load register. This will also update the
185 * timer counter register with the new value. This macro can be used to
186 * change the time-out value.
188 * @param BaseAddr is the base address of the scu timer.
189 * @param Value is the count to be loaded in to the load register.
193 * @note C-style signature:
194 * void XScuTimer_SetControlReg(u32 BaseAddr, u32 Value)
196 ******************************************************************************/
197 #define XScuTimer_SetControlReg(BaseAddr, Value) \
198 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET, Value)
200 /****************************************************************************/
203 * Returns the current timer load register value.
205 * @param BaseAddr is the base address of the scu timer.
207 * @return Contents of the timer load register.
209 * @note C-style signature:
210 u32 XScuTimer_GetControlReg(u32 BaseAddr)
212 ******************************************************************************/
213 #define XScuTimer_GetControlReg(BaseAddr) \
214 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET)
216 /****************************************************************************/
219 * Write to the timer counter register.
221 * @param BaseAddr is the base address of the scu timer.
222 * @param Value is the count to be loaded in to the counter register.
226 * @note C-style signature:
227 * void XScuTimer_SetIntrReg(u32 BaseAddr, u32 Value)
229 ******************************************************************************/
230 #define XScuTimer_SetIntrReg(BaseAddr, Value) \
231 XScuTimer_WriteReg(BaseAddr, XSCUTIMER_ISR_OFFSET, Value)
233 /****************************************************************************/
236 * Returns the current timer counter register value.
238 * @param BaseAddr is the base address of the scu timer.
240 * @return Contents of the timer counter register.
242 * @note C-style signature:
243 u32 XScuTimer_GetIntrReg(u32 BaseAddr)
245 ******************************************************************************/
246 #define XScuTimer_GetIntrReg(BaseAddr) \
247 XScuTimer_ReadReg(BaseAddr, XSCUTIMER_ISR_OFFSET)
249 /****************************************************************************/
252 * Read from the given Timer register.
254 * @param BaseAddr is the base address of the device
255 * @param RegOffset is the register offset to be read
257 * @return The 32-bit value of the register
259 * @note C-style signature:
260 * u32 XScuTimer_ReadReg(u32 BaseAddr, u32 RegOffset)
262 *****************************************************************************/
263 #define XScuTimer_ReadReg(BaseAddr, RegOffset) \
264 Xil_In32((BaseAddr) + (RegOffset))
266 /****************************************************************************/
269 * Write to the given Timer register.
271 * @param BaseAddr is the base address of the device
272 * @param RegOffset is the register offset to be written
273 * @param Data is the 32-bit value to write to the register
277 * @note C-style signature:
278 * void XScuTimer_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)
280 *****************************************************************************/
281 #define XScuTimer_WriteReg(BaseAddr, RegOffset, Data) \
282 Xil_Out32((BaseAddr) + (RegOffset), (Data))
284 /************************** Function Prototypes ******************************/
286 /************************** Variable Definitions *****************************/
292 #endif /* end of protection macro */