]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/spips_v3_0/src/xspips_hw.h
Completely re-generate the Zynq 7000 demo using the 2016.1 SDK tools.
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / spips_v3_0 / src / xspips_hw.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2015 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 xspips_hw.h
36 *
37 * This header file contains the identifiers and basic driver functions (or
38 * macros) that can be used to access the device. Other driver functions
39 * are defined in xspips.h.
40 *
41 * <pre>
42 * MODIFICATION HISTORY:
43 *
44 * Ver   Who    Date     Changes
45 * ----- ------ -------- -----------------------------------------------
46 * 1.00   drg/jz 01/25/10 First release
47 * 1.02a  sg     05/31/12 Updated XSPIPS_FIFO_DEPTH to 128 from 32 to match HW
48 *                        for CR 658289
49 * 1.04a  sg     01/30/13 Created XSPIPS_CR_MODF_GEN_EN_MASK macro and added it
50 *                        to XSPIPS_CR_RESET_STATE. Created
51 *                        XSPIPS_IXR_WR_TO_CLR_MASK for interrupts which need
52 *                        write-to-clear. Added shift and mask macros for d_nss
53 *                        parameter. Added Rx Watermark mask.
54 * 1.06a hk      08/22/13 Added prototypes of reset API and related constant
55 *                        definitions.
56 * 3.00  kvn     02/13/15 Modified code for MISRA-C:2012 compliance.
57 *
58 * </pre>
59 *
60 ******************************************************************************/
61
62 #ifndef XSPIPS_HW_H             /* prevent circular inclusions */
63 #define XSPIPS_HW_H             /* by using protection macros */
64
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68
69 /***************************** Include Files *********************************/
70
71 #include "xil_types.h"
72 #include "xil_assert.h"
73 #include "xil_io.h"
74
75 /************************** Constant Definitions *****************************/
76
77 /** @name Register Map
78  *
79  * Register offsets from the base address of an SPI device.
80  * @{
81  */
82 #define XSPIPS_CR_OFFSET        0x00U  /**< Configuration */
83 #define XSPIPS_SR_OFFSET        0x04U  /**< Interrupt Status */
84 #define XSPIPS_IER_OFFSET       0x08U  /**< Interrupt Enable */
85 #define XSPIPS_IDR_OFFSET       0x0CU  /**< Interrupt Disable */
86 #define XSPIPS_IMR_OFFSET       0x10U  /**< Interrupt Enabled Mask */
87 #define XSPIPS_ER_OFFSET        0x14U  /**< Enable/Disable Register */
88 #define XSPIPS_DR_OFFSET        0x18U  /**< Delay Register */
89 #define XSPIPS_TXD_OFFSET       0x1CU  /**< Data Transmit Register */
90 #define XSPIPS_RXD_OFFSET       0x20U  /**< Data Receive Register */
91 #define XSPIPS_SICR_OFFSET      0x24U  /**< Slave Idle Count */
92 #define XSPIPS_TXWR_OFFSET      0x28U  /**< Transmit FIFO Watermark */
93 #define XSPIPS_RXWR_OFFSET      0x2CU  /**< Receive FIFO Watermark */
94 /* @} */
95
96 /** @name Configuration Register
97  *
98  * This register contains various control bits that
99  * affects the operation of an SPI device. Read/Write.
100  * @{
101  */
102 #define XSPIPS_CR_MODF_GEN_EN_MASK 0x00020000U /**< Modefail Generation
103                                                  Enable */
104 #define XSPIPS_CR_MANSTRT_MASK   0x00010000U /**< Manual Transmission Start */
105 #define XSPIPS_CR_MANSTRTEN_MASK 0x00008000U /**< Manual Transmission Start
106                                                  Enable */
107 #define XSPIPS_CR_SSFORCE_MASK   0x00004000U /**< Force Slave Select */
108 #define XSPIPS_CR_SSCTRL_MASK    0x00003C00U /**< Slave Select Decode */
109 #define XSPIPS_CR_SSCTRL_SHIFT   10U        /**< Slave Select Decode shift */
110 #define XSPIPS_CR_SSCTRL_MAXIMUM 0xFU       /**< Slave Select maximum value */
111 #define XSPIPS_CR_SSDECEN_MASK   0x00000200U /**< Slave Select Decode Enable */
112
113 #define XSPIPS_CR_PRESC_MASK     0x00000038U /**< Prescaler Setting */
114 #define XSPIPS_CR_PRESC_SHIFT    3U         /**< Prescaler shift */
115 #define XSPIPS_CR_PRESC_MAXIMUM  0x07U      /**< Prescaler maximum value */
116
117 #define XSPIPS_CR_CPHA_MASK      0x00000004U /**< Phase Configuration */
118 #define XSPIPS_CR_CPOL_MASK      0x00000002U /**< Polarity Configuration */
119
120 #define XSPIPS_CR_MSTREN_MASK    0x00000001U /**< Master Mode Enable */
121 #define XSPIPS_CR_RESET_STATE    0x00020000U /**< Mode Fail Generation Enable */
122 /* @} */
123
124
125 /** @name SPI Interrupt Registers
126  *
127  * <b>SPI Status Register</b>
128  *
129  * This register holds the interrupt status flags for an SPI device. Some
130  * of the flags are level triggered, which means that they are set as long
131  * as the interrupt condition exists. Other flags are edge triggered,
132  * which means they are set once the interrupt condition occurs and remain
133  * set until they are cleared by software. The interrupts are cleared by
134  * writing a '1' to the interrupt bit position in the Status Register.
135  * Read/Write.
136  *
137  * <b>SPI Interrupt Enable Register</b>
138  *
139  * This register is used to enable chosen interrupts for an SPI device.
140  * Writing a '1' to a bit in this register sets the corresponding bit in the
141  * SPI Interrupt Mask register.  Write only.
142  *
143  * <b>SPI Interrupt Disable Register </b>
144  *
145  * This register is used to disable chosen interrupts for an SPI device.
146  * Writing a '1' to a bit in this register clears the corresponding bit in the
147  * SPI Interrupt Mask register. Write only.
148  *
149  * <b>SPI Interrupt Mask Register</b>
150  *
151  * This register shows the enabled/disabled interrupts of an SPI device.
152  * Read only.
153  *
154  * All four registers have the same bit definitions. They are only defined once
155  * for each of the Interrupt Enable Register, Interrupt Disable Register,
156  * Interrupt Mask Register, and Channel Interrupt Status Register
157  * @{
158  */
159
160 #define XSPIPS_IXR_TXUF_MASK            0x00000040U  /**< Tx FIFO Underflow */
161 #define XSPIPS_IXR_RXFULL_MASK          0x00000020U  /**< Rx FIFO Full */
162 #define XSPIPS_IXR_RXNEMPTY_MASK        0x00000010U  /**< Rx FIFO Not Empty */
163 #define XSPIPS_IXR_TXFULL_MASK          0x00000008U  /**< Tx FIFO Full */
164 #define XSPIPS_IXR_TXOW_MASK            0x00000004U  /**< Tx FIFO Overwater */
165 #define XSPIPS_IXR_MODF_MASK            0x00000002U  /**< Mode Fault */
166 #define XSPIPS_IXR_RXOVR_MASK           0x00000001U  /**< Rx FIFO Overrun */
167 #define XSPIPS_IXR_DFLT_MASK            0x00000027U  /**< Default interrupts
168                                                          mask */
169 #define XSPIPS_IXR_WR_TO_CLR_MASK       0x00000043U  /**< Interrupts which
170                                                          need write to clear */
171 #define XSPIPS_ISR_RESET_STATE          0x04U       /**< Default to tx/rx
172                                                        * reg empty */
173 #define XSPIPS_IXR_DISABLE_ALL_MASK     0x00000043U  /**< Disable all
174                                                        * interrupts */
175 /* @} */
176
177
178 /** @name Enable Register
179  *
180  * This register is used to enable or disable an SPI device.
181  * Read/Write
182  * @{
183  */
184 #define XSPIPS_ER_ENABLE_MASK   0x00000001U /**< SPI Enable Bit Mask */
185 /* @} */
186
187
188 /** @name Delay Register
189  *
190  * This register is used to program timing delays in
191  * slave mode. Read/Write
192  * @{
193  */
194 #define XSPIPS_DR_NSS_MASK      0xFF000000U /**< Delay for slave select
195                                               * de-assertion between
196                                               * word transfers mask */
197 #define XSPIPS_DR_NSS_SHIFT     24U        /**< Delay for slave select
198                                               * de-assertion between
199                                               * word transfers shift */
200 #define XSPIPS_DR_BTWN_MASK     0x00FF0000U /**< Delay Between Transfers        mask */
201 #define XSPIPS_DR_BTWN_SHIFT    16U        /**< Delay Between Transfers shift */
202 #define XSPIPS_DR_AFTER_MASK    0x0000FF00U /**< Delay After Transfers mask */
203 #define XSPIPS_DR_AFTER_SHIFT   8U         /**< Delay After Transfers shift */
204 #define XSPIPS_DR_INIT_MASK     0x000000FFU /**< Delay Initially mask */
205 /* @} */
206
207
208 /** @name Slave Idle Count Registers
209  *
210  * This register defines the number of pclk cycles the slave waits for a the
211  * SPI clock to become stable in quiescent state before it can detect the start
212  * of the next transfer in CPHA = 1 mode.
213  * Read/Write
214  *
215  * @{
216  */
217 #define XSPIPS_SICR_MASK        0x000000FFU /**< Slave Idle Count Mask */
218 /* @} */
219
220
221
222 /** @name Transmit FIFO Watermark Register
223  *
224  * This register defines the watermark setting for the Transmit FIFO. The
225  * transmit FIFO is 128 bytes deep, so the register is 7 bits. Valid values
226  * are 1 to 128.
227  *
228  * @{
229  */
230 #define XSPIPS_TXWR_MASK        0x0000007FU /**< Transmit Watermark Mask */
231 #define XSPIPS_TXWR_RESET_VALUE 0x00000001U /**< Transmit Watermark
232                                               * register reset value */
233 /* @} */
234
235 /** @name Receive FIFO Watermark Register
236  *
237  * This register defines the watermark setting for the Receive FIFO. The
238  * receive FIFO is 128 bytes deep, so the register is 7 bits. Valid values
239  * are 1 to 128.
240  *
241  * @{
242  */
243 #define XSPIPS_RXWR_MASK        0x0000007FU /**< Receive Watermark Mask */
244 #define XSPIPS_RXWR_RESET_VALUE 0x00000001U /**< Receive Watermark
245                                               * register reset value */
246 /* @} */
247
248 /** @name FIFO Depth
249  *
250  * This macro provides the depth of transmit FIFO and receive FIFO.
251  *
252  * @{
253  */
254 #define XSPIPS_FIFO_DEPTH       128U /**< FIFO depth of Tx and Rx */
255 /* @} */
256
257 /**************************** Type Definitions *******************************/
258
259 /***************** Macros (Inline Functions) Definitions *********************/
260
261 #define XSpiPs_In32 Xil_In32
262 #define XSpiPs_Out32 Xil_Out32
263
264 /****************************************************************************/
265 /**
266 * Read a register.
267 *
268 * @param        BaseAddress contains the base address of the device.
269 * @param        RegOffset contains the offset from the 1st register of the
270 *               device to the target register.
271 *
272 * @return       The value read from the register.
273 *
274 * @note         C-Style signature:
275 *               u32 XSpiPs_ReadReg(u32 BaseAddress. int RegOffset)
276 *
277 ******************************************************************************/
278 #define XSpiPs_ReadReg(BaseAddress, RegOffset) \
279         XSpiPs_In32((BaseAddress) + (RegOffset))
280
281 /***************************************************************************/
282 /**
283 * Write to a register.
284 *
285 * @param        BaseAddress contains the base address of the device.
286 * @param        RegOffset contains the offset from the 1st register of the
287 *               device to target register.
288 * @param        RegisterValue is the value to be written to the register.
289 *
290 * @return       None.
291 *
292 * @note         C-Style signature:
293 *               void XSpiPs_WriteReg(u32 BaseAddress, int RegOffset,
294 *               u32 RegisterValue)
295 *
296 ******************************************************************************/
297 #define XSpiPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \
298     XSpiPs_Out32((BaseAddress) + (RegOffset), (RegisterValue))
299
300 /************************** Function Prototypes ******************************/
301
302 void XSpiPs_ResetHw(u32 BaseAddress);
303
304 /************************** Variable Definitions *****************************/
305
306 #ifdef __cplusplus
307 }
308 #endif
309
310 #endif /* end of protection macro */