|
| 1 | +/***************************************************************************//** |
| 2 | + * @file common_data.c |
| 3 | + * @brief Defines common data to be used by adaq776x-1fmcz examples. |
| 4 | + * @author Celine Joy Capua (celinejoy.capua@analog.com) |
| 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 | +}; |
0 commit comments