Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/AD9467-FMC-EBZ/cf_ad9467.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file cf_ad9467.h
3 * @brief Header file of cf_ad9467 Driver.
4 ********************************************************************************
5 * Copyright 2012(c) Analog Devices, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * - Neither the name of Analog Devices, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 * - The use of this software may or may not infringe the patent rights
21 * of one or more patent holders. This license does not release you
22 * from the requirement that you obtain separate licenses from these
23 * patent holders to use this software.
24 * - Use of the software either in source or binary form, must be run
25 * on or directly connected to an Analog Devices Inc. component.
26 *
27 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
29 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
33 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 ********************************************************************************
39 * SVN Revision: $WCREV$
40 *******************************************************************************/
41 #ifndef __CF_AD9467_H__
42 #define __CF_AD9467_H__
43
44 /******************************************************************************/
45 /***************************** Include Files **********************************/
46 /******************************************************************************/
47 #include <stdint.h>
48 #include "xbasic_types.h"
49 #include "xparameters.h"
50
51 /******************************************************************************/
52 /******************* Macros and Constants Definitions *************************/
53 /******************************************************************************/
54 #ifdef _XPARAMETERS_PS_H_
55 #define CF_BASEADDR XPAR_AXI_AD9467_BASEADDR
56 #define DDR_BASEADDR XPAR_DDR_MEM_BASEADDR + 128*1024*1024
57 #define DMA_BASEADDR XPAR_AXI_DMA_0_BASEADDR
58 #define UART_BASEADDR XPS_UART1_BASEADDR
59 #define SPI_BASEADDR XPAR_AXI_SPI_0_BASEADDR
60 #else
61 #define CF_BASEADDR XPAR_AXI_AD9467_BASEADDR
62 #define DDR_BASEADDR XPAR_AXI_DDR_CNTRL_BASEADDR
63 #define DMA_BASEADDR XPAR_AXI_DMA_0_BASEADDR
64 #define UART_BASEADDR XPS_UART1_BASEADDR
65 #define SPI_BASEADDR XPAR_AXI_SPI_0_BASEADDR
66 #endif
67
68 /* ADC registers */
69 #define CF_REG_DELAY_CTRL 0x60
70 #define CF_REG_DELAY_STATUS 0x20
71 #define CF_REG_DATA_MONITOR 0x404
72
73 /* CF_REG_DELAY_CTRL bit definition. */
74 #define CF_DELAY_CTRL_SEL(x) (((x) & 0x1) << 17)
75 #define CF_DELAY_CTRL_RW_ENABLE(x) (((x) & 0x1) << 16)
76 #define CF_DELAY_CTRL_WR_ADDR(x) (((x) & 0xF) << 8)
77 #define CF_DELAY_CTRL_WR_DATA(x) (((x) & 0x1F) << 0)
78
79 /* CF_REG_DELAY_STATUS bit definition. */
80 #define CF_DELAY_STATUS_LOCKED (1 << 9) // (Read Only)
81 #define CF_DELAY_STATUS_STATUS (1 << 8) // (Read Only)
82 #define CF_DELAY_STATUS_RD_DATA (0x1F << 0) // (Read Only)
83
84 /* CF_REG_DATA_MONITOR bit definition. */
85 #define CF_DATA_MONITOR_PN_ERR (1 << 2) // (Write 1 to clear)
86 #define CF_DATA_MONITOR_PN_SYNC (1 << 1) // (Write 1 to clear)
87 #define CF_DATA_MONITOR_PN_OVER_RNG (1 << 0) // (Write 1 to clear)
88
89 #define ADC_REG_RSTN 0x040
90 #define ADC_MMCM_RSTN (1 << 1)
91 #define ADC_RSTN (1 << 0)
92
93 #define ADC_REG_CHAN_CNTRL(c) (0x0400 + (c) * 0x40)
94 #define ADC_PN_SEL (1 << 10) /* !v8.0 */
95 #define ADC_IQCOR_ENB (1 << 9)
96 #define ADC_DCFILT_ENB (1 << 8)
97 #define ADC_FORMAT_SIGNEXT (1 << 6)
98 #define ADC_FORMAT_TYPE (1 << 5)
99 #define ADC_FORMAT_ENABLE (1 << 4)
100 #define ADC_PN23_TYPE (1 << 1) /* !v8.0 */
101 #define ADC_ENABLE (1 << 0)
102
103 #define ADC_REG_CHAN_CNTRL_3(c) (0x0418 + (c) * 0x40) /* v8.0 */
104 #define ADC_ADC_PN_SEL(x) (((x) & 0xF) << 16)
105 #define ADC_TO_ADC_PN_SEL(x) (((x) >> 16) & 0xF)
106 #define ADC_ADC_DATA_SEL(x) (((x) & 0xF) << 0)
107 #define ADC_TO_ADC_DATA_SEL(x) (((x) >> 0) & 0xF)
108
109 /* DMAC registers */
110 #define AXI_DMAC_REG_IRQ_MASK 0x80
111 #define AXI_DMAC_REG_IRQ_PENDING 0x84
112 #define AXI_DMAC_REG_IRQ_SOURCE 0x88
113 #define AXI_DMAC_REG_CTRL 0x400
114 #define AXI_DMAC_REG_TRANSFER_ID 0x404
115 #define AXI_DMAC_REG_START_TRANSFER 0x408
116 #define AXI_DMAC_REG_FLAGS 0x40c
117 #define AXI_DMAC_REG_DEST_ADDRESS 0x410
118 #define AXI_DMAC_REG_SRC_ADDRESS 0x414
119 #define AXI_DMAC_REG_X_LENGTH 0x418
120 #define AXI_DMAC_REG_Y_LENGTH 0x41c
121 #define AXI_DMAC_REG_DEST_STRIDE 0x420
122 #define AXI_DMAC_REG_SRC_STRIDE 0x424
123 #define AXI_DMAC_REG_TRANSFER_DONE 0x428
124 #define AXI_DMAC_REG_ACTIVE_TRANSFER_ID 0x42c
125 #define AXI_DMAC_REG_STATUS 0x430
126 #define AXI_DMAC_REG_CURRENT_DEST_ADDR 0x434
127 #define AXI_DMAC_REG_CURRENT_SRC_ADDR 0x438
128 #define AXI_DMAC_REG_DBG0 0x43c
129 #define AXI_DMAC_REG_DBG1 0x440
130
131 #define AXI_DMAC_CTRL_ENABLE (1 << 0)
132 #define AXI_DMAC_CTRL_PAUSE (1 << 1)
133
134 #define AXI_DMAC_IRQ_SOT (1 << 0)
135 #define AXI_DMAC_IRQ_EOT (1 << 1)
136
137 /******************************************************************************/
138 /************************** Types Declarations ********************************/
139 /******************************************************************************/
140 typedef enum _TestModes
141 {
142 TEST_DISABLE = 0,
143 MIDSCALE,
144 POS_FULLSCALE,
145 NEG_FULLSCALE,
146 CHECKERBOARD,
147 PN_23_SEQUENCE,
148 PN_9_SEQUENCE,
149 ONE_ZERO_TOGGLE
150
151 }typeTestModes;
152
153 typedef enum _OutputModes
154 {
155 OFFSET_BINARY = 0,
156 TWOS_COMPLEMENT,
157 GRAY_CODE,
158
159 }typeOutputModes;
160
161 enum adc_pnsel {
162 ADC_PN9 = 0,
163 ADC_PN23A = 1,
164 ADC_PN7 = 4,
165 ADC_PN15 = 5,
166 ADC_PN23 = 6,
167 ADC_PN31 = 7,
168 ADC_PN_CUSTOM = 9,
169 ADC_PN_END = 10,
170 };
171
172 /*******************************************************************************/
173 /************************ Functions Declarations *******************************/
174 /*******************************************************************************/
175 /*! Initializes the ADC FPGA core. */
176 void adc_setup(uint32_t dco_delay);
177 /*! Configures the AD9467 device to run in the selected test mode. */
178 void adc_test(uint32_t mode, uint32_t format);
179 /*! Captures a specified number of samples from the ADC. */
180 void adc_capture(uint32_t qwcnt, uint32_t sa);
181
182 #endif /* __CF_AD9467_H__ */