Skip to content

Commit 4101fd1

Browse files
committed
projects: adaq776x-1fmcz: Add project for ADAQ776x-1
Add initial project files for both basic and IIO examples for ADAQ776x-1 Signed-off-by: adiceline <[email protected]>
1 parent a8b538d commit 4101fd1

File tree

15 files changed

+836
-0
lines changed

15 files changed

+836
-0
lines changed

projects/adaq776x-1fmcz/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Select the example you want to enable by chossing y for enabling and n for disabling
2+
BASIC_EXAMPLE = n
3+
IIO_EXAMPLE = y
4+
5+
#select part number to use: adaq7767-1, adaq7768-1, adaq7769-1
6+
ADAQ776x_DEV = adaq7769-1
7+
8+
include ../../tools/scripts/generic_variables.mk
9+
10+
include src.mk
11+
12+
include ../../tools/scripts/generic.mk
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"xilinx": {
3+
"basic": {
4+
"flags": "BASIC_EXAMPLE=y IIO_EXAMPLE=n",
5+
"hardware": [
6+
"adaq77691_fmc_zed"
7+
]
8+
},
9+
"iio": {
10+
"flags": "BASIC_EXAMPLE=n IIO_EXAMPLE=y",
11+
"hardware": [
12+
"adaq77691_fmc_zed"
13+
]
14+
}
15+
}
16+
}

projects/adaq776x-1fmcz/src.mk

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
include $(PROJECT)/src/platform/$(PLATFORM)/platform_src.mk
2+
include $(PROJECT)/src/examples/examples_src.mk
3+
4+
5+
SRCS += $(PROJECT)/src/platform/$(PLATFORM)/main.c
6+
7+
INCS += $(PROJECT)/src/common/common_data.h
8+
SRCS += $(PROJECT)/src/common/common_data.c
9+
10+
INCS += $(PROJECT)/src/platform/platform_includes.h
11+
12+
INCS += $(PROJECT)/src/platform/$(PLATFORM)/parameters.h
13+
SRCS += $(PROJECT)/src/platform/$(PLATFORM)/parameters.c
14+
15+
SRCS += $(DRIVERS)/api/no_os_spi.c \
16+
$(DRIVERS)/adc/ad7768-1/ad77681.c \
17+
$(DRIVERS)/axi_core/axi_dmac/axi_dmac.c \
18+
$(DRIVERS)/axi_core/spi_engine/spi_engine.c \
19+
$(DRIVERS)/api/no_os_irq.c \
20+
$(DRIVERS)/api/no_os_uart.c \
21+
$(NO-OS)/util/no_os_util.c \
22+
$(NO-OS)/util/no_os_lf256fifo.c \
23+
$(NO-OS)/util/no_os_alloc.c \
24+
$(NO-OS)/util/no_os_fifo.c \
25+
$(NO-OS)/util/no_os_mutex.c
26+
27+
SRCS += $(PLATFORM_DRIVERS)/xilinx_axi_io.c \
28+
$(PLATFORM_DRIVERS)/xilinx_gpio.c \
29+
$(PLATFORM_DRIVERS)/xilinx_spi.c \
30+
$(PLATFORM_DRIVERS)/xilinx_delay.c
31+
32+
INCS += $(DRIVERS)/adc/ad7768-1/ad77681.h
33+
34+
INCS += $(DRIVERS)/axi_core/axi_dmac/axi_dmac.h \
35+
$(DRIVERS)/axi_core/spi_engine/spi_engine.h \
36+
$(DRIVERS)/axi_core/spi_engine/spi_engine_private.h
37+
38+
INCS += $(PLATFORM_DRIVERS)/$(PLATFORM)_spi.h \
39+
$(PLATFORM_DRIVERS)/$(PLATFORM)_irq.h \
40+
$(PLATFORM_DRIVERS)/$(PLATFORM)_uart.h \
41+
$(PLATFORM_DRIVERS)/$(PLATFORM)_gpio.h
42+
43+
INCS += $(INCLUDE)/no_os_axi_io.h \
44+
$(INCLUDE)/no_os_spi.h \
45+
$(INCLUDE)/no_os_gpio.h \
46+
$(INCLUDE)/no_os_error.h \
47+
$(INCLUDE)/no_os_delay.h \
48+
$(INCLUDE)/no_os_irq.h \
49+
$(INCLUDE)/no_os_uart.h \
50+
$(INCLUDE)/no_os_util.h \
51+
$(INCLUDE)/no_os_units.h \
52+
$(INCLUDE)/no_os_lf256fifo.h \
53+
$(INCLUDE)/no_os_fifo.h \
54+
$(INCLUDE)/no_os_alloc.h \
55+
$(INCLUDE)/no_os_mutex.h
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/***************************************************************************//**
2+
* @file common_data.c
3+
* @brief Defines common data to be used by adaq776x-1fmcz examples.
4+
* @author Celine Joy Capua ([email protected])
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
34+
#include <stdbool.h>
35+
#include "common_data.h"
36+
#include "spi_engine.h"
37+
#include "no_os_spi.h"
38+
#include "no_os_delay.h"
39+
#include "no_os_error.h"
40+
#ifdef IIO_SUPPORT
41+
#include "no_os_uart.h"
42+
#endif
43+
44+
#ifdef IIO_SUPPORT
45+
struct no_os_uart_init_param adaq776x1_uart_ip = {
46+
.device_id = UART_DEVICE_ID,
47+
.irq_id = UART_IRQ_ID,
48+
.asynchronous_rx = true,
49+
.baud_rate = UART_BAUDRATE,
50+
.size = NO_OS_UART_CS_8,
51+
.parity = NO_OS_UART_PAR_NO,
52+
.stop = NO_OS_UART_STOP_1_BIT,
53+
.extra = &platform_uart_param,
54+
.platform_ops = &xil_uart_ops,
55+
};
56+
#endif
57+
58+
struct ad77681_init_param adaq776x1_init_param = {
59+
.spi_eng_dev_init = {
60+
.chip_select = AD77681_SPI_CS,
61+
.max_speed_hz = 1000000,
62+
.mode = NO_OS_SPI_MODE_2,
63+
.platform_ops = &spi_eng_platform_ops,
64+
.extra = (void*)&spi_eng_init_param,
65+
},
66+
.power_mode = AD77681_FAST,
67+
.mclk_div = AD77681_MCLK_DIV_8,
68+
.conv_mode = AD77681_CONV_CONTINUOUS,
69+
.diag_mux_sel = AD77681_POSITIVE_FS,
70+
.conv_diag_sel = false,
71+
.conv_len = AD77681_CONV_24BIT,
72+
.crc_sel = AD77681_CRC,
73+
.status_bit = 0,
74+
.VCM_out = AD77681_VCM_HALF_VCC,
75+
.AINn = AD77681_AINn_ENABLED,
76+
.AINp = AD77681_AINp_ENABLED,
77+
.REFn = AD77681_BUFn_ENABLED,
78+
.REFp = AD77681_BUFp_ENABLED,
79+
.filter = AD77681_FIR,
80+
.decimate = AD77681_SINC5_FIR_DECx32,
81+
.sinc3_osr = 0,
82+
.vref = AD77681_VOLTAGE_REF,
83+
.mclk = AD77681_MCLK,
84+
.sample_rate = AD77681_DEFAULT_SAMPLING_FREQ,
85+
#if ADAQ77671_DEV
86+
.has_pga = false,
87+
.has_variable_aaf = true,
88+
.aaf_gain = AD7768_AAF_IN,
89+
#elif ADAQ77681_DEV
90+
.has_variable_aaf = false,
91+
.has_pga = true,
92+
.num_pga_modes = ARRAY_SIZE(adaq7768_gains),
93+
.default_pga_mode = AD7768_PGA_GAIN_2,
94+
.pgia_mode2pin_offset = 6,
95+
.pga_gains = adaq7768_gains,
96+
#elif ADAQ7769_DEV
97+
.has_variable_aaf = true,
98+
.has_pga = true,
99+
.num_pga_modes = ARRAY_SIZE(adaq7769_gains),
100+
.default_pga_mode = AD7769_PGA_GAIN_0,
101+
.pgia_mode2pin_offset = 0,
102+
.pga_gains = adaq7769_gains,
103+
.gain_mode = AD7768_PGA_GAIN_0,
104+
.aaf_gain = AD7768_AAF_IN3,
105+
#endif
106+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/***************************************************************************//**
2+
* @file common_data.h
3+
* @brief Defines common data to be used by adaq776x-1fmcz examples.
4+
* @author Celine Joy Capua ([email protected])
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
#ifndef __COMMON_DATA_H__
34+
#define __COMMON_DATA_H__
35+
36+
#include "platform_includes.h"
37+
#include "ad77681.h"
38+
39+
extern struct ad77681_init_param adaq776x1_init_param;
40+
extern struct no_os_uart_init_param adaq776x1_uart_ip;
41+
42+
#endif /* __COMMON_DATA_H__ */
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/***************************************************************************//**
2+
* @file basic_example.c
3+
* @brief Implementation of basic example for adaq776x-1fmcz project.
4+
* @author Celine Joy Capua ([email protected])
5+
********************************************************************************
6+
* Copyright 2025(c) Analog Devices, Inc.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Analog Devices, Inc. nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25+
* EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*******************************************************************************/
33+
34+
#include "basic_example.h"
35+
#include <stdio.h>
36+
#include <sleep.h>
37+
#include <stdbool.h>
38+
#include <stdint.h>
39+
#include <stdlib.h>
40+
#include "clk_axi_clkgen.h"
41+
#include "xil_printf.h"
42+
#include "xilinx_irq.h"
43+
#include "ad77681.h"
44+
#include "spi_engine.h"
45+
#include "common_data.h"
46+
#include "no_os_delay.h"
47+
#include "no_os_error.h"
48+
49+
#define SPI_ENGINE_OFFLOAD_EXAMPLE 0
50+
51+
int basic_example_main()
52+
{
53+
struct ad77681_dev *adc_dev;
54+
struct ad77681_status_registers *adc_status;
55+
struct axi_clkgen *clkgen;
56+
uint8_t adc_data[5];
57+
uint8_t *data;
58+
uint32_t i;
59+
uint32_t spi_msg_cmds[6] = {CS_LOW, CS_HIGH, CS_LOW, WRITE_READ(1), CS_HIGH};
60+
int32_t ret;
61+
uint32_t commands_data[4] = {0, 0, 0, AD77681_REG_READ(AD77681_REG_ADC_DATA)};
62+
struct spi_engine_offload_message spi_engine_offload_message;
63+
64+
Xil_ICacheEnable();
65+
Xil_DCacheEnable();
66+
67+
ret = axi_clkgen_init(&clkgen, &clkgen_init);
68+
if (ret != 0) {
69+
printf("error: axi_clkgen_init() failed\n");
70+
return -1;
71+
} else {
72+
printf("success: axi_clkgen_init() passed\n");
73+
}
74+
75+
ret = axi_clkgen_set_rate(clkgen, 80000000);
76+
if (ret != 0) {
77+
return -1;
78+
} else {
79+
printf("success: axi_clkgen_set_rate() passed\n");
80+
}
81+
82+
ad77681_setup(&adc_dev, adaq776x1_init_param, &adc_status);
83+
if (ret != 0) {
84+
printf("error: ad77681_setup() failed\n");
85+
return -1;
86+
} else {
87+
printf("success: ad77681_setup() passed\n");
88+
}
89+
90+
if (SPI_ENGINE_OFFLOAD_EXAMPLE == 0) {
91+
printf("Reading ADC data using SPI engine...\n");
92+
while (1) {
93+
printf("im in the loop\n");
94+
ad77681_spi_read_adc_data(adc_dev, adc_data,
95+
AD77681_REGISTER_DATA_READ);
96+
printf("[ADC DATA]: 0x");
97+
for (i = 0; i < sizeof(adc_data); i++) {
98+
printf("%x", adc_data[i]);
99+
}
100+
printf("\r\n");
101+
no_os_mdelay(1000);
102+
}
103+
} else {
104+
ret = spi_engine_offload_init(adc_dev->spi_desc,
105+
&spi_engine_offload_init_param);
106+
if (ret != 0)
107+
return -1;
108+
109+
spi_engine_offload_message.commands = spi_msg_cmds;
110+
spi_engine_offload_message.no_commands = NO_OS_ARRAY_SIZE(spi_msg_cmds);
111+
spi_engine_offload_message.commands_data = commands_data;
112+
spi_engine_offload_message.rx_addr = 0x800000;
113+
spi_engine_offload_message.tx_addr = 0xA000000;
114+
115+
ret = spi_engine_offload_transfer(adc_dev->spi_desc, spi_engine_offload_message,
116+
AD77681_EVB_SAMPLE_NO);
117+
if (ret != 0)
118+
return ret;
119+
120+
no_os_mdelay(1000);
121+
122+
Xil_DCacheInvalidateRange(spi_engine_offload_message.rx_addr,
123+
AD77681_EVB_SAMPLE_NO * 4);
124+
125+
for (i = 0; i < AD77681_EVB_SAMPLE_NO * 4 ; i++) {
126+
printf("%x\r\n", *data);
127+
data += sizeof(uint8_t);
128+
}
129+
}
130+
131+
printf("Bye\n");
132+
133+
Xil_DCacheDisable();
134+
Xil_ICacheDisable();
135+
136+
return 0;
137+
}

0 commit comments

Comments
 (0)