Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/ad-fmcadc2-ebz/ad_fmcadc2_ebz.c

raw symbols SCIP
1 /***************************************************************************//**
2 * @file ad_fmcadc2_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 <xparameters.h>
44 #include <xil_cache.h>
45 #include <xil_io.h>
46 #include "platform_drivers.h"
47 #include "ad9625.h"
48 #include "adc_core.h"
49 #include "adxcvr_core.h"
50
51 #ifdef _XPARAMETERS_PS_H_
52 #define SPI_DEVICE_ID XPAR_PS7_SPI_0_DEVICE_ID
53 #define GPIO_DEVICE_ID XPAR_PS7_GPIO_0_DEVICE_ID
54 #define GPIO_TYPE PS7_GPIO
55 #define GPIO_JESD204_SYSREF 54 + 34
56 #define ADC_DDR_BASEADDR XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x800000
57 #else
58 #define SPI_DEVICE_ID XPAR_SPI_0_DEVICE_ID
59 #define ADC_DDR_BASEADDR XPAR_AXI_DDR_CNTRL_BASEADDR + 0x800000
60 #endif
61 #define AD9625_CORE_BASEADDR XPAR_AXI_AD9625_CORE_BASEADDR
62 #define AD9625_DMA_BASEADDR XPAR_AXI_AD9625_DMA_BASEADDR
63 #define AD9625_JESD_BASEADDR XPAR_AXI_AD9625_JESD_BASEADDR
64 #define AD9625_ADXCVR_BASEADDR XPAR_AXI_AD9625_XCVR_BASEADDR
65
66 ad9625_init_param default_ad9625_init_param = {
67 0, // spi_chip_select
68 SPI_MODE_3, // spi_mode
69 #ifdef _XPARAMETERS_PS_H_
70 PS7_SPI, // spi_type
71 #else
72 AXI_SPI, // spi_type
73 #endif
74 SPI_DEVICE_ID, // spi_device_id;
75 };
76
77 int main(void)
78 {
79 adc_core ad9625_core;
80 ad9625_dev *ad9625_device;
81 jesd204_core ad9625_jesd204;
82 adxcvr_core ad9625_xcvr;
83
84 Xil_ICacheEnable();
85 Xil_DCacheEnable();
86
87 ad9625_setup(&ad9625_device, default_ad9625_init_param);
88
89 ad9625_jesd204.base_addr = AD9625_JESD_BASEADDR;
90 ad9625_jesd204.rx_tx_n = 1;
91 ad9625_jesd204.octets_per_frame = 1;
92 ad9625_jesd204.frames_per_multiframe = 32;
93 ad9625_jesd204.subclass_mode = 1;
94 ad9625_jesd204.sys_ref = INTERN;
95 ad9625_jesd204.gpio_device.device_id = GPIO_DEVICE_ID;
96 ad9625_jesd204.gpio_device.type = GPIO_TYPE;
97 ad9625_jesd204.gpio_sysref = GPIO_JESD204_SYSREF;
98
99 ad9625_xcvr.base_addr = AD9625_ADXCVR_BASEADDR;
100 ad9625_xcvr.tx_enable = 0;
101 ad9625_xcvr.gth_enable = 0;
102 ad9625_xcvr.lpm_enable = 1;
103 ad9625_xcvr.out_clk_sel = 2;
104 ad9625_xcvr.sys_clk_sel = 0;
105
106 ad9625_xcvr.lane_rate_khz = 6250000;
107 ad9625_xcvr.ref_rate_khz = 625000;
108
109 ad9625_spi_write(ad9625_device, AD9625_REG_TEST_CNTRL, 0x0F);
110 ad9625_spi_write(ad9625_device, AD9625_REG_OUTPUT_MODE, 0x01);
111 ad9625_spi_write(ad9625_device, AD9625_REG_TRANSFER, 0x01);
112
113 ad9625_core.adc_baseaddr = AD9625_CORE_BASEADDR;
114 ad9625_core.dmac_baseaddr = AD9625_DMA_BASEADDR;
115 ad9625_core.no_of_channels = 1;
116 ad9625_core.resolution = 12;
117
118 jesd204_init(ad9625_jesd204);
119 adxcvr_init(ad9625_xcvr);
120 jesd204_gen_sysref(ad9625_jesd204);
121 adc_setup(ad9625_core);
122
123 // check JESD link status
124 jesd204_read_status(ad9625_jesd204);
125
126 xil_printf("Start capturing data...\n\r");
127
128 adc_capture(ad9625_core, 16384, ADC_DDR_BASEADDR);
129
130 xil_printf("Done.\n\r");
131
132 Xil_DCacheDisable();
133 Xil_ICacheDisable();
134
135 return 0;
136 }