Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/AD6673-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_ad6673.h"
48 #include "AD6673.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 /* AD6673 Setup. */
71 ad6673_setup(SPI_BASEADDR, 1);
72
73 /* Read the device ID and Speed grade of AD6673. */
74 xil_printf("\n\r********************************************************************\r\n");
75 xil_printf(" ADI AD6673-250EBZ Reference Design\n\r");
76 xil_printf(" AD6673 CHIP ID: 0x%02x\n\r", ad6673_read(AD6673_REG_CHIP_ID));
77 xil_printf(" AD6673 SPEED GRADE: 0x%02x", ad6673_read(AD6673_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 if((mode != PN_23_SEQUENCE) && (mode !=PN_9_SEQUENCE)) // skip PN23 and PN9 test modes
83 {
84 adc_test(mode, OFFSET_BINARY); // Data format is offset binary
85 adc_test(mode, TWOS_COMPLEMENT); // Data format is twos complement
86 }
87 }
88
89 xil_printf("Testing done.\n\r");
90
91 /* AD6673 Setup for data acquisition. */
92 ad6673_output_format(OFFSET_BINARY); // Offset binary
93 ad6673_output_invert(0); // Output invert Off
94 ad6673_output_disable(0); // Output disable Off
95 ad6673_test_mode(TEST_DISABLE); // Test mode Off
96 ad6673_transfer(); // Synchronously update registers
97
98 xil_printf("Start capturing data...\n\r");
99
100 while(1)
101 {
102 adc_capture(1024, DDR_BASEADDR);
103 }
104
105 Xil_DCacheDisable();
106 Xil_ICacheDisable();
107
108 return 0;
109 }