1 |
14 |
mjlyons |
/*****************************************************************************
|
2 |
|
|
* Filename: C:\Users\mjlyons\workspace\vSPI\projnav\xps/drivers/spiifc_v1_00_a/src/spiifc.h
|
3 |
|
|
* Version: 1.00.a
|
4 |
|
|
* Description: spiifc Driver Header File
|
5 |
|
|
* Date: Tue Feb 28 11:11:28 2012 (by Create and Import Peripheral Wizard)
|
6 |
|
|
*****************************************************************************/
|
7 |
|
|
|
8 |
|
|
#ifndef SPIIFC_H
|
9 |
|
|
#define SPIIFC_H
|
10 |
|
|
|
11 |
|
|
/***************************** Include Files *******************************/
|
12 |
|
|
|
13 |
|
|
#include "xbasic_types.h"
|
14 |
|
|
#include "xstatus.h"
|
15 |
|
|
#include "xil_io.h"
|
16 |
|
|
|
17 |
|
|
/************************** Constant Definitions ***************************/
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* User Logic Slave Space Offsets
|
22 |
|
|
* -- SLV_REG0 : user logic slave module register 0
|
23 |
|
|
* -- SLV_REG1 : user logic slave module register 1
|
24 |
|
|
* -- SLV_REG2 : user logic slave module register 2
|
25 |
|
|
* -- SLV_REG3 : user logic slave module register 3
|
26 |
|
|
* -- SLV_REG4 : user logic slave module register 4
|
27 |
|
|
* -- SLV_REG5 : user logic slave module register 5
|
28 |
|
|
* -- SLV_REG6 : user logic slave module register 6
|
29 |
|
|
* -- SLV_REG7 : user logic slave module register 7
|
30 |
|
|
* -- SLV_REG8 : user logic slave module register 8
|
31 |
|
|
* -- SLV_REG9 : user logic slave module register 9
|
32 |
|
|
* -- SLV_REG10 : user logic slave module register 10
|
33 |
|
|
* -- SLV_REG11 : user logic slave module register 11
|
34 |
|
|
* -- SLV_REG12 : user logic slave module register 12
|
35 |
|
|
* -- SLV_REG13 : user logic slave module register 13
|
36 |
|
|
* -- SLV_REG14 : user logic slave module register 14
|
37 |
|
|
* -- SLV_REG15 : user logic slave module register 15
|
38 |
|
|
*/
|
39 |
|
|
#define SPIIFC_USER_SLV_SPACE_OFFSET (0x00000000)
|
40 |
|
|
#define SPIIFC_SLV_REG0_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000000)
|
41 |
|
|
#define SPIIFC_SLV_REG1_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000004)
|
42 |
|
|
#define SPIIFC_SLV_REG2_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000008)
|
43 |
|
|
#define SPIIFC_SLV_REG3_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x0000000C)
|
44 |
|
|
#define SPIIFC_SLV_REG4_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000010)
|
45 |
|
|
#define SPIIFC_SLV_REG5_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000014)
|
46 |
|
|
#define SPIIFC_SLV_REG6_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000018)
|
47 |
|
|
#define SPIIFC_SLV_REG7_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x0000001C)
|
48 |
|
|
#define SPIIFC_SLV_REG8_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000020)
|
49 |
|
|
#define SPIIFC_SLV_REG9_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000024)
|
50 |
|
|
#define SPIIFC_SLV_REG10_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000028)
|
51 |
|
|
#define SPIIFC_SLV_REG11_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x0000002C)
|
52 |
|
|
#define SPIIFC_SLV_REG12_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000030)
|
53 |
|
|
#define SPIIFC_SLV_REG13_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000034)
|
54 |
|
|
#define SPIIFC_SLV_REG14_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x00000038)
|
55 |
|
|
#define SPIIFC_SLV_REG15_OFFSET (SPIIFC_USER_SLV_SPACE_OFFSET + 0x0000003C)
|
56 |
|
|
|
57 |
|
|
/**
|
58 |
|
|
* Interrupt Controller Space Offsets
|
59 |
|
|
* -- INTR_DGIER : device (peripheral) global interrupt enable register
|
60 |
|
|
* -- INTR_ISR : ip (user logic) interrupt status register
|
61 |
|
|
* -- INTR_IER : ip (user logic) interrupt enable register
|
62 |
|
|
*/
|
63 |
|
|
#define SPIIFC_INTR_CNTRL_SPACE_OFFSET (0x00000100)
|
64 |
|
|
#define SPIIFC_INTR_DGIER_OFFSET (SPIIFC_INTR_CNTRL_SPACE_OFFSET + 0x0000001C)
|
65 |
|
|
#define SPIIFC_INTR_IPISR_OFFSET (SPIIFC_INTR_CNTRL_SPACE_OFFSET + 0x00000020)
|
66 |
|
|
#define SPIIFC_INTR_IPIER_OFFSET (SPIIFC_INTR_CNTRL_SPACE_OFFSET + 0x00000028)
|
67 |
|
|
|
68 |
|
|
/**
|
69 |
|
|
* Interrupt Controller Masks
|
70 |
|
|
* -- INTR_TERR_MASK : transaction error
|
71 |
|
|
* -- INTR_DPTO_MASK : data phase time-out
|
72 |
|
|
* -- INTR_IPIR_MASK : ip interrupt requeset
|
73 |
|
|
* -- INTR_RFDL_MASK : read packet fifo deadlock interrupt request
|
74 |
|
|
* -- INTR_WFDL_MASK : write packet fifo deadlock interrupt request
|
75 |
|
|
* -- INTR_IID_MASK : interrupt id
|
76 |
|
|
* -- INTR_GIE_MASK : global interrupt enable
|
77 |
|
|
* -- INTR_NOPEND : the DIPR has no pending interrupts
|
78 |
|
|
*/
|
79 |
|
|
#define INTR_TERR_MASK (0x00000001UL)
|
80 |
|
|
#define INTR_DPTO_MASK (0x00000002UL)
|
81 |
|
|
#define INTR_IPIR_MASK (0x00000004UL)
|
82 |
|
|
#define INTR_RFDL_MASK (0x00000020UL)
|
83 |
|
|
#define INTR_WFDL_MASK (0x00000040UL)
|
84 |
|
|
#define INTR_IID_MASK (0x000000FFUL)
|
85 |
|
|
#define INTR_GIE_MASK (0x80000000UL)
|
86 |
|
|
#define INTR_NOPEND (0x80)
|
87 |
|
|
|
88 |
|
|
/**************************** Type Definitions *****************************/
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
/***************** Macros (Inline Functions) Definitions *******************/
|
92 |
|
|
|
93 |
|
|
/**
|
94 |
|
|
*
|
95 |
|
|
* Write a value to a SPIIFC register. A 32 bit write is performed.
|
96 |
|
|
* If the component is implemented in a smaller width, only the least
|
97 |
|
|
* significant data is written.
|
98 |
|
|
*
|
99 |
|
|
* @param BaseAddress is the base address of the SPIIFC device.
|
100 |
|
|
* @param RegOffset is the register offset from the base to write to.
|
101 |
|
|
* @param Data is the data written to the register.
|
102 |
|
|
*
|
103 |
|
|
* @return None.
|
104 |
|
|
*
|
105 |
|
|
* @note
|
106 |
|
|
* C-style signature:
|
107 |
|
|
* void SPIIFC_mWriteReg(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Data)
|
108 |
|
|
*
|
109 |
|
|
*/
|
110 |
|
|
#define SPIIFC_mWriteReg(BaseAddress, RegOffset, Data) \
|
111 |
|
|
Xil_Out32((BaseAddress) + (RegOffset), (Xuint32)(Data))
|
112 |
|
|
|
113 |
|
|
/**
|
114 |
|
|
*
|
115 |
|
|
* Read a value from a SPIIFC register. A 32 bit read is performed.
|
116 |
|
|
* If the component is implemented in a smaller width, only the least
|
117 |
|
|
* significant data is read from the register. The most significant data
|
118 |
|
|
* will be read as 0.
|
119 |
|
|
*
|
120 |
|
|
* @param BaseAddress is the base address of the SPIIFC device.
|
121 |
|
|
* @param RegOffset is the register offset from the base to write to.
|
122 |
|
|
*
|
123 |
|
|
* @return Data is the data from the register.
|
124 |
|
|
*
|
125 |
|
|
* @note
|
126 |
|
|
* C-style signature:
|
127 |
|
|
* Xuint32 SPIIFC_mReadReg(Xuint32 BaseAddress, unsigned RegOffset)
|
128 |
|
|
*
|
129 |
|
|
*/
|
130 |
|
|
#define SPIIFC_mReadReg(BaseAddress, RegOffset) \
|
131 |
|
|
Xil_In32((BaseAddress) + (RegOffset))
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
/**
|
135 |
|
|
*
|
136 |
|
|
* Write/Read 32 bit value to/from SPIIFC user logic slave registers.
|
137 |
|
|
*
|
138 |
|
|
* @param BaseAddress is the base address of the SPIIFC device.
|
139 |
|
|
* @param RegOffset is the offset from the slave register to write to or read from.
|
140 |
|
|
* @param Value is the data written to the register.
|
141 |
|
|
*
|
142 |
|
|
* @return Data is the data from the user logic slave register.
|
143 |
|
|
*
|
144 |
|
|
* @note
|
145 |
|
|
* C-style signature:
|
146 |
|
|
* void SPIIFC_mWriteSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Value)
|
147 |
|
|
* Xuint32 SPIIFC_mReadSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset)
|
148 |
|
|
*
|
149 |
|
|
*/
|
150 |
|
|
#define SPIIFC_mWriteSlaveReg0(BaseAddress, RegOffset, Value) \
|
151 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG0_OFFSET) + (RegOffset), (Xuint32)(Value))
|
152 |
|
|
#define SPIIFC_mWriteSlaveReg1(BaseAddress, RegOffset, Value) \
|
153 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG1_OFFSET) + (RegOffset), (Xuint32)(Value))
|
154 |
|
|
#define SPIIFC_mWriteSlaveReg2(BaseAddress, RegOffset, Value) \
|
155 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG2_OFFSET) + (RegOffset), (Xuint32)(Value))
|
156 |
|
|
#define SPIIFC_mWriteSlaveReg3(BaseAddress, RegOffset, Value) \
|
157 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG3_OFFSET) + (RegOffset), (Xuint32)(Value))
|
158 |
|
|
#define SPIIFC_mWriteSlaveReg4(BaseAddress, RegOffset, Value) \
|
159 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG4_OFFSET) + (RegOffset), (Xuint32)(Value))
|
160 |
|
|
#define SPIIFC_mWriteSlaveReg5(BaseAddress, RegOffset, Value) \
|
161 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG5_OFFSET) + (RegOffset), (Xuint32)(Value))
|
162 |
|
|
#define SPIIFC_mWriteSlaveReg6(BaseAddress, RegOffset, Value) \
|
163 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG6_OFFSET) + (RegOffset), (Xuint32)(Value))
|
164 |
|
|
#define SPIIFC_mWriteSlaveReg7(BaseAddress, RegOffset, Value) \
|
165 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG7_OFFSET) + (RegOffset), (Xuint32)(Value))
|
166 |
|
|
#define SPIIFC_mWriteSlaveReg8(BaseAddress, RegOffset, Value) \
|
167 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG8_OFFSET) + (RegOffset), (Xuint32)(Value))
|
168 |
|
|
#define SPIIFC_mWriteSlaveReg9(BaseAddress, RegOffset, Value) \
|
169 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG9_OFFSET) + (RegOffset), (Xuint32)(Value))
|
170 |
|
|
#define SPIIFC_mWriteSlaveReg10(BaseAddress, RegOffset, Value) \
|
171 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG10_OFFSET) + (RegOffset), (Xuint32)(Value))
|
172 |
|
|
#define SPIIFC_mWriteSlaveReg11(BaseAddress, RegOffset, Value) \
|
173 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG11_OFFSET) + (RegOffset), (Xuint32)(Value))
|
174 |
|
|
#define SPIIFC_mWriteSlaveReg12(BaseAddress, RegOffset, Value) \
|
175 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG12_OFFSET) + (RegOffset), (Xuint32)(Value))
|
176 |
|
|
#define SPIIFC_mWriteSlaveReg13(BaseAddress, RegOffset, Value) \
|
177 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG13_OFFSET) + (RegOffset), (Xuint32)(Value))
|
178 |
|
|
#define SPIIFC_mWriteSlaveReg14(BaseAddress, RegOffset, Value) \
|
179 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG14_OFFSET) + (RegOffset), (Xuint32)(Value))
|
180 |
|
|
#define SPIIFC_mWriteSlaveReg15(BaseAddress, RegOffset, Value) \
|
181 |
|
|
Xil_Out32((BaseAddress) + (SPIIFC_SLV_REG15_OFFSET) + (RegOffset), (Xuint32)(Value))
|
182 |
|
|
|
183 |
|
|
#define SPIIFC_mReadSlaveReg0(BaseAddress, RegOffset) \
|
184 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG0_OFFSET) + (RegOffset))
|
185 |
|
|
#define SPIIFC_mReadSlaveReg1(BaseAddress, RegOffset) \
|
186 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG1_OFFSET) + (RegOffset))
|
187 |
|
|
#define SPIIFC_mReadSlaveReg2(BaseAddress, RegOffset) \
|
188 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG2_OFFSET) + (RegOffset))
|
189 |
|
|
#define SPIIFC_mReadSlaveReg3(BaseAddress, RegOffset) \
|
190 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG3_OFFSET) + (RegOffset))
|
191 |
|
|
#define SPIIFC_mReadSlaveReg4(BaseAddress, RegOffset) \
|
192 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG4_OFFSET) + (RegOffset))
|
193 |
|
|
#define SPIIFC_mReadSlaveReg5(BaseAddress, RegOffset) \
|
194 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG5_OFFSET) + (RegOffset))
|
195 |
|
|
#define SPIIFC_mReadSlaveReg6(BaseAddress, RegOffset) \
|
196 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG6_OFFSET) + (RegOffset))
|
197 |
|
|
#define SPIIFC_mReadSlaveReg7(BaseAddress, RegOffset) \
|
198 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG7_OFFSET) + (RegOffset))
|
199 |
|
|
#define SPIIFC_mReadSlaveReg8(BaseAddress, RegOffset) \
|
200 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG8_OFFSET) + (RegOffset))
|
201 |
|
|
#define SPIIFC_mReadSlaveReg9(BaseAddress, RegOffset) \
|
202 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG9_OFFSET) + (RegOffset))
|
203 |
|
|
#define SPIIFC_mReadSlaveReg10(BaseAddress, RegOffset) \
|
204 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG10_OFFSET) + (RegOffset))
|
205 |
|
|
#define SPIIFC_mReadSlaveReg11(BaseAddress, RegOffset) \
|
206 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG11_OFFSET) + (RegOffset))
|
207 |
|
|
#define SPIIFC_mReadSlaveReg12(BaseAddress, RegOffset) \
|
208 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG12_OFFSET) + (RegOffset))
|
209 |
|
|
#define SPIIFC_mReadSlaveReg13(BaseAddress, RegOffset) \
|
210 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG13_OFFSET) + (RegOffset))
|
211 |
|
|
#define SPIIFC_mReadSlaveReg14(BaseAddress, RegOffset) \
|
212 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG14_OFFSET) + (RegOffset))
|
213 |
|
|
#define SPIIFC_mReadSlaveReg15(BaseAddress, RegOffset) \
|
214 |
|
|
Xil_In32((BaseAddress) + (SPIIFC_SLV_REG15_OFFSET) + (RegOffset))
|
215 |
|
|
|
216 |
|
|
/**
|
217 |
|
|
*
|
218 |
|
|
* Write/Read 32 bit value to/from SPIIFC user logic memory (BRAM).
|
219 |
|
|
*
|
220 |
|
|
* @param Address is the memory address of the SPIIFC device.
|
221 |
|
|
* @param Data is the value written to user logic memory.
|
222 |
|
|
*
|
223 |
|
|
* @return The data from the user logic memory.
|
224 |
|
|
*
|
225 |
|
|
* @note
|
226 |
|
|
* C-style signature:
|
227 |
|
|
* void SPIIFC_mWriteMemory(Xuint32 Address, Xuint32 Data)
|
228 |
|
|
* Xuint32 SPIIFC_mReadMemory(Xuint32 Address)
|
229 |
|
|
*
|
230 |
|
|
*/
|
231 |
|
|
#define SPIIFC_mWriteMemory(Address, Data) \
|
232 |
|
|
Xil_Out32(Address, (Xuint32)(Data))
|
233 |
|
|
#define SPIIFC_mReadMemory(Address) \
|
234 |
|
|
Xil_In32(Address)
|
235 |
|
|
|
236 |
|
|
/************************** Function Prototypes ****************************/
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
/**
|
240 |
|
|
*
|
241 |
|
|
* Enable all possible interrupts from SPIIFC device.
|
242 |
|
|
*
|
243 |
|
|
* @param baseaddr_p is the base address of the SPIIFC device.
|
244 |
|
|
*
|
245 |
|
|
* @return None.
|
246 |
|
|
*
|
247 |
|
|
* @note None.
|
248 |
|
|
*
|
249 |
|
|
*/
|
250 |
|
|
void SPIIFC_EnableInterrupt(void * baseaddr_p);
|
251 |
|
|
|
252 |
|
|
/**
|
253 |
|
|
*
|
254 |
|
|
* Example interrupt controller handler.
|
255 |
|
|
*
|
256 |
|
|
* @param baseaddr_p is the base address of the SPIIFC device.
|
257 |
|
|
*
|
258 |
|
|
* @return None.
|
259 |
|
|
*
|
260 |
|
|
* @note None.
|
261 |
|
|
*
|
262 |
|
|
*/
|
263 |
|
|
void SPIIFC_Intr_DefaultHandler(void * baseaddr_p);
|
264 |
|
|
|
265 |
|
|
/**
|
266 |
|
|
*
|
267 |
|
|
* Run a self-test on the driver/device. Note this may be a destructive test if
|
268 |
|
|
* resets of the device are performed.
|
269 |
|
|
*
|
270 |
|
|
* If the hardware system is not built correctly, this function may never
|
271 |
|
|
* return to the caller.
|
272 |
|
|
*
|
273 |
|
|
* @param baseaddr_p is the base address of the SPIIFC instance to be worked on.
|
274 |
|
|
*
|
275 |
|
|
* @return
|
276 |
|
|
*
|
277 |
|
|
* - XST_SUCCESS if all self-test code passed
|
278 |
|
|
* - XST_FAILURE if any self-test code failed
|
279 |
|
|
*
|
280 |
|
|
* @note Caching must be turned off for this function to work.
|
281 |
|
|
* @note Self test may fail if data memory and device are not on the same bus.
|
282 |
|
|
*
|
283 |
|
|
*/
|
284 |
|
|
XStatus SPIIFC_SelfTest(void * baseaddr_p);
|
285 |
|
|
|
286 |
|
|
#endif /** SPIIFC_H */
|