Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/ad-fmcjesdadc1-ebz/ad_fmcjesdadc1_ebz.c

raw symbols SCIP
1 /***************************************************************************//**
2 * @file ad_fmcjesdadc1_ebz.c
3 * @brief Implementation of Main Function.
4 * @author DBogdan ([email protected])
5 ********************************************************************************
6 * Copyright 2014(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 #include <xil_cache.h>
44 #include <xil_io.h>
45 #include "xparameters.h"
46 #include "platform_drivers.h"
47 #include "ad9517.h"
48 #include "ad9250.h"
49 #include "adxcvr_core.h"
50 #include "adc_core.h"
51
52 /******************************************************************************/
53 /********************** Macros and Constants Definitions **********************/
54 /******************************************************************************/
55 #ifdef _XPARAMETERS_PS_H_
56 #define SPI_DEVICE_ID XPAR_PS7_SPI_0_DEVICE_ID
57 #define GPIO_DEVICE_ID XPAR_PS7_GPIO_0_DEVICE_ID
58 #define GPIO_TYPE PS7_GPIO
59 #define GPIO_SYSREF 54 + 32
60 #define ADC_DDR_BASEADDR XPAR_DDR_MEM_BASEADDR + 0x800000
61 #else
62 #define SPI_DEVICE_ID XPAR_SPI_0_DEVICE_ID
63 #define GPIO_DEVICE_ID 0 // FIXME
64 #define GPIO_TYPE AXI_GPIO
65 #define GPIO_SYSREF 0 // FIXME
66 #define ADC_DDR_BASEADDR XPAR_AXI_DDR_CNTRL_BASEADDR + 0x800000
67 #endif
68 #define AD9250_ADXCVR_BASEADDR XPAR_AXI_AD9250_XCVR_BASEADDR
69 #define AD9250_JESD_BASEADDR XPAR_AXI_AD9250_JESD_BASEADDR
70
71 ad9517_init_param default_ad9517_init_param = {
72 0, // spi_chip_select
73 SPI_MODE_0, // spi_mode
74 #ifdef _XPARAMETERS_PS_H_
75 PS7_SPI, // spi_type
76 #else
77 AXI_SPI, // spi_type
78 #endif
79 SPI_DEVICE_ID, // spi_device_id
80 };
81
82 ad9250_init_param default_ad9250_init_param = {
83 0, // spi_chip_select
84 SPI_MODE_0, // spi_mode
85 #ifdef _XPARAMETERS_PS_H_
86 PS7_SPI, // spi_type
87 #else
88 AXI_SPI, // spi_type
89 #endif
90 SPI_DEVICE_ID, // spi_device_id
91 0, // id_no
92 };
93
94 /***************************************************************************//**
95 * @brief main
96 *******************************************************************************/
97 int main(void)
98 {
99 ad9250_dev *ad9250_0_device;
100 ad9250_dev *ad9250_1_device;
101 ad9517_dev *ad9517_device;
102 adc_core ad9250_0_core;
103 adc_core ad9250_1_core;
104 jesd204_core ad9250_jesd204;
105 adxcvr_core ad9250_xcvr;
106
107 Xil_ICacheEnable();
108 Xil_DCacheEnable();
109
110 ad9517_setup(&ad9517_device, default_ad9517_init_param);
111
112 default_ad9250_init_param.id_no = 0;
113 ad9250_setup(&ad9250_0_device, default_ad9250_init_param);
114
115 default_ad9250_init_param.id_no = 1;
116 ad9250_setup(&ad9250_1_device, default_ad9250_init_param);
117
118 ad9250_jesd204.base_addr = AD9250_JESD_BASEADDR;
119 ad9250_jesd204.rx_tx_n = 1;
120 ad9250_jesd204.octets_per_frame = 1;
121 ad9250_jesd204.frames_per_multiframe = 32;
122 ad9250_jesd204.subclass_mode = 1;
123 ad9250_jesd204.sysref_type = INTERN;
124 ad9250_jesd204.gpio_device.device_id = GPIO_DEVICE_ID;
125 ad9250_jesd204.gpio_device.type = PS7_GPIO;
126 ad9250_jesd204.gpio_sysref = GPIO_SYSREF;
127
128 ad9250_xcvr.base_addr = AD9250_ADXCVR_BASEADDR;
129 ad9250_xcvr.tx_enable = 0;
130 ad9250_xcvr.gth_enable = 0;
131 ad9250_xcvr.lpm_enable = 0;
132 ad9250_xcvr.out_clk_sel = 2;
133 ad9250_xcvr.sys_clk_sel = 0;
134 ad9250_xcvr.init_set_rate_enable = 0;
135
136 jesd204_init(ad9250_jesd204);
137 adxcvr_init(ad9250_xcvr);
138
139 jesd204_gen_sysref(ad9250_jesd204);
140
141 jesd204_read_status(ad9250_jesd204);
142
143 ad9250_0_core.adc_baseaddr = XPAR_AXI_AD9250_0_CORE_BASEADDR;
144 ad9250_0_core.dmac_baseaddr = XPAR_AXI_AD9250_0_DMA_BASEADDR;
145 ad9250_0_core.no_of_channels = 2;
146 ad9250_0_core.resolution = 14;
147
148 ad9250_1_core.adc_baseaddr = XPAR_AXI_AD9250_1_CORE_BASEADDR;
149 ad9250_1_core.dmac_baseaddr = XPAR_AXI_AD9250_1_DMA_BASEADDR;
150 ad9250_1_core.no_of_channels = 2;
151 ad9250_1_core.resolution = 14;
152
153 adc_setup(ad9250_0_core);
154 adc_setup(ad9250_1_core);
155
156 ad9250_spi_write(ad9250_0_device, 0x0d, 0x0f);
157 ad9250_spi_write(ad9250_0_device, 0xff, 0x01);
158
159 ad9250_spi_write(ad9250_1_device, 0x0d, 0x0f);
160 ad9250_spi_write(ad9250_1_device, 0xff, 0x01);
161
162 adc_capture(ad9250_0_core, 32768, ADC_DDR_BASEADDR);
163 adc_capture(ad9250_1_core, 32768, ADC_DDR_BASEADDR + 0x20000);
164
165 xil_printf("Ramp capture done.\n");
166
167 Xil_DCacheDisable();
168 Xil_ICacheDisable();
169
170 xil_printf("Done.\n");
171
172 return 0;
173 }