Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/AD9250-EBZ/main.c

raw symbols SCIP
1 /***************************************************************************//**
2 * @file Main.c
3 * @brief Implementation of the program's main function.
4 ********************************************************************************
5 * Copyright 2013(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 "cf_ad9250.h"
48 #include "AD9250.h"
49
50 void xil_printf(const char *ctrl1, ...);
51
52 /***************************************************************************//**
53 * @brief Main function.
54 *
55 * @return 0.
56 *******************************************************************************/
57 int main(void)
58 {
59 uint32_t mode;
60
61 Xil_ICacheEnable();
62 Xil_DCacheEnable();
63
64 /* Initialize JESD FPGA core. */
65 jesd_core_setup();
66
67 /* Initialize DMA core. */
68 dma_core_setup();
69
70 /* AD9250 Setup. */
71 ad9250_setup(SPI_BASEADDR, 1);
72
73 /* Read the device ID and Speed grade of AD9250. */
74 xil_printf("\n\r********************************************************************\r\n");
75 xil_printf(" ADI AD9250-250EBZ Reference Design\n\r");
76 xil_printf(" AD9250 CHIP ID: 0x%02x\n\r", ad9250_read(AD9250_REG_CHIP_ID));
77 xil_printf(" AD9250 SPEED GRADE: 0x%02x", ad9250_read(AD9250_REG_CHIP_INFO));
78 xil_printf("\n\r********************************************************************\r\n");
79
80 for (mode = MIDSCALE; mode <= ONE_ZERO_TOGGLE; mode++) // Data pattern checks
81 {
82 adc_test(mode, OFFSET_BINARY); // Data format is offset binary
83 adc_test(mode, TWOS_COMPLEMENT); // Data format is twos complement
84 }
85
86 xil_printf("Testing done.\n\r");
87
88 /* AD9250 Setup for data acquisition. */
89 ad9250_output_format(OFFSET_BINARY); // Offset binary
90 ad9250_output_invert(0); // Output invert Off
91 ad9250_output_disable(0); // Output disable Off
92 ad9250_test_mode(TEST_DISABLE); // Test mode Off
93 ad9250_transfer(); // Synchronously update register
94
95 xil_printf("Start capturing data...\n\r");
96
97 while(1)
98 {
99 adc_capture(1024, DDR_BASEADDR);
100 }
101
102 Xil_DCacheDisable();
103 Xil_ICacheDisable();
104
105 return 0;
106 }