[1927] | 1 | /***************************************************************** |
---|
| 2 | * File: w3_userio.h |
---|
[2825] | 3 | * Copyright (c) 2014 Mango Communications, all rights reseved |
---|
[1927] | 4 | * Released under the WARP License |
---|
| 5 | * See http://warp.rice.edu/license for details |
---|
| 6 | *****************************************************************/ |
---|
| 7 | |
---|
| 8 | /*! \file w3_userio.h |
---|
| 9 | |
---|
| 10 | \mainpage |
---|
| 11 | This is the driver for the w3_userio core, which provides access to all the user IO resources on WARP v3 boards. These resources include |
---|
| 12 | user LEDs, RF LEDs, hex displays, push buttons and a DIP switch. |
---|
| 13 | |
---|
| 14 | This 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 | |
---|
[2826] | 16 | @version 1.01.a |
---|
[1927] | 17 | @author Patrick Murphy |
---|
[2826] | 18 | @copyright (c) 2014 Mango Communications, Inc. All rights reserved.<br> |
---|
[1927] | 19 | Released under the WARP open source license (see http://warp.rice.edu/license) |
---|
| 20 | |
---|
| 21 | */ |
---|
| 22 | /* Address map: |
---|
| 23 | HDL is coded [31:0], adopting Xilinx's convention for AXI IPIF cores |
---|
| 24 | All registers are 32-bits |
---|
| 25 | regX[31] maps to 0x80000000 in C driver |
---|
| 26 | regX[0] maps to 0x00000001 in C driver |
---|
| 27 | |
---|
| 28 | 0: Control RW |
---|
| 29 | [31:30] = Reserved |
---|
| 30 | [ 29] = Left hex data mode (0=user supplies bit-per-segment; 1=user supplies 4-bit hex) 0x20000000 |
---|
| 31 | [ 28] = Right hex data mode (0=user supplies bit-per-segment; 1=user supplies 4-bit hex) 0x10000000 |
---|
| 32 | Control source for LEDs: 0=software controlled, 1=usr_ port controlled |
---|
| 33 | [27:24] = {rfb_red rfb_green rfa_red rfa_green} 0x0F000000 |
---|
| 34 | [23:16] = {leds_red leds_green} 0x00FF0000 |
---|
[3463] | 35 | [15: 8] = {hexdisp_right{a b c d e f g dp}} 0x0000FF00 |
---|
| 36 | [ 7: 0] = {hexdisp_left{a b c d e f g dp}} 0x000000FF !! Left/Right are swapped in user_logic.v comments |
---|
[1927] | 37 | 1: Left hex display RW |
---|
| 38 | [31: 9] = reserved |
---|
| 39 | [ 8] = DP (controlled directly; doesn't depend on data mode) 0x100 |
---|
| 40 | [ 6: 0] = Data value ([6:4] ignored when data mode = 1) 0x03F |
---|
| 41 | 2: Right hex display RW |
---|
| 42 | [31: 9] = reserved |
---|
| 43 | [ 8] = DP (controlled directly; doesn't depend on data mode) 0x100 |
---|
| 44 | [ 6: 0] = Data value ([6:4] ignored when data mode = 1) 0x03F |
---|
| 45 | 3: Red user LEDs RW |
---|
| 46 | [31: 4] = reserved |
---|
| 47 | [ 3: 0] = Data value (1=LED illuminated) 0xF, with 0x1 mapped to lowest LED |
---|
| 48 | 4: Green user LEDs RW |
---|
| 49 | [31: 4] = reserved |
---|
| 50 | [ 3: 0] = Data value (1=LED illuminated) 0xF, with 0x1 mapped to lowest LED |
---|
| 51 | 5: RF LEDs RW |
---|
| 52 | [31: 4] = reserved |
---|
| 53 | [ 3] = rfb_red 0x8 |
---|
| 54 | [ 2] = rfb_green 0x4 |
---|
| 55 | [ 1] = rfa_red 0x2 |
---|
| 56 | [ 0] = rfa_green 0x1 |
---|
| 57 | 6: Switch/button inputs RO |
---|
| 58 | [31: 7] = reserved |
---|
| 59 | [ 6] = pb_up 0x40 |
---|
| 60 | [ 5] = pb_mid 0x20 |
---|
| 61 | [ 4] = pb_down 0x10 |
---|
| 62 | [ 3: 0] = DIP switch 0x0F (with 0x1 mapped to right-most switch) |
---|
| 63 | |
---|
[2825] | 64 | 7: PWM Gen Param: PWM period RW |
---|
| 65 | [31:29] = reserved |
---|
| 66 | [28: 0] = PWN period |
---|
[1927] | 67 | |
---|
[2825] | 68 | 8: PWM Gen Param: PWM output deassert thresh RW |
---|
| 69 | [31:29] = reserved |
---|
| 70 | [28: 0] = PWM output deassert thresh |
---|
| 71 | |
---|
| 72 | 9: PWM Gen Param: PWM ramp step RW |
---|
| 73 | [31] = ramp enabled |
---|
| 74 | [30:20] = reserved |
---|
| 75 | [19: 0] = PWM thresh ramp step |
---|
| 76 | |
---|
| 77 | 10: HW Output control sel RW |
---|
| 78 | [31:28] = Reserved |
---|
| 79 | HW Control source for LEDs: 0=usr_ ports, 1=pwm gen (same ctrlSrc masks as reg0) |
---|
| 80 | [27:24] = {rfb_red rfb_green rfa_red rfa_green} 0x0F000000 |
---|
| 81 | [23:16] = {leds_red leds_green} 0x00FF0000 |
---|
| 82 | [15: 8] = {hexdisp_left{a b c d e f g dp}} 0x0000FF00 |
---|
| 83 | [ 7: 0] = {hexdisp_right{a b c d e f g dp}} 0x000000FF |
---|
| 84 | |
---|
| 85 | 11: FPGA DNA LSB |
---|
| 86 | [31: 0] = 32LSB of FPGA DNA |
---|
| 87 | |
---|
| 88 | 12: FPGA DNA MSB |
---|
| 89 | [31:25] = reserved |
---|
| 90 | [24: 0] = FPGA DNA 25MSB |
---|
| 91 | */ |
---|
| 92 | |
---|
[1927] | 93 | #ifndef W3_USERIO_H |
---|
| 94 | #define W3_USERIO_H |
---|
| 95 | |
---|
| 96 | #include "xil_io.h" |
---|
| 97 | |
---|
| 98 | /// @cond EXCLUDE_FROM_DOCS |
---|
| 99 | // Address offset for each slave register; exclude from docs, as users never use these directly |
---|
| 100 | #define W3_USERIO_USER_SLV_SPACE_OFFSET (0x00000000) |
---|
| 101 | #define W3_USERIO_SLV_REG0_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000000) |
---|
| 102 | #define W3_USERIO_SLV_REG1_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000004) |
---|
| 103 | #define W3_USERIO_SLV_REG2_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000008) |
---|
| 104 | #define W3_USERIO_SLV_REG3_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x0000000C) |
---|
| 105 | #define W3_USERIO_SLV_REG4_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000010) |
---|
| 106 | #define W3_USERIO_SLV_REG5_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000014) |
---|
| 107 | #define W3_USERIO_SLV_REG6_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000018) |
---|
| 108 | #define W3_USERIO_SLV_REG7_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x0000001C) |
---|
| 109 | #define W3_USERIO_SLV_REG8_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000020) |
---|
| 110 | #define W3_USERIO_SLV_REG9_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000024) |
---|
| 111 | #define W3_USERIO_SLV_REG10_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000028) |
---|
| 112 | #define W3_USERIO_SLV_REG11_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x0000002C) |
---|
[2825] | 113 | #define W3_USERIO_SLV_REG12_OFFSET (W3_USERIO_USER_SLV_SPACE_OFFSET + 0x00000030) |
---|
[1927] | 114 | /// @endcond |
---|
| 115 | |
---|
[2827] | 116 | /** \defgroup control_reg Control registers |
---|
[1927] | 117 | * \addtogroup control_reg |
---|
| 118 | <b>Hardware vs. software control</b>: |
---|
| 119 | Every LED and hex display segment can be controlled either via software or hardware: |
---|
| 120 | <ul> |
---|
[2827] | 121 | <li><b>Software</b>: user code sets LED state by writing a 1 to the corresponding register bit |
---|
| 122 | <li><b>Hardware</b>: Two modes:<ul> |
---|
| 123 | <li><b>Port mode</b>: LED state is controlled by corresponding usr_* port |
---|
| 124 | <li><b>PWM mode</b>: LED state is controlled by internal PWM waveform generator |
---|
| 125 | </ul> |
---|
[1927] | 126 | </ul> |
---|
| 127 | |
---|
[2826] | 128 | The 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 |
---|
[1927] | 129 | for all other LED/hex display outputs. |
---|
| 130 | |
---|
| 131 | The control source (hw or sw) for each output bit is set by the control register described below. |
---|
| 132 | |
---|
| 133 | Examples: |
---|
| 134 | \code{.c} |
---|
| 135 | //Assumes user code sets USERIO_BASEADDR to base address of w3_userio core, as set in xparameters.h |
---|
| 136 | |
---|
[2827] | 137 | //------------------------------------------------------------------------------ |
---|
| 138 | // Set both hex dipslays to map 4-bit to 7-segment values automatically |
---|
[1927] | 139 | userio_write_control(USERIO_BASEADDR, (W3_USERIO_HEXDISP_L_MAPMODE | W3_USERIO_HEXDISP_R_MAPMODE)); |
---|
| 140 | |
---|
[2827] | 141 | //------------------------------------------------------------------------------ |
---|
| 142 | // Select software control of all outputs |
---|
[1927] | 143 | userio_set_ctrlSrc_sw(USERIO_BASEADDR, (W3_USERIO_CTRLSRC_LEDS_RF | W3_USERIO_CTRLSRC_LEDS | W3_USERIO_CTRLSRC_HEXDISPS)); |
---|
| 144 | |
---|
[2827] | 145 | //------------------------------------------------------------------------------ |
---|
| 146 | // Select hardware/port control of RF LEDs |
---|
[1927] | 147 | userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RF); |
---|
| 148 | |
---|
[2827] | 149 | //------------------------------------------------------------------------------ |
---|
| 150 | // Enable hardware control of green user LEDs, software control of red user LEDs |
---|
[1927] | 151 | userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_GREEN); |
---|
| 152 | userio_set_ctrlSrc_sw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RED); |
---|
[2826] | 153 | |
---|
[2827] | 154 | //------------------------------------------------------------------------------ |
---|
| 155 | // Use the PWM generator to slowly blink the green LEDs |
---|
[2826] | 156 | userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_GREEN); |
---|
| 157 | userio_set_hw_ctrl_mode_pwm(USERIO_BASEADDR, (W3_USERIO_CTRLSRC_LEDS_GREEN); |
---|
| 158 | userio_set_pwm_ramp_en(USERIO_BASEADDR, 0); |
---|
| 159 | userio_set_pwm_period(USERIO_BASEADDR, 65530); |
---|
| 160 | userio_set_pwm_thresh(USERIO_BASEADDR, 65530/2); |
---|
| 161 | |
---|
[2827] | 162 | //------------------------------------------------------------------------------ |
---|
| 163 | // Use the PWM generator to show a "sleep" pattern on red LEDs |
---|
[2826] | 164 | userio_set_ctrlSrc_hw(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RED); |
---|
| 165 | userio_set_hw_ctrl_mode_pwm(USERIO_BASEADDR, W3_USERIO_CTRLSRC_LEDS_RED); |
---|
| 166 | |
---|
[2827] | 167 | //Use fast period so blinking is not visable |
---|
| 168 | // (fast blink with low duty cycle looks like a dim constant brightness) |
---|
[2826] | 169 | userio_set_pwm_period(USERIO_BASEADDR, 500); |
---|
| 170 | |
---|
| 171 | //Ramp must be disabled when changing ramp params |
---|
| 172 | userio_set_pwm_ramp_en(USERIO_BASEADDR, 0); |
---|
| 173 | userio_set_pwm_ramp_min(USERIO_BASEADDR, 2); |
---|
| 174 | userio_set_pwm_ramp_max(USERIO_BASEADDR, 250); |
---|
| 175 | userio_set_pwm_ramp_en(USERIO_BASEADDR, 1); |
---|
[1927] | 176 | \endcode |
---|
| 177 | |
---|
| 178 | * @{ |
---|
| 179 | */ |
---|
| 180 | |
---|
| 181 | #define userio_read_control(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG0_OFFSET) //!< Returns the value of the control register |
---|
| 182 | #define userio_write_control(baseaddr, x) Xil_Out32(baseaddr+W3_USERIO_SLV_REG0_OFFSET, x) //!< Sets the control register to x |
---|
| 183 | |
---|
[2826] | 184 | #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) |
---|
[1927] | 185 | #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) |
---|
| 186 | |
---|
[2826] | 187 | #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 |
---|
| 188 | #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 |
---|
[2825] | 189 | |
---|
| 190 | //PWM config macros |
---|
[2826] | 191 | #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 |
---|
| 192 | #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 |
---|
| 193 | #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 |
---|
| 194 | #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 |
---|
| 195 | #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 |
---|
[2825] | 196 | |
---|
[1927] | 197 | //reg0 masks |
---|
| 198 | #define W3_USERIO_HEXDISP_L_MAPMODE 0x20000000 //!< Enables 4-bit to 7-segment mapping for left hex display |
---|
| 199 | #define W3_USERIO_HEXDISP_R_MAPMODE 0x10000000 //!< Enables 4-bit to 7-segment mapping for right hex display |
---|
| 200 | #define W3_USERIO_CTRLSRC_LED_RFB_RED 0x08000000 //!< Control source selection mask for red LED near RF B |
---|
| 201 | #define W3_USERIO_CTRLSRC_LED_RFB_GREEN 0x04000000 //!< Control source selection mask for green LED near RF B |
---|
| 202 | #define W3_USERIO_CTRLSRC_LED_RFA_RED 0x02000000 //!< Control source selection mask for red LED near RF A |
---|
| 203 | #define W3_USERIO_CTRLSRC_LED_RFA_GREEN 0x01000000 //!< Control source selection mask for green LED near RF A |
---|
| 204 | #define W3_USERIO_CTRLSRC_LEDS_RED 0x000F0000 //!< Control source selection mask for the red user LEDs |
---|
| 205 | #define W3_USERIO_CTRLSRC_LEDS_GREEN 0x00F00000 //!< Control source selection mask for the green user LEDs |
---|
[3462] | 206 | #define W3_USERIO_CTRLSRC_HEXDISP_R 0x0000FF00 //!< Control source selection mask for the left hex display (includes decimal point) |
---|
| 207 | #define W3_USERIO_CTRLSRC_HEXDISP_L 0x000000FF //!< Control source selection mask for the right hex display (includes decimal point) |
---|
| 208 | #define W3_USERIO_CTRLSRC_HEXDISP_DP_R 0x00008000 //!< Control source selection mask for the left hex display decimal point |
---|
| 209 | #define W3_USERIO_CTRLSRC_HEXDISP_DP_L 0x00000080 //!< Control source selection mask for the right hex display decimal point |
---|
[1927] | 210 | |
---|
| 211 | #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 |
---|
| 212 | #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 |
---|
| 213 | #define W3_USERIO_CTRLSRC_LEDS_RF (W3_USERIO_CTRLSRC_LEDS_RFA | W3_USERIO_CTRLSRC_LEDS_RFB) //!< Control source selection masks for all RF LEDs |
---|
| 214 | #define W3_USERIO_CTRLSRC_LEDS (W3_USERIO_CTRLSRC_LEDS_RED | W3_USERIO_CTRLSRC_LEDS_GREEN) //!< Control source selection masks for all user LEDs |
---|
| 215 | #define W3_USERIO_CTRLSRC_HEXDISPS (W3_USERIO_CTRLSRC_HEXDISP_L | W3_USERIO_CTRLSRC_HEXDISP_R) //!< Control source selection masks for both hex displays |
---|
[2825] | 216 | |
---|
[2826] | 217 | #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 |
---|
[1927] | 218 | /** @}*/ |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | /** \defgroup userio_read Reading user IO |
---|
| 222 | <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 |
---|
| 223 | of outputs configured for hardware control (i.e. outputs with corresponding CTRLSRC_* asserted in control reg) will not reflect actual output state. |
---|
| 224 | |
---|
| 225 | Examples: |
---|
| 226 | \code{.c} |
---|
| 227 | //Assumes user code sets USERIO_BASEADDR to base address of w3_userio core, as set in xparameters.h |
---|
| 228 | |
---|
| 229 | //Check if middle push button is being pressed |
---|
| 230 | if(userio_read_inputs(USERIO_BASEADDR) & W3_USERIO_PB_M) {...} |
---|
| 231 | |
---|
| 232 | //Read 4-bit DIP switch value |
---|
| 233 | u8 x = userio_read_inputs(USERIO_BASEADDR) & W3_USERIO_DIPSW; |
---|
| 234 | \endcode |
---|
| 235 | |
---|
| 236 | * \addtogroup userio_read |
---|
| 237 | * @{ |
---|
| 238 | */ |
---|
| 239 | #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) |
---|
| 240 | #define userio_read_hexdisp_left(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG1_OFFSET) //!< Returns the current state of the left hex display outputs |
---|
| 241 | #define userio_read_hexdisp_right(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG2_OFFSET) //!< Returns the current state of the right hex display outputs |
---|
| 242 | #define userio_read_leds_red(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG3_OFFSET) //!< Returns the current state of the red user LEDs |
---|
| 243 | #define userio_read_leds_green(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG4_OFFSET) //!< Returns the current state of the green user LEDs |
---|
| 244 | #define userio_read_leds_rf(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG5_OFFSET) //!< Returns the current state of the RF LEDs |
---|
| 245 | /** @}*/ |
---|
| 246 | |
---|
| 247 | /** \defgroup userio_write Setting user outputs |
---|
| 248 | |
---|
| 249 | <b>Hex display notes:</b> |
---|
| 250 | The w3_userio core implements logic to map 4-bit values to the 7-segment representation of the corresponding hex value. When this mode |
---|
| 251 | is 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 |
---|
| 252 | mode is disabled, the user value is driven directly to the 7-segments of the hex display. |
---|
| 253 | |
---|
| 254 | The 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. |
---|
| 255 | |
---|
| 256 | Examples: |
---|
| 257 | \code{.c} |
---|
| 258 | //Assumes user code sets USERIO_BASEADDR to base address of w3_userio core, as set in xparameters.h |
---|
| 259 | |
---|
| 260 | //Display "B" on the left hex dipslay (assumes map mode is enabled; see control register docs) |
---|
| 261 | userio_write_hexdisp_left(USERIO_ADDR, 0xB); |
---|
| 262 | |
---|
| 263 | //Display "4" on the right hex dipslay and light the decimal point (assumes map mode is enabled; see control register docs) |
---|
| 264 | userio_write_hexdisp_right(USERIO_ADDR, (0x4 | W3_USERIO_HEXDISP_DP) ); |
---|
| 265 | |
---|
| 266 | //Turn off all four green user LEDs |
---|
| 267 | userio_write_leds_green(USERIO_ADDR, 0); |
---|
| 268 | |
---|
| 269 | //Toggle the 2 LSB of the red user LEDs |
---|
| 270 | userio_toggle_leds_red(USERIO_ADDR, 0x3); |
---|
| 271 | |
---|
| 272 | \endcode |
---|
| 273 | * \addtogroup userio_write |
---|
| 274 | * @{ |
---|
| 275 | */ |
---|
| 276 | #define userio_write_hexdisp_left(baseaddr, x) Xil_Out32(baseaddr+W3_USERIO_SLV_REG1_OFFSET, x) //!< Sets the left hex dispaly |
---|
| 277 | #define userio_write_hexdisp_right(baseaddr, x) Xil_Out32(baseaddr+W3_USERIO_SLV_REG2_OFFSET, x) //!< Sets the right hex dispaly |
---|
| 278 | #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) |
---|
| 279 | #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) |
---|
| 280 | #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) |
---|
| 281 | #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 |
---|
| 282 | #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 |
---|
| 283 | #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 |
---|
| 284 | #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 |
---|
| 285 | #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 |
---|
| 286 | /** @}*/ |
---|
| 287 | |
---|
| 288 | /** \defgroup userio_masks Masks for user IO elements |
---|
| 289 | * \addtogroup userio_masks |
---|
| 290 | * @{ |
---|
| 291 | */ |
---|
| 292 | |
---|
| 293 | //reg1/reg2 masks |
---|
| 294 | #define W3_USERIO_HEXDISP_DP 0x100 //!< Mask for decimal point LEDs on hex displays |
---|
| 295 | |
---|
| 296 | //reg5 masks |
---|
| 297 | #define W3_USERIO_RFA_LED_GREEN 0x1 //!< Mask for green LED near RF A |
---|
| 298 | #define W3_USERIO_RFA_LED_RED 0x2 //!< Mask for red LED near RF A |
---|
| 299 | #define W3_USERIO_RFB_LED_GREEN 0x4 //!< Mask for green LED near RF B |
---|
| 300 | #define W3_USERIO_RFB_LED_RED 0x8 //!< Mask for red LED near RF B |
---|
| 301 | |
---|
| 302 | //reg6 masks |
---|
| 303 | #define W3_USERIO_PB_U 0x40 //!< Mask for up push button |
---|
| 304 | #define W3_USERIO_PB_M 0x20 //!< Mask for middle push button |
---|
| 305 | #define W3_USERIO_PB_D 0x10 //!< Mask for down push button |
---|
| 306 | #define W3_USERIO_DIPSW 0x0F //!< Mask for 4 positions of DIP switch |
---|
| 307 | /** @}*/ |
---|
| 308 | |
---|
| 309 | /** \defgroup dna_read Reading FPGA DNA |
---|
| 310 | Every 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 |
---|
| 311 | DNA value is 56 bits, so two 32-bit registers are used to store the full value. |
---|
| 312 | |
---|
| 313 | <b>Hardware requirements:</b> |
---|
| 314 | <ul> |
---|
| 315 | <li>A clock signal slower than 100MHz must be connected to the w3_userio core DNA_Port_Clk port |
---|
| 316 | <li>The w3_userio core parameter INCLUDE_DNA_READ_LOGIC must be enabled |
---|
| 317 | </ul> |
---|
| 318 | If both requirements aren't met the DNA register values are undefined. |
---|
| 319 | |
---|
| 320 | The FPGA DNA value is also stored in the WARP v3 board EEPROM. Refer to the user guide EEPROM page for details. |
---|
| 321 | * \addtogroup dna_read |
---|
| 322 | * @{ |
---|
| 323 | */ |
---|
[2825] | 324 | #define userio_read_fpga_dna_lsb(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG12_OFFSET) //!< Returns the 32 LSB of the FPGA DNA |
---|
| 325 | #define userio_read_fpga_dna_msb(baseaddr) Xil_In32(baseaddr+W3_USERIO_SLV_REG12_OFFSET) //!< Returns the 24 MSB of the FPGA DNA |
---|
[1927] | 326 | /** @}*/ |
---|
| 327 | |
---|
| 328 | #endif /** W3_USERIO_H */ |
---|
| 329 | |
---|