Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/AD9467-FMC-EBZ/main.c

raw symbols SCIP
1 /***************************************************************************//**
2 * @file Main.c
3 * @brief Implementation of the program's main function.
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
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdio.h>
46 #include "xil_cache.h"
47 #include "xparameters.h"
48 #include "cf_ad9467.h"
49 #include "AD9467.h"
50 #include "AD9517.h"
51
52 void xil_printf(const char *ctrl1, ...);
53
54 #ifdef _XPARAMETERS_PS_H_
55 #define SPI_DEVICE_ID XPAR_PS7_SPI_0_DEVICE_ID
56 #else
57 #define SPI_DEVICE_ID XPAR_SPI_0_DEVICE_ID
58 #endif
59
60 /***************************************************************************//**
61 * @brief Main function.
62 *
63 * @return 0.
64 *******************************************************************************/
65 int main(){
66
67 uint32_t mode;
68
69 Xil_ICacheEnable();
70 Xil_DCacheEnable();
71
72 /* AD9467 Setup. */
73 ad9467_setup(SPI_DEVICE_ID, 0);
74
75 /* AD9517 Setup. */
76 ad9517_setup(SPI_DEVICE_ID, 1); // Initialize device.
77 ad9517_power_mode(3, 0); // Set channel 3 for normal operation
78 ad9517_frequency(3, 250000000); // Set the channel 3 frequency to 250Mhz
79 ad9517_update(); // Update registers
80
81 /* Read the device ID for AD9467 and AD9517. */
82 xil_printf("\n\r********************************************************************\r\n");
83 xil_printf(" ADI AD9467-FMC-EBZ Reference Design\n\r");
84 xil_printf(" AD9467 CHIP ID: 0x%02x\n\r", ad9467_read(AD9467_REG_CHIP_ID));
85 xil_printf(" AD9467 CHIP GRADE: 0x%02x\n\r", ad9467_read(AD9467_REG_CHIP_GRADE));
86 xil_printf(" AD9517 CHIP ID: 0x%02x", ad9517_read(AD9517_REG_PART_ID));
87 xil_printf("\n\r********************************************************************\r\n");
88
89 /* AD9467 test. */
90 adc_setup(0);
91
92 for (mode = MIDSCALE; mode <= ONE_ZERO_TOGGLE; mode++) // Data pattern checks
93 {
94 adc_test(mode, OFFSET_BINARY); // Data format is offset binary
95 adc_test(mode, TWOS_COMPLEMENT); // Data format is twos complement
96 }
97 xil_printf("Testing done.\n\r");
98 /* AD9467 Setup for data acquisition */
99 ad9467_output_invert(0); // Output invert Off
100 ad9467_transfer(); // Synchronously update registers
101 ad9467_output_format(1); // Twos complement
102 ad9467_transfer(); // Synchronously update registers
103 ad9467_reset_PN9(0); // Clear PN9 bit
104 ad9467_transfer(); // Synchronously update registers
105 ad9467_reset_PN23(0); // Clear PN23 bit
106 ad9467_transfer(); // Synchronously update registers
107 ad9467_test_mode(0); // Test mode Off
108 ad9467_transfer(); // Synchronously update registers
109
110 xil_printf("Start capturing data...\n\r");
111
112 adc_capture(16384, DDR_BASEADDR);
113
114 xil_printf("Done.\n\r");
115
116 Xil_DCacheDisable();
117 Xil_ICacheDisable();
118
119 return 0;
120 }