1 /******************************************************************************
3 * Copyright (C) 2010 - 2015 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 /****************************************************************************/
37 * This file contains the hardware interface to the System Watch Dog Timer (WDT).
40 * MODIFICATION HISTORY:
42 * Ver Who Date Changes
43 * ----- ------ -------- ---------------------------------------------
44 * 1.00a ecm/jz 01/15/10 First release
45 * 1.02a sg 07/15/12 Removed defines related to External Signal
46 * Length functionality for CR 658287
47 * 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
50 ******************************************************************************/
51 #ifndef XWDTPS_HW_H /* prevent circular inclusions */
52 #define XWDTPS_HW_H /* by using protection macros */
58 /***************************** Include Files *********************************/
60 #include "xil_types.h"
61 #include "xil_assert.h"
64 /************************** Constant Definitions *****************************/
66 /** @name Register Map
67 * Offsets of registers from the start of the device
71 #define XWDTPS_ZMR_OFFSET 0x00000000U /**< Zero Mode Register */
72 #define XWDTPS_CCR_OFFSET 0x00000004U /**< Counter Control Register */
73 #define XWDTPS_RESTART_OFFSET 0x00000008U /**< Restart Register */
74 #define XWDTPS_SR_OFFSET 0x0000000CU /**< Status Register */
78 /** @name Zero Mode Register
79 * This register controls how the time out is indicated and also contains
80 * the access code (0xABC) to allow writes to the register
83 #define XWDTPS_ZMR_WDEN_MASK 0x00000001U /**< enable the WDT */
84 #define XWDTPS_ZMR_RSTEN_MASK 0x00000002U /**< enable the reset output */
85 #define XWDTPS_ZMR_IRQEN_MASK 0x00000004U /**< enable the IRQ output */
87 #define XWDTPS_ZMR_RSTLN_MASK 0x00000070U /**< set length of reset pulse */
88 #define XWDTPS_ZMR_RSTLN_SHIFT 4U /**< shift for reset pulse */
90 #define XWDTPS_ZMR_IRQLN_MASK 0x00000180U /**< set length of interrupt pulse */
91 #define XWDTPS_ZMR_IRQLN_SHIFT 7U /**< shift for interrupt pulse */
93 #define XWDTPS_ZMR_ZKEY_MASK 0x00FFF000U /**< mask for writing access key */
94 #define XWDTPS_ZMR_ZKEY_VAL 0x00ABC000U /**< access key, 0xABC << 12 */
98 /** @name Counter Control register
99 * This register controls how fast the timer runs and the reset value
100 * and also contains the access code (0x248) to allow writes to the
105 #define XWDTPS_CCR_CLKSEL_MASK 0x00000003U /**< counter clock prescale */
107 #define XWDTPS_CCR_CRV_MASK 0x00003FFCU /**< counter reset value */
108 #define XWDTPS_CCR_CRV_SHIFT 2U /**< shift for writing value */
110 #define XWDTPS_CCR_CKEY_MASK 0x03FFC000U /**< mask for writing access key */
111 #define XWDTPS_CCR_CKEY_VAL 0x00920000U /**< access key, 0x248 << 14 */
113 /* Bit patterns for Clock prescale divider values */
115 #define XWDTPS_CCR_PSCALE_0008 0x00000000U /**< divide clock by 8 */
116 #define XWDTPS_CCR_PSCALE_0064 0x00000001U /**< divide clock by 64 */
117 #define XWDTPS_CCR_PSCALE_0512 0x00000002U /**< divide clock by 512 */
118 #define XWDTPS_CCR_PSCALE_4096 0x00000003U /**< divide clock by 4096 */
122 /** @name Restart register
123 * This register resets the timer preventing a timeout. Value is specific
128 #define XWDTPS_RESTART_KEY_VAL 0x00001999U /**< valid key */
132 /** @name Status register
133 * This register indicates timer reached zero count.
136 #define XWDTPS_SR_WDZ_MASK 0x00000001U /**< time out occurred */
140 /**************************** Type Definitions *******************************/
143 /***************** Macros (Inline Functions) Definitions *********************/
145 /****************************************************************************/
148 * Read the given register.
150 * @param BaseAddress is the base address of the device
151 * @param RegOffset is the register offset to be read
153 * @return The 32-bit value of the register
155 * @note C-style signature:
156 * u32 XWdtPs_ReadReg(u32 BaseAddress, u32 RegOffset)
158 *****************************************************************************/
159 #define XWdtPs_ReadReg(BaseAddress, RegOffset) \
160 Xil_In32((BaseAddress) + (u32)(RegOffset))
162 /****************************************************************************/
165 * Write the given register.
167 * @param BaseAddress is the base address of the device
168 * @param RegOffset is the register offset to be written
169 * @param Data is the 32-bit value to write to the register
173 * @note C-style signature:
174 * void XWdtPs_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
176 *****************************************************************************/
177 #define XWdtPs_WriteReg(BaseAddress, RegOffset, Data) \
178 Xil_Out32((BaseAddress) + (u32)(RegOffset), (u32)(Data))
181 /************************** Function Prototypes ******************************/
184 /************************** Variable Definitions *****************************/