source: PlatformSupport/CustomPeripherals/pcores/w3_userio_axi_v1_03_a/src/w3_userio.h

Last change on this file was 5686, checked in by murphpo, 7 years ago

Fixed typo in userio.h in (unused) macro for overwriting all bits in debug header

File size: 23.0 KB
Line 
1/*****************************************************************
2* File: w3_userio.h
3* Copyright (c) 2016 Mango Communications, all rights reseved
4* Released under the WARP License
5* See http://warpproject.org/license for details
6*****************************************************************/
7
8/*! \file w3_userio.h
9
10\mainpage
11This is the driver for the w3_userio core, which provides access to all the user IO resources on WARP v3 boards. These resources include
12user LEDs, RF LEDs, hex displays, push buttons and a DIP switch.
13
14This driver only implements macros for reading/writing registers in the w3_userio core hardware. Macros are also provided to read the Virtex-6 device DNA.
15
16@version 1.03.a
17@copyright (c) 2011-2016 Mango Communications, Inc. All rights reserved.<br>
18Released under the WARP open source license (see http://warpproject.org/license)
19
20*/
21    /* Address map:
22        HDL is coded [31:0], adopting Xilinx's convention for AXI IPIF cores
23        All registers are 32-bits
24            regX[31]  maps to 0x80000000 in C driver
25            regX[0]   maps to 0x00000001 in C driver
26
27    0: Control RW
28        [31:30] = Reserved
29        [   29] = Left hex data mode (0=user supplies bit-per-segment; 1=user supplies 4-bit hex)   0x20000000
30        [   28] = Right hex data mode (0=user supplies bit-per-segment; 1=user supplies 4-bit hex)  0x10000000
31      Control source for LEDs: 0=software controlled, 1=usr_ port controlled
32        [27:24] = {rfb_red rfb_green rfa_red rfa_green} 0x0F000000
33        [23:16] = {leds_red leds_green}                 0x00FF0000
34        [15: 8] = {hexdisp_right{a b c d e f g dp}}     0x0000FF00
35        [ 7: 0] = {hexdisp_left{a b c d e f g dp}}      0x000000FF !! Left/Right are swapped in user_logic.v comments
36    1: Left hex display RW
37        [31: 9] = reserved
38        [    8] = DP (controlled directly; doesn't depend on data mode) 0x100
39        [ 6: 0] = Data value ([6:4] ignored when data mode = 1)         0x03F
40    2: Right hex display RW
41        [31: 9] = reserved
42        [    8] = DP (controlled directly; doesn't depend on data mode) 0x100
43        [ 6: 0] = Data value ([6:4] ignored when data mode = 1)         0x03F
44    3: Red user LEDs RW
45        [31: 4] = reserved
46        [ 3: 0] = Data value (1=LED illuminated) 0xF, with 0x1 mapped to lowest LED
47    4: Green user LEDs RW
48        [31: 4] = reserved
49        [ 3: 0] = Data value (1=LED illuminated) 0xF, with 0x1 mapped to lowest LED
50    5: RF LEDs RW
51        [31: 4] = reserved
52        [    3] = rfb_red   0x8
53        [    2] = rfb_green 0x4
54        [    1] = rfa_red   0x2
55        [    0] = rfa_green 0x1
56    6: Switch/button inputs RO
57        [31: 7] = reserved
58        [    6] = pb_up         0x40
59        [    5] = pb_mid        0x20
60        [    4] = pb_down       0x10
61        [ 3: 0] = DIP switch    0x0F (with 0x1 mapped to right-most switch)
62
63    7: PWM Gen Param: PWM period RW
64        [31:29] = reserved
65        [28: 0] = PWN period
66
67    8: PWM Gen Param: PWM output deassert thresh RW
68        [31:29] = reserved
69        [28: 0] = PWM output deassert thresh
70       
71    9: PWM Gen Param: PWM ramp step RW
72        [31]    = ramp enabled
73        [30:20] = reserved
74        [19: 0] = PWM thresh ramp step
75
76    10: HW Output control sel RW
77        [31:28] = Reserved
78      HW Control source for LEDs: 0=usr_ ports, 1=pwm gen (same ctrlSrc masks as reg0)
79        [27:24] = {rfb_red rfb_green rfa_red rfa_green} 0x0F000000
80        [23:16] = {leds_red leds_green}                 0x00FF0000
81        [15: 8] = {hexdisp_left{a b c d e f g dp}}      0x0000FF00
82        [ 7: 0] = {hexdisp_right{a b c d e f g dp}}     0x000000FF
83
84    11: FPGA DNA LSB
85        [31: 0] = 32LSB of FPGA DNA
86
87    12: FPGA DNA MSB
88        [31:25] = reserved
89        [24: 0] = FPGA DNA 25MSB
90
91    13: Debug Header IO
92        [31:15] = Reserved
93        [15: 0] = IOB data. Bits corresponding to inputs contain input values. Bits
94                   corresponding to outputs contain output values. Bits corresponding to
95                   unused pins contain would-be output values (whatever software last wrote).
96
97   14: Debug Header IO control
98        [31:16] = IOB direction control, 1 bit per pin; only C_DBG_HDR_WIDTH LSB are used
99        [15: 0] = Debug header output source select (0=sw via reg13, 1=usr_dbg_hdr_out port)
100*/
101
102#ifndef W3_USERIO_H
103#define W3_USERIO_H
104
105#include "xil_io.h"
106
107/// @cond EXCLUDE_FROM_DOCS
108// Address offset for each slave register; exclude from docs, as users never use these directly
109#define W3_USERIO_USER_SLV_SPACE_OFFSET (0x00000000)
110#define W3_USERIO_SLV_REG0_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000000)
111#define W3_USERIO_SLV_REG1_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000004)
112#define W3_USERIO_SLV_REG2_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000008)
113#define W3_USERIO_SLV_REG3_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x0000000C)
114#define W3_USERIO_SLV_REG4_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000010)
115#define W3_USERIO_SLV_REG5_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000014)
116#define W3_USERIO_SLV_REG6_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000018)
117#define W3_USERIO_SLV_REG7_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x0000001C)
118#define W3_USERIO_SLV_REG8_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000020)
119#define W3_USERIO_SLV_REG9_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000024)
120#define W3_USERIO_SLV_REG10_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000028)
121#define W3_USERIO_SLV_REG11_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x0000002C)
122#define W3_USERIO_SLV_REG12_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000030)
123#define W3_USERIO_SLV_REG13_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000034)
124#define W3_USERIO_SLV_REG14_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000038)
125/// @endcond
126
127/** \defgroup control_reg Control registers
128 *  \addtogroup control_reg
129<b>Hardware vs. software control</b>:
130Every LED and hex display segment can be controlled either via software or hardware:
131<ul>
132<li><b>Software</b>: user code sets LED state by writing a 1 to the corresponding register bit
133<li><b>Hardware</b>: Two modes:<ul>
134   <li><b>Port mode</b>: LED state is controlled by corresponding usr_* port
135   <li><b>PWM mode</b>:  LED state is controlled by internal PWM waveform generator
136   </ul>
137</ul>
138
139The WARP reference designs use hardware/port control for the RF LEDs (to indicate real-time Tx/Rx state of each RF interface) and software control
140for all other LED/hex display outputs.
141
142The control source (hw or sw) for each output bit is set by the control register described below.
143
144Examples:
145\code{.c}
146//Assumes user code sets USERIO_BASEADDR to base address of w3_userio core, as set in xparameters.h
147
148//------------------------------------------------------------------------------
149// Set both hex dipslays to map 4-bit to 7-segment values automatically
150userio_write_control(USERIO_BASEADDR, (W3_USERIO_HEXDISP_L_MAPMODE | W3_USERIO_HEXDISP_R_MAPMODE));
151
152//------------------------------------------------------------------------------
153// Select software control of all outputs
154userio_set_ctrlSrc_sw(USERIO_BASEADDR, (W3_USERIO_CTRLSRC_LEDS_RF | W3_USERIO_CTRLSRC_LEDS | W3_USERIO_CTRLSRC_HEXDISPS));
155
156//------------------------------------------------------------------------------
157// Select hardware/port control of RF LEDs
158userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RF);
159
160//------------------------------------------------------------------------------
161// Enable hardware control of green user LEDs, software control of red user LEDs
162userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_GREEN);
163userio_set_ctrlSrc_sw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RED);
164
165//------------------------------------------------------------------------------
166// Use the PWM generator to slowly blink the green LEDs
167userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_GREEN);
168userio_set_hw_ctrl_mode_pwm(USERIO_BASEADDR, (W3_USERIO_CTRLSRC_LEDS_GREEN);
169userio_set_pwm_ramp_en(USERIO_BASEADDR, 0);
170userio_set_pwm_period(USERIO_BASEADDR, 65530);
171userio_set_pwm_thresh(USERIO_BASEADDR, 65530/2);
172
173//------------------------------------------------------------------------------
174// Use the PWM generator to show a "sleep" pattern on red LEDs
175userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RED);
176userio_set_hw_ctrl_mode_pwm(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RED);
177
178//Use fast period so blinking is not visable
179// (fast blink with low duty cycle looks like a dim constant brightness)
180userio_set_pwm_period(USERIO_BASEADDR, 500);
181
182//Ramp must be disabled when changing ramp params
183userio_set_pwm_ramp_en(USERIO_BASEADDR, 0);
184userio_set_pwm_ramp_min(USERIO_BASEADDR, 2);
185userio_set_pwm_ramp_max(USERIO_BASEADDR, 250);
186userio_set_pwm_ramp_en(USERIO_BASEADDR, 1);
187\endcode
188
189 * @{
190 */
191
192#define userio_read_control(baseaddr)       Xil_In32(baseaddr+W3_USERIO_SLV_REG0_OFFSET) //!< Returns the value of the control register
193#define userio_write_control(baseaddr, x)       Xil_Out32(baseaddr+W3_USERIO_SLV_REG0_OFFSET, x) //!< Sets the control register to x
194
195#define userio_set_ctrlSrc_sw(baseaddr, ioMask) Xil_Out32(baseaddr+W3_USERIO_SLV_REG0_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG0_OFFSET) & ~(ioMask)))//!< Sets selected outputs to software control (register writes)
196#define userio_set_ctrlSrc_hw(baseaddr, ioMask) Xil_Out32(baseaddr+W3_USERIO_SLV_REG0_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG0_OFFSET) | (ioMask))) //!< Sets selected outputs to hardware control (usr_ ports)
197
198#define userio_set_hw_ctrl_mode_pwm(baseaddr, ioMask) Xil_Out32(baseaddr+W3_USERIO_SLV_REG10_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG10_OFFSET) | (ioMask))) //!< Sets selected outputs to use PWM generator for hardware/PWM control
199#define userio_set_hw_ctrl_mode_port(baseaddr, ioMask) Xil_Out32(baseaddr+W3_USERIO_SLV_REG10_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG10_OFFSET) & (~ioMask))) //!< Sets selected outputs to use PWM generator for hardware/port control
200
201//PWM config macros
202#define userio_set_pwm_period(baseaddr, p) Xil_Out32(baseaddr+W3_USERIO_SLV_REG7_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG7_OFFSET) & 0x0000FFFF) | (((p) & 0xFFFF)<<16)) //!< Sets the PWM period; larger periods result in slower blinking
203#define userio_set_pwm_thresh(baseaddr, t) Xil_Out32(baseaddr+W3_USERIO_SLV_REG7_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG7_OFFSET) & 0xFFFF0000) | ((t) & 0xFFFF)) //!< Sets the PWM duty cycle threshold; threshold be greater than 1 and less than the PWM period. This threshold is ignored when the threshold ramp is enabled
204#define userio_set_pwm_ramp_en(baseaddr, d) Xil_Out32(baseaddr+W3_USERIO_SLV_REG9_OFFSET, ( (Xil_In32(baseaddr+W3_USERIO_SLV_REG9_OFFSET) & 0x7FFFFFFF) | ((d&0x1)<<31))) //!< Enables and disables the PWM threshold ramp logic. Ramp must be disabled when changing ramp min/max params
205#define userio_set_pwm_ramp_max(baseaddr, m) Xil_Out32(baseaddr+W3_USERIO_SLV_REG9_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG9_OFFSET) & 0xFFFF0000) | ((m) & 0xFFFF)) //!< Sets the max value of the ramped PWM threshold; must be greater than the ramp min value and less than the PWM period
206#define userio_set_pwm_ramp_min(baseaddr, m) Xil_Out32(baseaddr+W3_USERIO_SLV_REG9_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG9_OFFSET) & 0x8000FFFF) | (((m) & 0x7FFF)<<16)) //!< Sets the min value of the ramped PWM threshold; must be greater than 1 and less than the ramp max value
207
208//reg0 masks
209#define W3_USERIO_HEXDISP_L_MAPMODE     0x20000000 //!< Enables 4-bit to 7-segment mapping for left hex display
210#define W3_USERIO_HEXDISP_R_MAPMODE     0x10000000 //!< Enables 4-bit to 7-segment mapping for right hex display
211#define W3_USERIO_CTRLSRC_LED_RFB_RED   0x08000000 //!< Control source selection mask for red LED near RF B
212#define W3_USERIO_CTRLSRC_LED_RFB_GREEN 0x04000000 //!< Control source selection mask for green LED near RF B
213#define W3_USERIO_CTRLSRC_LED_RFA_RED   0x02000000 //!< Control source selection mask for red LED near RF A
214#define W3_USERIO_CTRLSRC_LED_RFA_GREEN 0x01000000 //!< Control source selection mask for green LED near RF A
215#define W3_USERIO_CTRLSRC_LEDS_RED      0x000F0000 //!< Control source selection mask for the red user LEDs
216#define W3_USERIO_CTRLSRC_LEDS_GREEN    0x00F00000 //!< Control source selection mask for the green user LEDs
217#define W3_USERIO_CTRLSRC_HEXDISP_R     0x0000FF00 //!< Control source selection mask for the left hex display (includes decimal point)
218#define W3_USERIO_CTRLSRC_HEXDISP_L     0x000000FF //!< Control source selection mask for the right hex display (includes decimal point)
219#define W3_USERIO_CTRLSRC_HEXDISP_DP_R  0x00008000 //!< Control source selection mask for the left hex display decimal point
220#define W3_USERIO_CTRLSRC_HEXDISP_DP_L  0x00000080 //!< Control source selection mask for the right hex display decimal point
221
222#define W3_USERIO_CTRLSRC_LEDS_RFA      (W3_USERIO_CTRLSRC_LED_RFA_RED | W3_USERIO_CTRLSRC_LED_RFA_GREEN) //!< Control source selection masks for both LEDs near RF A
223#define W3_USERIO_CTRLSRC_LEDS_RFB      (W3_USERIO_CTRLSRC_LED_RFB_RED | W3_USERIO_CTRLSRC_LED_RFB_GREEN) //!< Control source selection masks for both LEDs near RF B
224#define W3_USERIO_CTRLSRC_LEDS_RF       (W3_USERIO_CTRLSRC_LEDS_RFA | W3_USERIO_CTRLSRC_LEDS_RFB) //!< Control source selection masks for all RF LEDs
225#define W3_USERIO_CTRLSRC_LEDS          (W3_USERIO_CTRLSRC_LEDS_RED | W3_USERIO_CTRLSRC_LEDS_GREEN) //!< Control source selection masks for all user LEDs
226#define W3_USERIO_CTRLSRC_HEXDISPS      (W3_USERIO_CTRLSRC_HEXDISP_L | W3_USERIO_CTRLSRC_HEXDISP_R) //!< Control source selection masks for both hex displays
227
228#define W3_USERIO_CTRLSRC_ALL_OUTPUTS   (W3_USERIO_CTRLSRC_LEDS_RF | W3_USERIO_CTRLSRC_LEDS  | W3_USERIO_CTRLSRC_HEXDISPS) //!< Control source selection masks for all outputs
229/** @}*/
230
231
232/** \defgroup userio_read Reading user IO
233<b>Note on output state</b>: The macros for reading the current state of user outputs (LEDs, hex displays) can only access outputs configured for software control. Attempts to read the state
234of outputs configured for hardware control (i.e. outputs with corresponding CTRLSRC_* asserted in control reg) will not reflect actual output state.
235
236Examples:
237\code{.c}
238//Assumes user code sets USERIO_BASEADDR to base address of w3_userio core, as set in xparameters.h
239
240//Check if middle push button is being pressed
241if(userio_read_inputs(USERIO_BASEADDR) & W3_USERIO_PB_M) {...}
242
243//Read 4-bit DIP switch value
244u8 x = userio_read_inputs(USERIO_BASEADDR) & W3_USERIO_DIPSW;
245\endcode
246
247 *  \addtogroup userio_read
248 * @{
249 */
250#define userio_read_inputs(baseaddr)        Xil_In32(baseaddr+W3_USERIO_SLV_REG6_OFFSET) //!< Returns the current state of the user inputs (buttons and DIP switch)
251#define userio_read_hexdisp_left(baseaddr)  Xil_In32(baseaddr+W3_USERIO_SLV_REG1_OFFSET) //!< Returns the current state of the left hex display outputs
252#define userio_read_hexdisp_right(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG2_OFFSET) //!< Returns the current state of the right hex display outputs
253#define userio_read_leds_red(baseaddr)      Xil_In32(baseaddr+W3_USERIO_SLV_REG3_OFFSET) //!< Returns the current state of the red user LEDs
254#define userio_read_leds_green(baseaddr)    Xil_In32(baseaddr+W3_USERIO_SLV_REG4_OFFSET) //!< Returns the current state of the green user LEDs
255#define userio_read_leds_rf(baseaddr)       Xil_In32(baseaddr+W3_USERIO_SLV_REG5_OFFSET) //!< Returns the current state of the RF LEDs
256/** @}*/
257
258/** \defgroup userio_write Setting user outputs
259
260<b>Hex display notes:</b>
261The w3_userio core implements logic to map 4-bit values to the 7-segment representation of the corresponding hex value. When this mode
262is enabled via the control register (W3_USERIO_HEXDISP_x_MAPMODE is asserte), user code should write 4-bit values via the hex display macros below. When map
263mode is disabled, the user value is driven directly to the 7-segments of the hex display.
264
265The decimal point on each hex dipslay is controlled by OR'ing 4 bit (in map mode) or 7 bit (in non-map mode) value with W3_USERIO_HEXDISP_DP.
266
267Examples:
268\code{.c}
269//Assumes user code sets USERIO_BASEADDR to base address of w3_userio core, as set in xparameters.h
270
271//Display "B" on the left hex dipslay (assumes map mode is enabled; see control register docs)
272userio_write_hexdisp_left(USERIO_ADDR, 0xB);
273
274//Display "4" on the right hex dipslay and light the decimal point (assumes map mode is enabled; see control register docs)
275userio_write_hexdisp_right(USERIO_ADDR, (0x4 | W3_USERIO_HEXDISP_DP) );
276
277//Turn off all four green user LEDs
278userio_write_leds_green(USERIO_ADDR, 0);
279
280//Toggle the 2 LSB of the red user LEDs
281userio_toggle_leds_red(USERIO_ADDR, 0x3);
282
283\endcode
284 *  \addtogroup userio_write
285 * @{
286 */
287#define userio_write_hexdisp_left(baseaddr, x)  Xil_Out32(baseaddr+W3_USERIO_SLV_REG1_OFFSET, x) //!< Sets the left hex dispaly
288#define userio_write_hexdisp_right(baseaddr, x) Xil_Out32(baseaddr+W3_USERIO_SLV_REG2_OFFSET, x) //!< Sets the right hex dispaly
289#define userio_write_leds_red(baseaddr, x)      Xil_Out32(baseaddr+W3_USERIO_SLV_REG3_OFFSET, x) //!< Sets the 4 red LEDs when configured for software control (software control is default)
290#define userio_write_leds_green(baseaddr, x)    Xil_Out32(baseaddr+W3_USERIO_SLV_REG4_OFFSET, x) //!< Sets the 4 green LEDs when configured for software control (software control is default)
291#define userio_write_leds_rf(baseaddr, x)       Xil_Out32(baseaddr+W3_USERIO_SLV_REG5_OFFSET, x) //!< Sets the 4 RF LEDs when configured for software control (hardware control is default)
292#define userio_toggle_hexdisp_left(baseaddr, mask)  Xil_Out32(baseaddr+W3_USERIO_SLV_REG1_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG1_OFFSET) ^ mask)) //!< Toggles the state of bits selected by mask on left hex display
293#define userio_toggle_hexdisp_right(baseaddr, mask) Xil_Out32(baseaddr+W3_USERIO_SLV_REG2_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG2_OFFSET) ^ mask)) //!< Toggles the state of bits selected by mask on right hex display
294#define userio_toggle_leds_red(baseaddr, mask)      Xil_Out32(baseaddr+W3_USERIO_SLV_REG3_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG3_OFFSET) ^ mask)) //!< Toggles the state of bits selected by mask in red LEDs
295#define userio_toggle_leds_green(baseaddr, mask)    Xil_Out32(baseaddr+W3_USERIO_SLV_REG4_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG4_OFFSET) ^ mask)) //!< Toggles the state of bits selected by mask in green LEDs
296#define userio_toggle_leds_rf(baseaddr, mask)       Xil_Out32(baseaddr+W3_USERIO_SLV_REG5_OFFSET, (Xil_In32(baseaddr+W3_USERIO_SLV_REG5_OFFSET) ^ mask)) //!< Toggles the state of bits selected by mask in RF LEDs
297/** @}*/
298
299/** \defgroup userio_masks Masks for user IO elements
300 *  \addtogroup userio_masks
301 * @{
302 */
303
304//reg1/reg2 masks
305#define W3_USERIO_HEXDISP_DP            0x100 //!< Mask for decimal point LEDs on hex displays
306
307//reg5 masks
308#define W3_USERIO_RFA_LED_GREEN         0x1 //!< Mask for green LED near RF A
309#define W3_USERIO_RFA_LED_RED           0x2 //!< Mask for red LED near RF A
310#define W3_USERIO_RFB_LED_GREEN         0x4 //!< Mask for green LED near RF B
311#define W3_USERIO_RFB_LED_RED           0x8 //!< Mask for red LED near RF B
312
313//reg6 masks
314#define W3_USERIO_PB_U  0x40 //!< Mask for up push button
315#define W3_USERIO_PB_M  0x20 //!< Mask for middle push button
316#define W3_USERIO_PB_D  0x10 //!< Mask for down push button
317#define W3_USERIO_DIPSW 0x0F //!< Mask for 4 positions of DIP switch
318/** @}*/
319
320/** \defgroup dbg_hdr Debug Header I/O
321The userio core implements an array of bi-directional buffers that can be routed to the WARP v3 board's debug header. The direction of each
322pin is configured at run time. This is similar to the Xilinx axi_gpio core. However the w3_userio implmenetaiton supports reading the current
323value of both inputs (like axi_gpi) and outputs (unlike axi_gpio). This allows read-modify-write of output bits, permitting simultaneous use
324of the debug header pins from multiple CPUs.
325
326 *  \addtogroup dbg_hdr
327 * @{
328 */
329//reg14 masks
330#define W3_USERIO_DBG_HDR_DIR_MASK      0xFFFF0000 //!< Mask for IOB direction control bits (1 per pin)
331#define W3_USERIO_DBG_HDR_CTRLSRC_MASK  0X0000FFFF //!< Mask for IOB control source (1=hw, 0=sw) bits
332#define W3_USERIO_DBG_HDR_VAL_MASK      0x0000FFFF //!< Mask for IOB data value bits (1 per pin)
333
334#define DBG_HDR_DIR_OUTPUT              0x0 //!< Flag for setting debug header IO as output via dir argument to userio_set_dbg_hdr_io_dir()
335#define DBG_HDR_DIR_INPUT               0x1 //!< Flag for setting debug header IO as input via dir argument to userio_set_dbg_hdr_io_dir()
336
337#define DBG_HDR_CTRLSRC_SW              0x0 //!< Flag for setting debug header IO as software-controlled output via ctrlsrc argument to userio_set_dbg_hdr_out_ctrlsrc()
338#define DBG_HDR_CTRLSRC_HW              0x1 //!< Flag for setting debug header IO as hardware-controlled output via ctrlsrc argument to userio_set_dbg_hdr_out_ctrlsrc()
339
340#define userio_set_dbg_hdr_io_dir(baseaddr, dir, pin_mask) Xil_Out32((baseaddr)+W3_USERIO_SLV_REG14_OFFSET, \
341    (dir) ? \
342    (Xil_In32(baseaddr + W3_USERIO_SLV_REG14_OFFSET) |  (((pin_mask) << 16) & W3_USERIO_DBG_HDR_DIR_MASK)) : \
343    (Xil_In32(baseaddr + W3_USERIO_SLV_REG14_OFFSET) & ~(((pin_mask) << 16) & W3_USERIO_DBG_HDR_DIR_MASK)))  //!< Configure IOB direction for debug header pins
344
345#define userio_set_dbg_hdr_out(baseaddr, pin_mask) Xil_Out32((baseaddr)+W3_USERIO_SLV_REG13_OFFSET, \
346    (Xil_In32(baseaddr + W3_USERIO_SLV_REG13_OFFSET) | ((pin_mask) & W3_USERIO_DBG_HDR_VAL_MASK)))   //!< Assert selected software-controlled debug header output pins
347
348#define userio_clear_dbg_hdr_out(baseaddr, pin_mask) Xil_Out32((baseaddr)+W3_USERIO_SLV_REG13_OFFSET, \
349    (Xil_In32(baseaddr + W3_USERIO_SLV_REG13_OFFSET) & ~((pin_mask) & W3_USERIO_DBG_HDR_VAL_MASK))) //!< Clear selected software-controlled debug header output pins
350
351#define userio_write_dbg_hdr_out(baseaddr, val) Xil_Out32((baseaddr)+W3_USERIO_SLV_REG13_OFFSET, \
352    ((Xil_In32(baseaddr + W3_USERIO_SLV_REG13_OFFSET) & ~W3_USERIO_DBG_HDR_VAL_MASK) | ((val) & W3_USERIO_DBG_HDR_VAL_MASK))) //!< Write value of all software-controlled debug header output pins
353   
354#define userio_read_dbg_hdr_io(baseaddr) (Xil_In32((baseaddr)+W3_USERIO_SLV_REG13_OFFSET) & W3_USERIO_DBG_HDR_VAL_MASK) //!< Read value of all debug header pins
355   
356#define userio_set_dbg_hdr_out_ctrlsrc(baseaddr, ctrlsrc, pin_mask) Xil_Out32((baseaddr)+W3_USERIO_SLV_REG14_OFFSET, \
357    (ctrlsrc) ? \
358    (Xil_In32(baseaddr + W3_USERIO_SLV_REG14_OFFSET) |  ((pin_mask) & W3_USERIO_DBG_HDR_CTRLSRC_MASK)) : \
359    (Xil_In32(baseaddr + W3_USERIO_SLV_REG14_OFFSET) & ~((pin_mask) & W3_USERIO_DBG_HDR_CTRLSRC_MASK))) //!< Configure output pins as controlled by software or hardware
360 
361 /** @}*/
362
363 
364/** \defgroup dna_read Reading FPGA DNA
365Every Virtex-6 FPGA has a unique "DNA" value embedded in the device. The w3_userio core implements logic to read this value into software-accessible registers. The
366DNA value is 56 bits, so two 32-bit registers are used to store the full value.
367
368<b>Hardware requirements:</b>
369<ul>
370<li>A clock signal slower than 100MHz must be connected to the w3_userio core DNA_Port_Clk port
371<li>The w3_userio core parameter INCLUDE_DNA_READ_LOGIC must be enabled
372</ul>
373If both requirements aren't met the DNA register values are undefined.
374
375The FPGA DNA value is also stored in the WARP v3 board EEPROM. Refer to the user guide EEPROM page for details.
376 *  \addtogroup dna_read
377 * @{
378 */
379#define userio_read_fpga_dna_lsb(baseaddr)  Xil_In32(baseaddr+W3_USERIO_SLV_REG12_OFFSET) //!< Returns the 32 LSB of the FPGA DNA
380#define userio_read_fpga_dna_msb(baseaddr)  Xil_In32(baseaddr+W3_USERIO_SLV_REG12_OFFSET) //!< Returns the 24 MSB of the FPGA DNA
381/** @}*/
382
383#endif /** W3_USERIO_H */
384
Note: See TracBrowser for help on using the repository browser.