Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/AD9250-EBZ/cf_ad9250.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file cf_ad9250.h
3 * @brief Header file of cf_ad9250 Driver.
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 #ifndef __CF_AD9250_H__
42 #define __CF_AD9250_H__
43
44 /******************************************************************************/
45 /***************************** Include Files **********************************/
46 /******************************************************************************/
47 #include <stdint.h>
48 #include "xparameters.h"
49
50 /******************************************************************************/
51 /******************* Macros and Constants Definitions *************************/
52 /******************************************************************************/
53 #ifdef _XPARAMETERS_PS_H_
54 #define CF_BASEADDR XPAR_AXI_AD9250_0_BASEADDR
55 #define JESD_BASEADDR XPAR_AXI_JESD204B_RX2_0_BASEADDR
56 #define DDR_BASEADDR XPAR_DDR_MEM_BASEADDR + 128*1024*1024
57 #define DMA_BASEADDR XPAR_AXI_DMA_0_BASEADDR
58 #define UART_BASEADDR XPS_UART1_BASEADDR
59 #define SPI_BASEADDR XPAR_AXI_SPI_0_BASEADDR
60 #define LCD_BASEADDR XPAR_AXI_GPIO_0_BASEADDR
61 #else
62 #define CF_BASEADDR XPAR_AXI_AD9250_0_BASEADDR
63 #define JESD_BASEADDR XPAR_AXI_JESD204B_RX2_0_BASEADDR
64 #define DDR_BASEADDR XPAR_DDR3_SDRAM_S_AXI_BASEADDR
65 #define DMA_BASEADDR XPAR_AXI_DMA_0_BASEADDR
66 #define UART_BASEADDR XPAR_RS232_UART_1_BASEADDR
67 #define SPI_BASEADDR XPAR_AXI_SPI_0_BASEADDR
68 #define LCD_BASEADDR XPAR_AXI_GPIO_0_BASEADDR
69 #endif
70
71 #ifdef _XPARAMETERS_PS_H_
72 #define CYCLES_FOR_1_MS 100000
73 #else
74 #define CYCLES_FOR_1_MS 800000
75 #endif
76
77 /* CF register map. */
78 #define CF_REG_VERSION 0x00
79 #define CF_REG_CAPTURE_CTRL 0x0C
80 #define CF_REG_ADC_STATUS 0x10
81 #define CF_REG_DATA_MONITOR 0x14
82 #define CF_REG_PN_TYPE 0x24
83 #define CF_REG_DATA_SELECT 0x28
84
85 /***************************************************************************//**
86 * This register controls the capture of ADC data. A 0 to 1 transition in the
87 * capture bit starts the capture. The capture count is the number of quad words
88 * minus one. To capture 16 quad words (64bit), sw must write 0x0_0000 followed
89 * by 0x1_000f.
90 *******************************************************************************/
91 /* CF_REG_CAPTURE_CTRL bit definition. */
92 #define CF_CAPTURE_CTRL_CAPTURE_START(x) (((x) & 0x1) << 16)
93 #define CF_CAPTURE_CTRL_CAPTURE_COUNT(x) ((((x) - 1) & 0xFFFF) << 0)
94
95 /***************************************************************************//**
96 * This register indicates the status of an ADC data capture. Software must clear
97 * all the bits before starting a data capture.
98 *******************************************************************************/
99 /* CF_REG_ADC_STATUS bit definition. */
100 #define CF_ADC_STATUS_UNDERFLOW (1 << 2) // (Write 1 to clear)
101 #define CF_ADC_STATUS_OVERFLOW (1 << 1) // (Write 1 to clear)
102 #define CF_ADC_STATUS_BUSY (1 << 0) // (Read Only)
103
104 /***************************************************************************//**
105 * This register indicates the status of ADC data monitoring (regardless of data
106 * capture). These bits are set whenever a corresponding error is detected.
107 * Software must clear these bits and read them back to monitor the status.
108 *******************************************************************************/
109 /* CF_REG_DATA_MONITOR bit definition. */
110 #define CF_DATA_MONITOR_PN_ERR (1 << 2) // (Write 1 to clear)
111 #define CF_DATA_MONITOR_PN_OUT_OF_SYNC (1 << 1) // (Write 1 to clear)
112 #define CF_DATA_MONITOR_OVER_RNG (1 << 0) // (Write 1 to clear)
113
114 /***************************************************************************//**
115 * This register selects the pseudo-random sequence used by the PN Monitor.
116 * PN9 sequence is used when bit 0 is cleared.
117 * PN23 sequence is used when bit 0 is set.
118 *******************************************************************************/
119 /* CF_REG_PN_TYPE bit definition. */
120 #define CF_PN_TYPE_BIT(x) (((x) & 0x1) << 0) // PN9(0) or PN23(1)
121
122 /***************************************************************************//**
123 * This register controls the data select from DDR. The incoming data word's
124 * bytes are assumed to be rising edge first. That is first byte appears on the
125 * rising edge followed by second byte on the falling edge.
126 *******************************************************************************/
127 /* CF_REG_DATA_SELECT bit definition. */
128 #define CF_DATA_SELECT_BIT(x) (((x) & 0x1) << 0) // Rising (0) or
129 // Falling (1) edge first
130 /* JESD register map */
131 #define JESD_REG_VERSION 0x00
132 #define JESD_REG_LANE_CTRL 0x04
133 #define JESD_REG_SYSREF 0x08
134 #define JESD_REG_FRAMES 0x0C
135 #define JESD_REG_DELAY 0x10
136 #define JESD_REG_TEST 0x14
137 #define JESD_REG_BUFCNT 0x18
138 #define JESD_REG_INIT_DATA0 0x1c
139 #define JESD_REG_INIT_DATA1 0x20
140 #define JESD_REG_INIT_DATA2 0x24
141 #define JESD_REG_INIT_DATA3 0x28
142 #define JESD_REG_TEST_MFCNT 0x2c
143 #define JESD_REG_TEST_ILACNT 0x30
144 #define JESD_REG_TEST_ERRCNT 0x34
145
146 /* JESD_REG_LANE_CTRL bit definition. */
147 #define JESD_LANE_CTRL_SYSREF_SEL(x) (((x) & 0x1) << 4) // Select sw(0x1) or hw(0x0) sysref generation
148 #define JESD_LANE_CTRL_LANE_SYNC_EN(x) (((x) & 0x1) << 3) // Enable (0x1) lane synchronization
149 #define JESD_LANE_CTRL_SCR_EN(x) (((x) & 0x1) << 2) // Enable (0x1) scrambling
150 #define JESD_LANE_CTRL_SYSREF_EN(x) (((x) & 0x1) << 1) // Enable (0x1) re-alignment at every sysref pulses
151 #define JESD_LANE_CTRL_ERR_DISB(x) (((x) & 0x1) << 0) // Disable (0x1) error reporting via sync
152
153 /* JESD_REG_SYSREF bit definition. */
154 #define JESD_SYSREF_INT(x) (((x) & 0x1) << 0) // Software controlled sysref (0->1 transition)
155
156 /* JESD_REG_FRAMES bit definition. */
157 #define JESD_FRAMES_FRM_CNT(x) ((((x) - 1) & 0x1F) << 8) // Number of frames per multi-frame
158 #define JESD_FRAMES_BYTE_CNT(x) ((((x) - 1) & 0xFF) << 0) // Number of bytes (octets) per frame
159
160 /* JESD_REG_DELAY bit definition. */
161 #define JESD_DELAY_BUFF_DELAY(x) (((x) & 0x1FFF) << 0) // Buffer delay from multi-frame
162
163 /* JESD_REG_TEST bit definition. */
164 #define JESD_TEST_MODE(x) (((x) & 0x3) << 2) // Test mode (?)
165 #define JESD_TEST_LANE_SEL(x) (((x) & 0x3) << 0) // Select lanes (0, 1, 2 or 3) for reporting
166
167 /* The following registers are based on lane_sel
168
169 JESD_REG_BUFCNT - Buffer count (latency)
170 JESD_REG_INIT_DATA0 - ILS Data 1
171 JESD_REG_INIT_DATA1 - ILS Data 1
172 JESD_REG_INIT_DATA2 - ILS Data 2
173 JESD_REG_INIT_DATA3 - ILS Data 3
174 JESD_REG_TEST_MFCNT - Test MF count (?)
175 JESD_REG_TEST_ILACNT - Test ILA count (?)
176 JESD_REG_TEST_ERRCNT - Test ERROR count (?)
177 */
178
179 /******************************************************************************/
180 /************************** Types Declarations ********************************/
181 /******************************************************************************/
182 typedef enum _TestModes
183 {
184 TEST_DISABLE = 0,
185 MIDSCALE,
186 POS_FULLSCALE,
187 NEG_FULLSCALE,
188 CHECKERBOARD,
189 PN_23_SEQUENCE,
190 PN_9_SEQUENCE,
191 ONE_ZERO_TOGGLE
192
193 }typeTestModes;
194
195 typedef enum _OutputModes
196 {
197 OFFSET_BINARY = 0,
198 TWOS_COMPLEMENT
199
200 }typeOutputModes;
201
202 /*******************************************************************************/
203 /************************ Functions Declarations *******************************/
204 /*******************************************************************************/
205
206 /*! Initializes JESD FPGA core. */
207 void jesd_core_setup(void);
208
209 /*! Initializes DMA core. */
210 void dma_core_setup(void);
211
212 /*! Captures a specified number of samples from the ADC. */
213 void adc_capture(uint32_t size, uint32_t address);
214
215 /*! Configures the AD9250 device to run in the selected test mode. */
216 void adc_test(uint32_t mode, uint32_t format);
217
218 #endif /* __CF_AD9250_H__ */