Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/fmcdaq3/fmcdaq3.c

raw symbols SCIP
1 /***************************************************************************//**
2 * @file ad_fmcdaq3_ebz.c
3 * @brief Implementation of Main Function.
4 * @author DBogdan ([email protected])
5 ********************************************************************************
6 * Copyright 2015(c) Analog Devices, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * - Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * - Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 * - The use of this software may or may not infringe the patent rights
22 * of one or more patent holders. This license does not release you
23 * from the requirement that you obtain separate licenses from these
24 * patent holders to use this software.
25 * - Use of the software either in source or binary form, must be run
26 * on or directly connected to an Analog Devices Inc. component.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *******************************************************************************/
39
40 /******************************************************************************/
41 /***************************** Include Files **********************************/
42 /******************************************************************************/
43
44 #include "platform_drivers.h"
45 #include "ad9152.h"
46 #include "ad9528.h"
47 #include "ad9680.h"
48 #include "adc_core.h"
49 #include "dac_core.h"
50 #include "xcvr_core.h"
51 #include "jesd_core.h"
52
53 /******************************************************************************/
54 /********************** Macros and Constants Definitions **********************/
55 /******************************************************************************/
56
57 #define GPIO_CLKD_STATUS_0 32
58 #define GPIO_CLKD_STATUS_1 33
59 #define GPIO_DAC_IRQ 34
60 #define GPIO_ADC_FDA 35
61 #define GPIO_ADC_FDB 36
62 #define GPIO_DAC_TXEN 37
63 #define GPIO_ADC_PD 38
64 #define GPIO_TRIG 39
65
66 /***************************************************************************//**
67 * @brief main
68 *******************************************************************************/
69 int main(void)
70 {
71 spi_device ad9528_spi_device;
72 spi_device ad9152_spi_device;
73 spi_device ad9680_spi_device;
74 ad9528_channel_spec ad9528_channels[8];
75 ad9528_platform_data ad9528_param;
76 ad9152_init_param ad9152_param;
77 ad9680_init_param ad9680_param;
78 xcvr_core ad9152_xcvr;
79 jesd_core ad9152_jesd;
80 dac_channel ad9152_channels[2];
81 dac_core ad9152_core;
82 xcvr_core ad9680_xcvr;
83 jesd_core ad9680_jesd;
84 adc_core ad9680_core;
85
86 ad_spi_init(&ad9528_spi_device);
87 ad_spi_init(&ad9152_spi_device);
88 ad_spi_init(&ad9680_spi_device);
89
90 ad9528_spi_device.chip_select = 0x6;
91 ad9152_spi_device.chip_select = 0x5;
92 ad9680_spi_device.chip_select = 0x3;
93
94 // ad9528 defaults
95
96 ad9528_param.num_channels = 8;
97 ad9528_param.channels = &ad9528_channels[0];
98 ad9528_init(&ad9528_param);
99
100 // dac-device-clock (1.25G) & sysref (2.44M)
101
102 ad9528_channels[0].channel_num = 2;
103 ad9528_channels[0].channel_divider = 1;
104 ad9528_channels[1].channel_num = 8;
105 ad9528_channels[1].channel_divider = 512;
106
107 // dac-fpga-clock (625M) & sysref (2.44M)
108
109 ad9528_channels[2].channel_num = 9;
110 ad9528_channels[2].channel_divider = 2;
111 ad9528_channels[3].channel_num = 7;
112 ad9528_channels[3].channel_divider = 512;
113
114 // adc-device-clock (1.2G) & sysref (2.44M)
115
116 ad9528_channels[4].channel_num = 13;
117 ad9528_channels[4].channel_divider = 1;
118 ad9528_channels[5].channel_num = 5;
119 ad9528_channels[5].channel_divider = 512;
120
121 // adc-fpga-clock (625M) & sysref (2.44M)
122
123 ad9528_channels[6].channel_num = 4;
124 ad9528_channels[6].channel_divider = 2;
125 ad9528_channels[7].channel_num = 6;
126 ad9528_channels[7].channel_divider = 512;
127
128 // pllx settings
129
130 ad9528_param.spi3wire = 1;
131 ad9528_param.vcxo_freq = 125000000;
132 ad9528_param.osc_in_diff_en = 1;
133 ad9528_param.pll2_charge_pump_current_nA = 805000;
134 ad9528_param.pll2_vco_diff_m1 = 3;
135 ad9528_param.pll2_ndiv_a_cnt = 2;
136 ad9528_param.pll2_ndiv_b_cnt = 7;
137 ad9528_param.pll2_n2_div = 10;
138 ad9528_param.sysref_k_div = 512;
139 ad9528_param.rpole2 = RPOLE2_900_OHM;
140 ad9528_param.rzero= RZERO_3250_OHM;
141 ad9528_param.cpole1 = CPOLE1_16_PF;
142
143 // dac settings
144
145 ad9152_xcvr.mmcm_present = 0;
146 ad9152_xcvr.reconfig_bypass = 1;
147 ad9152_xcvr.rx_tx_n = 0;
148 ad9152_xcvr.no_of_lanes = 4;
149 ad9152_xcvr.lane_rate_kbps = 10*1000*1000;
150
151 ad9152_jesd.rx_tx_n = 0;
152 ad9152_jesd.scramble_enable = 1;
153 ad9152_jesd.octets_per_frame = 1;
154 ad9152_jesd.frames_per_multiframe = 32;
155 ad9152_jesd.subclass_mode = 1;
156
157 ad9152_channels[0].dds_dual_tone = 0;
158 ad9152_channels[0].dds_frequency_0 = 33*1000*1000;
159 ad9152_channels[0].dds_phase_0 = 0;
160 ad9152_channels[0].dds_scale_0 = 500000;
161 ad9152_channels[0].sel = DAC_SRC_DDS;
162 ad9152_channels[1].dds_dual_tone = 0;
163 ad9152_channels[1].dds_frequency_0 = 11*1000*1000;
164 ad9152_channels[1].dds_phase_0 = 0;
165 ad9152_channels[1].dds_scale_0 = 500000;
166 ad9152_channels[0].pat_data = 0xb1b0a1a0;
167 ad9152_channels[1].pat_data = 0xd1d0c1c0;
168 ad9152_channels[1].sel = DAC_SRC_DDS;
169
170 ad9152_core.no_of_channels = 2;
171 ad9152_core.resolution = 16;
172 ad9152_core.channels = &ad9152_channels[0];
173
174 ad9152_param.stpl_samples[0][0] = (ad9152_channels[0].pat_data>> 0) & 0xffff;
175 ad9152_param.stpl_samples[0][1] = (ad9152_channels[0].pat_data>>16) & 0xffff;
176 ad9152_param.stpl_samples[0][2] = (ad9152_channels[0].pat_data>> 0) & 0xffff;
177 ad9152_param.stpl_samples[0][3] = (ad9152_channels[0].pat_data>>16) & 0xffff;
178 ad9152_param.stpl_samples[1][0] = (ad9152_channels[1].pat_data>> 0) & 0xffff;
179 ad9152_param.stpl_samples[1][1] = (ad9152_channels[1].pat_data>>16) & 0xffff;
180 ad9152_param.stpl_samples[1][2] = (ad9152_channels[1].pat_data>> 0) & 0xffff;
181 ad9152_param.stpl_samples[1][3] = (ad9152_channels[1].pat_data>>16) & 0xffff;
182 ad9152_param.interpolation = 1;
183 ad9152_param.lane_rate_kbps = 10000000;
184
185 // adc settings
186
187 ad9680_param.lane_rate_kbps = 10000000;
188
189 ad9680_xcvr.mmcm_present = 0;
190 ad9680_xcvr.reconfig_bypass = 1;
191 ad9680_xcvr.rx_tx_n = 1;
192 ad9680_xcvr.no_of_lanes = 4;
193 ad9680_xcvr.lane_rate_kbps = 10*1000*1000;
194
195 ad9680_jesd.rx_tx_n = 1;
196 ad9680_jesd.scramble_enable = 1;
197 ad9680_jesd.octets_per_frame = 1;
198 ad9680_jesd.frames_per_multiframe = 32;
199 ad9680_jesd.subclass_mode = 1;
200
201 ad9680_core.no_of_channels = 2;
202 ad9680_core.resolution = 14;
203
204 // base addresses
205
206 #ifdef XILINX
207 ad9152_xcvr.base_address = XPAR_AXI_AD9152_XCVR_BASEADDR;
208 ad9152_core.base_address = XPAR_AXI_AD9152_CORE_BASEADDR;
209 ad9680_xcvr.base_address = XPAR_AXI_AD9680_XCVR_BASEADDR;
210 ad9680_core.base_address = XPAR_AXI_AD9680_CORE_BASEADDR;
211 ad9152_jesd.base_address = XPAR_AXI_AD9152_JESD_BASEADDR;
212 ad9680_jesd.base_address = XPAR_AXI_AD9680_JESD_BASEADDR;
213 #endif
214 #ifdef ALTERA
215 ad9152_xcvr.base_address = AXI_AD9152_XCVR_BASE;
216 ad9152_core.base_address = AXI_AD9152_CORE_BASE;
217 ad9680_xcvr.base_address = AXI_AD9680_XCVR_BASE;
218 ad9680_core.base_address = AXI_AD9680_CORE_BASE;
219 ad9152_jesd.base_address = AVL_AD9152_XCVR_IP_RECONFIG_BASE;
220 ad9680_jesd.base_address = AVL_AD9680_XCVR_IP_RECONFIG_BASE;
221 ad9152_xcvr.mmcm_lpll_base_address = AVL_AD9152_XCVR_CORE_PLL_RECONFIG_BASE;
222 ad9680_xcvr.mmcm_lpll_base_address = AVL_AD9680_XCVR_CORE_PLL_RECONFIG_BASE;
223 ad9152_xcvr.tx_lane_pll_base_address = AVL_AD9152_XCVR_LANE_PLL_RECONFIG_BASE;
224 #endif
225
226 // functions (do not modify below)
227
228 ad_platform_init();
229 ad_gpio_set(GPIO_DAC_TXEN, 0x1);
230 ad_gpio_set(GPIO_ADC_PD, 0x0);
231
232 ad9528_setup(&ad9528_spi_device, &ad9528_param);
233
234 ad9152_setup(&ad9152_spi_device, ad9152_param);
235 jesd_setup(ad9152_jesd);
236 xcvr_setup(ad9152_xcvr);
237 jesd_status(ad9152_jesd);
238 dac_setup(ad9152_core);
239 ad9152_status(&ad9152_spi_device);
240
241 // ad9152-x1 do not support data path prbs (use short-tpl)
242
243 ad9152_channels[0].sel = DAC_SRC_SED;
244 ad9152_channels[1].sel = DAC_SRC_SED;
245 dac_data_setup(ad9152_core);
246 ad9152_short_pattern_test(&ad9152_spi_device, ad9152_param);
247
248 // ad9152-xN (n > 1) supports data path prbs
249
250 ad9152_channels[0].sel = DAC_SRC_PN23;
251 ad9152_channels[1].sel = DAC_SRC_PN23;
252 dac_data_setup(ad9152_core);
253 ad9152_param.prbs_type = AD9152_TEST_PN7;
254 ad9152_datapath_prbs_test(&ad9152_spi_device, ad9152_param);
255
256 ad9152_channels[0].sel = DAC_SRC_PN31;
257 ad9152_channels[1].sel = DAC_SRC_PN31;
258 dac_data_setup(ad9152_core);
259 ad9152_param.prbs_type = AD9152_TEST_PN15;
260 ad9152_datapath_prbs_test(&ad9152_spi_device, ad9152_param);
261
262 ad9680_setup(&ad9680_spi_device, ad9680_param);
263 jesd_setup(ad9680_jesd);
264 xcvr_setup(ad9680_xcvr);
265 jesd_status(ad9680_jesd);
266 adc_setup(ad9680_core);
267 ad9680_test(&ad9680_spi_device, AD9680_TEST_PN9);
268 adc_pn_mon(ad9680_core, ADC_PN9);
269 ad9680_test(&ad9680_spi_device, AD9680_TEST_PN23);
270 adc_pn_mon(ad9680_core, ADC_PN23A);
271
272 // default data
273
274 ad9152_channels[0].sel = DAC_SRC_DDS;
275 ad9152_channels[1].sel = DAC_SRC_DDS;
276 dac_data_setup(ad9152_core);
277 ad9680_test(&ad9680_spi_device, AD9680_TEST_OFF);
278 ad_printf("daq3: done\n");
279 ad_platform_close();
280 return(0);
281 }