From c33b5546777bc348d46d808a6c6408586bac4bd0 Mon Sep 17 00:00:00 2001 From: Janani Sunil Date: Mon, 3 Feb 2025 08:30:18 +0100 Subject: [PATCH] projects:ad4170_iio: Add support to AD4190 Add support to AD4190, update documentation and copyright Corrected the virtual com port parameters and configured VCOM as default Add runtime detection of connected device with the EEPROM contents Added macros/APIs for configuring the sampling rate/FS values Signed-off-by: Janani Sunil --- .../source/projects/ad4170_iio/ad4170_iio.rst | 1 + projects/ad4170_iio/.gitignore | 2 + projects/ad4170_iio/STM32/sdp_k1/.extSettings | 2 +- .../ad4170_iio/STM32/sdp_k1/ad4170_iio.ioc | 5 +- .../app/ad4170_accelerometer_config.c | 10 +- projects/ad4170_iio/app/ad4170_iio.c | 107 ++++++++++++++++-- .../ad4170_iio/app/ad4170_loadcell_config.c | 10 +- .../ad4170_iio/app/ad4170_loadcell_config.h | 5 +- projects/ad4170_iio/app/ad4170_regs.h | 2 +- projects/ad4170_iio/app/ad4170_rtd_config.c | 10 +- .../ad4170_iio/app/ad4170_thermistor_config.c | 10 +- .../app/ad4170_thermocouple_config.c | 10 +- projects/ad4170_iio/app/ad4170_user_config.c | 10 +- projects/ad4170_iio/app/ad4170_user_config.h | 2 +- projects/ad4170_iio/app/app_config.c | 5 +- projects/ad4170_iio/app/app_config.h | 15 ++- projects/ad4170_iio/app/app_config_mbed.h | 5 +- projects/ad4170_iio/app/app_config_stm32.h | 33 ++++-- 18 files changed, 205 insertions(+), 39 deletions(-) diff --git a/doc/sphinx/source/projects/ad4170_iio/ad4170_iio.rst b/doc/sphinx/source/projects/ad4170_iio/ad4170_iio.rst index 9f6744ce2..65492da1b 100644 --- a/doc/sphinx/source/projects/ad4170_iio/ad4170_iio.rst +++ b/doc/sphinx/source/projects/ad4170_iio/ad4170_iio.rst @@ -8,6 +8,7 @@ Supported Hardware **Supported Devices:** * `AD4170 `_ +* `AD4190 `_ **Supported Carrier Boards:** diff --git a/projects/ad4170_iio/.gitignore b/projects/ad4170_iio/.gitignore index fd415d6b9..963d5b801 100644 --- a/projects/ad4170_iio/.gitignore +++ b/projects/ad4170_iio/.gitignore @@ -29,6 +29,8 @@ STM32/sdp_k1/.mxproject STM32/sdp_k1/ad4170_iio Debug.launch STM32/sdp_k1/STM32F469NIHX_FLASH.ld STM32/sdp_k1/STM32F469NIHX_RAM.ld +STM32/sdp_k1/Middlewares +STM32/sdp_k1/USB_DEVICE scripts/__pycache__ tests/.pytest_cache tests/__pycache__ diff --git a/projects/ad4170_iio/STM32/sdp_k1/.extSettings b/projects/ad4170_iio/STM32/sdp_k1/.extSettings index e207eba9b..6fd1f9daa 100644 --- a/projects/ad4170_iio/STM32/sdp_k1/.extSettings +++ b/projects/ad4170_iio/STM32/sdp_k1/.extSettings @@ -25,4 +25,4 @@ app/libraries/no-OS/iio/=../../../../libraries/no-OS/iio/iio.c;../../../../libra app/libraries/no-OS/drivers/api/=../../../../libraries/no-OS/drivers/api/no_os_gpio.c;../../../../libraries/no-OS/drivers/api/no_os_spi.c;../../../../libraries/no-OS/drivers/api/no_os_irq.c;../../../../libraries/no-OS/drivers/api/no_os_i2c.c;../../../../libraries/no-OS/drivers/api/no_os_eeprom.c;../../../../libraries/no-OS/drivers/api/no_os_uart.c;../../../../libraries/no-OS/drivers/api/no_os_tdm.c;../../../../libraries/no-OS/drivers/api/no_os_pwm.c;../../../../libraries/no-OS/drivers/api/no_os_dma.c; [Others] -Define=_USE_STD_INT_TYPES;TINYIIOD_VERSION_MAJOR;TINYIIOD_VERSION_MINOR;TINYIIOD_VERSION_GIT;IIOD_BUFFER_SIZE;IIO_IGNORE_BUFF_OVERRUN_ERR;USE_PHY_COM_PORT;NO_OS_VERSION;TARGET_SDP_K1 \ No newline at end of file +Define=_USE_STD_INT_TYPES;TINYIIOD_VERSION_MAJOR;TINYIIOD_VERSION_MINOR;TINYIIOD_VERSION_GIT;IIOD_BUFFER_SIZE;IIO_IGNORE_BUFF_OVERRUN_ERR;NO_OS_VERSION;TARGET_SDP_K1 \ No newline at end of file diff --git a/projects/ad4170_iio/STM32/sdp_k1/ad4170_iio.ioc b/projects/ad4170_iio/STM32/sdp_k1/ad4170_iio.ioc index e306d1863..28a5da880 100644 --- a/projects/ad4170_iio/STM32/sdp_k1/ad4170_iio.ioc +++ b/projects/ad4170_iio/STM32/sdp_k1/ad4170_iio.ioc @@ -522,7 +522,10 @@ TIM8.TIM_MasterSlaveMode=TIM_MASTERSLAVEMODE_ENABLE UART5.IPParameters=VirtualMode UART5.VirtualMode=Asynchronous USB_DEVICE.CLASS_NAME_HS=CDC -USB_DEVICE.IPParameters=VirtualMode-CDC_HS,VirtualModeHS,CLASS_NAME_HS +USB_DEVICE.IPParameters=VirtualMode-CDC_HS,VirtualModeHS,CLASS_NAME_HS,PRODUCT_STRING_CDC_HS,VID-CDC_HS,PID_CDC_HS +USB_DEVICE.PID_CDC_HS=0xB66C +USB_DEVICE.PRODUCT_STRING_CDC_HS=STM32_Virtual_Com_Port +USB_DEVICE.VID-CDC_HS=0x456 USB_DEVICE.VirtualMode-CDC_HS=Cdc USB_DEVICE.VirtualModeHS=Cdc_HS USB_OTG_HS.IPParameters=VirtualMode-Device_HS diff --git a/projects/ad4170_iio/app/ad4170_accelerometer_config.c b/projects/ad4170_iio/app/ad4170_accelerometer_config.c index 8ba149e12..684fb7aa0 100644 --- a/projects/ad4170_iio/app/ad4170_accelerometer_config.c +++ b/projects/ad4170_iio/app/ad4170_accelerometer_config.c @@ -2,7 +2,7 @@ * @file ad4170_accelerometer_config.c * @brief Accelerometer user configurations module for AD4170 IIO firmware ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -56,7 +56,11 @@ struct ad4170_init_param ad4170_accelerometer_config_params = { .pin_muxing = { .chan_to_gpio = AD4170_CHANNEL_NOT_TO_GPIO, #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) +#if defined(DEV_AD4190) + .dig_aux2_ctrl = AD4170_DIG_AUX2_SYNC, // Used as START Input. +#else .dig_aux2_ctrl = AD4170_DIG_AUX2_LDAC, // Used as h/w LDACB +#endif // DEV_AD4190 .dig_aux1_ctrl = AD4170_DIG_AUX1_RDY, // Used as RDY (end of conversion) #elif (INTERFACE_MODE == TDM_MODE) .dig_aux1_ctrl = AD4170_DIG_AUX1_DISABLED, @@ -105,6 +109,8 @@ struct ad4170_init_param ad4170_accelerometer_config_params = { /* Setup configurations */ .setups = { { + /* NOTE: chop_adc = AD4170_CHOP_IEXC_CD and AD4170_CHOP_IEXC_ABCD options + * are not available on the AD4190 */ .misc = { .chop_iexc = AD4170_CHOP_IEXC_OFF, .chop_adc = AD4170_CHOP_OFF, @@ -137,6 +143,7 @@ struct ad4170_init_param ad4170_accelerometer_config_params = { { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA }, { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA } }, +#if !defined(DEV_AD4190) .fir_control = { .fir_mode = AD4170_FIR_DEFAULT, .coeff_set = AD4170_FIR_COEFF_SET0, @@ -149,6 +156,7 @@ struct ad4170_init_param ad4170_accelerometer_config_params = { .hw_toggle = false, .hw_ldac = false } +#endif }, &gpio_init_sync_inb, diff --git a/projects/ad4170_iio/app/ad4170_iio.c b/projects/ad4170_iio/app/ad4170_iio.c index add98eff6..13722902e 100644 --- a/projects/ad4170_iio/app/ad4170_iio.c +++ b/projects/ad4170_iio/app/ad4170_iio.c @@ -3,7 +3,7 @@ * @brief Implementation of AD4170 IIO application interfaces * @details This module acts as an interface for AD4170 IIO application ******************************************************************************** - * Copyright (c) 2021-24 Analog Devices, Inc. + * Copyright (c) 2021-2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -429,6 +429,25 @@ struct ad4170_cached_reg reg_values[N_REGISTERS_CACHED]; /* Register index */ uint8_t read_reg_id = 0; +/* Permissible HW Mezzanine names */ +static const char *mezzanine_names[] = { + "EVAL-AD4170-4ARDZ", + "", + "", + "EVAL-AD4190-4ARDZ" +}; + +/* Active device available options */ +static const char* active_dev[] = { + "ad4170", + "", + "", + "ad4190", +}; + +/* Effective sampling rate of the device */ +static uint32_t sampling_rate = AD4170_MAX_SAMPLING_RATE; + /******************************************************************************/ /************************ Functions Prototypes ********************************/ /******************************************************************************/ @@ -514,7 +533,7 @@ static int get_sampling_frequency(void *device, * indicate an actual sampling rate of device. * Refer the 'note' in function description above for timeout calculations */ return sprintf(buf, "%d", - (AD4170_DEFLT_SAMPLING_FREQUENCY / num_of_channels)); + (sampling_rate / num_of_channels)); } static int set_sampling_frequency(void *device, @@ -544,7 +563,7 @@ static int get_adc_raw(void *device, intptr_t id) { int32_t ret; - static int32_t adc_data_raw = 0; + static uint32_t adc_data_raw = 0; int32_t offset = 0; uint8_t setup = p_ad4170_dev_inst->config.setup[channel->ch_num].setup_n; bool bipolar = p_ad4170_dev_inst->config.setups[setup].afe.bipolar; @@ -1505,6 +1524,13 @@ int32_t debug_reg_read(void *dev, uint32_t reg, uint32_t *readval) reg_base_add = debug_reg_search(reg, ®_addr_offset); + if (p_ad4170_dev_inst->id == ID_AD4190) { + if ((reg_base_add >= AD4170_REG_FIR_CONTROL) + && (reg_base_add <= AD4170_REG_DAC_INPUTB(0))) { + return -EINVAL; + } + } + /* Read data from device register */ ret = ad4170_spi_reg_read(dev, reg_base_add, readval); if (ret) { @@ -1537,6 +1563,13 @@ int32_t debug_reg_write(void *dev, uint32_t reg, uint32_t writeval) reg_base_add = debug_reg_search(reg, ®_addr_offset); + if (p_ad4170_dev_inst->id == ID_AD4190) { + if ((reg_base_add >= AD4170_REG_FIR_CONTROL) + && (reg_base_add <= AD4170_REG_DAC_INPUTB(0))) { + return -EINVAL; + } + } + /* Read the register contents */ ret = ad4170_spi_reg_read(dev, reg_base_add, &data); if (ret) { @@ -2852,6 +2885,45 @@ void ticker_callback(void *ctx) } } +/** + * @brief Configure filter parameters according to active device chosen + * @param None + * @return none + */ +void ad4170_configure_filter_params(void) +{ + uint16_t filter_fs; + uint8_t setup_id; + enum ad4170_filter_type filter_type; + + if (ad4170_init_params.id == ID_AD4170) { +#if (INTERFACE_MODE == SPI_INTERRUPT_MODE) + filter_fs = FS_SINC5_AVG_24_KSPS; + filter_type = AD4170_FILT_SINC5_AVG; +#else // TDM_MODE and SPI_DMA_MODE + filter_fs = FS_SINC5_512_KSPS; + filter_type = AD4170_FILT_SINC5; +#endif + } else if (ad4170_init_params.id == ID_AD4190) { +#if (INTERFACE_MODE == SPI_INTERRUPT_MODE) + filter_fs = FS_SINC5_AVG_24_KSPS; + filter_fs = AD4170_FILT_SINC5_AVG; +#else // TDM_MODE and SPI_DMA Mode + filter_fs = FS_SINC3_62P5_KSPS; + filter_type = AD4170_FILT_SINC3; +#endif + } + + /* Update the setup register with the filter and FS value */ + for (setup_id = 0; setup_id < AD4170_NUM_SETUPS; setup_id++) { + ad4170_init_params.config.setups[setup_id].filter.filter_type = filter_type; + ad4170_init_params.config.setups[setup_id].filter_fs = filter_fs; + } + + /* Calculate the effective sampling rate of the device */ + sampling_rate = (AD4170_INTERNAL_CLOCK / (FILTER_SCALE * filter_fs)); +} + /** * @brief Initialize the IIO interface for AD4170 IIO device * @return none @@ -2860,6 +2932,7 @@ void ticker_callback(void *ctx) int32_t ad4170_iio_initialize(void) { int32_t init_status; + uint8_t read_id; /* Init the system peripherals */ init_status = init_system(); @@ -2868,16 +2941,26 @@ int32_t ad4170_iio_initialize(void) } /* Read context attributes */ - init_status = get_iio_context_attributes(&iio_init_params.ctx_attrs, - &iio_init_params.nb_ctx_attr, - eeprom_desc, - HW_MEZZANINE_NAME, - STR(HW_CARRIER_NAME), - &hw_mezzanine_is_valid); - if (init_status) { - return init_status; + for (read_id = 0; read_id < NO_OS_ARRAY_SIZE(mezzanine_names); read_id++) { + init_status = get_iio_context_attributes(&iio_init_params.ctx_attrs, + &iio_init_params.nb_ctx_attr, + eeprom_desc, + mezzanine_names[read_id], + STR(HW_CARRIER_NAME), + &hw_mezzanine_is_valid); + if (init_status) { + return init_status; + } + + if (hw_mezzanine_is_valid) { + ad4170_init_params.id = read_id; + break; + } } + /* Re-assign the parameters according to the active device */ + ad4170_configure_filter_params(); + if (hw_mezzanine_is_valid) { /* Initialize AD4170 device and peripheral interface */ init_status = ad4170_init(&p_ad4170_dev_inst, &ad4170_init_params); @@ -2891,7 +2974,7 @@ int32_t ad4170_iio_initialize(void) return init_status; } - iio_device_init_params[0].name = ACTIVE_DEVICE_NAME; + iio_device_init_params[0].name = active_dev[p_ad4170_dev_inst->id]; iio_device_init_params[0].raw_buf = adc_data_buffer; iio_device_init_params[0].raw_buf_len = DATA_BUFFER_SIZE; diff --git a/projects/ad4170_iio/app/ad4170_loadcell_config.c b/projects/ad4170_iio/app/ad4170_loadcell_config.c index 0a988e17e..c659a2452 100644 --- a/projects/ad4170_iio/app/ad4170_loadcell_config.c +++ b/projects/ad4170_iio/app/ad4170_loadcell_config.c @@ -2,7 +2,7 @@ * @file ad4170_loadcell_config.c * @brief Loadcell user configurations module for AD4170 IIO firmware ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -56,7 +56,11 @@ struct ad4170_init_param ad4170_loadcell_config_params = { .pin_muxing = { .chan_to_gpio = AD4170_CHANNEL_NOT_TO_GPIO, #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) +#if defined(DEV_AD4190) + .dig_aux2_ctrl = AD4170_DIG_AUX2_SYNC, // Used as START Input. +#else .dig_aux2_ctrl = AD4170_DIG_AUX2_LDAC, // Used as h/w LDACB +#endif // DEV_AD4190 .dig_aux1_ctrl = AD4170_DIG_AUX1_RDY, // Used as RDY (end of conversion) #elif (INTERFACE_MODE == TDM_MODE) .dig_aux1_ctrl = AD4170_DIG_AUX1_DISABLED, @@ -127,6 +131,8 @@ struct ad4170_init_param ad4170_loadcell_config_params = { { .misc = { #if defined(LOADCELL_AC_EXCITATION) + /* NOTE: chop_adc = AD4170_CHOP_IEXC_CD and AD4170_CHOP_IEXC_ABCD options + * are not available on the AD4190 */ /* Excitation currents are periodically chopped for AC excitation measurement */ .chop_adc = AD4170_CHOP_ACX_4PIN, #else @@ -243,6 +249,7 @@ struct ad4170_init_param ad4170_loadcell_config_params = { { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA }, { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA } }, +#if !defined(DEV_AD4190) .fir_control = { .fir_mode = AD4170_FIR_DEFAULT, .coeff_set = AD4170_FIR_COEFF_SET0, @@ -255,6 +262,7 @@ struct ad4170_init_param ad4170_loadcell_config_params = { .hw_toggle = false, .hw_ldac = false } +#endif }, &gpio_init_sync_inb, diff --git a/projects/ad4170_iio/app/ad4170_loadcell_config.h b/projects/ad4170_iio/app/ad4170_loadcell_config.h index 80c401f0c..659b76ca5 100644 --- a/projects/ad4170_iio/app/ad4170_loadcell_config.h +++ b/projects/ad4170_iio/app/ad4170_loadcell_config.h @@ -2,7 +2,7 @@ * @file ad4170_loadcell_config.h * @brief Header for AD4170 Loadcell configurations module ****************************************************************************** -* Copyright (c) 2021-22 Analog Devices, Inc. +* Copyright (c) 2021-22,25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -25,7 +25,8 @@ /********************** Macros and Constants Definition ***********************/ /******************************************************************************/ -/* Select the excitation type for load cell (AC/DC) - one at a time */ +/* Select the excitation type for load cell (AC/DC) - one at a time + * Note- AC excitation is not applicable in case of AD4190 */ #define LOADCELL_DC_EXCITATION //#define LOADCELL_AC_EXCITATION diff --git a/projects/ad4170_iio/app/ad4170_regs.h b/projects/ad4170_iio/app/ad4170_regs.h index 1d74ab21e..b52abf980 100644 --- a/projects/ad4170_iio/app/ad4170_regs.h +++ b/projects/ad4170_iio/app/ad4170_regs.h @@ -2,7 +2,7 @@ * @file ad4170_regs.h * @brief Global declarations for ad4170_regs module ******************************************************************************** -* Copyright (c) 2021,2024 Analog Devices, Inc. +* Copyright (c) 2021,2025 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. diff --git a/projects/ad4170_iio/app/ad4170_rtd_config.c b/projects/ad4170_iio/app/ad4170_rtd_config.c index a737bc31b..bb765cdce 100644 --- a/projects/ad4170_iio/app/ad4170_rtd_config.c +++ b/projects/ad4170_iio/app/ad4170_rtd_config.c @@ -2,7 +2,7 @@ * @file ad4170_rtd_config.c * @brief RTD (2/3/4-wire) user configurations module for AD4170 IIO firmware ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -56,7 +56,11 @@ struct ad4170_init_param ad4170_rtd_config_params = { .pin_muxing = { .chan_to_gpio = AD4170_CHANNEL_NOT_TO_GPIO, #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) +#if defined(DEV_AD4190) + .dig_aux2_ctrl = AD4170_DIG_AUX2_SYNC, // Used as START Input. +#else .dig_aux2_ctrl = AD4170_DIG_AUX2_LDAC, // Used as h/w LDACB +#endif // DEV_AD4190 .dig_aux1_ctrl = AD4170_DIG_AUX1_RDY, // Used as RDY (end of conversion) #elif (INTERFACE_MODE == TDM_MODE) .dig_aux1_ctrl = AD4170_DIG_AUX1_DISABLED, @@ -110,6 +114,8 @@ struct ad4170_init_param ad4170_rtd_config_params = { .setups = { // Setup0 { + /* NOTE: chop_adc = AD4170_CHOP_IEXC_CD and AD4170_CHOP_IEXC_ABCD + * options are not available on the AD4190 */ .misc = { .chop_iexc = AD4170_CHOP_IEXC_OFF, .chop_adc = AD4170_CHOP_OFF, @@ -156,6 +162,7 @@ struct ad4170_init_param ad4170_rtd_config_params = { { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA }, #endif }, +#if !defined(DEV_AD4190) .fir_control = { .fir_mode = AD4170_FIR_DEFAULT, .coeff_set = AD4170_FIR_COEFF_SET0, @@ -168,6 +175,7 @@ struct ad4170_init_param ad4170_rtd_config_params = { .hw_toggle = false, .hw_ldac = false } +#endif }, &gpio_init_sync_inb, diff --git a/projects/ad4170_iio/app/ad4170_thermistor_config.c b/projects/ad4170_iio/app/ad4170_thermistor_config.c index 917fd254c..ff28f56ea 100644 --- a/projects/ad4170_iio/app/ad4170_thermistor_config.c +++ b/projects/ad4170_iio/app/ad4170_thermistor_config.c @@ -2,7 +2,7 @@ * @file ad4170_thermistor_config.c * @brief Thermistor user configurations module for AD4170 IIO firmware ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -56,7 +56,11 @@ struct ad4170_init_param ad4170_thermistor_config_params = { .pin_muxing = { .chan_to_gpio = AD4170_CHANNEL_NOT_TO_GPIO, #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) +#if defined(DEV_AD4190) + .dig_aux2_ctrl = AD4170_DIG_AUX2_SYNC, // Used as START Input. +#else .dig_aux2_ctrl = AD4170_DIG_AUX2_LDAC, // Used as h/w LDACB +#endif // DEV_AD4190 .dig_aux1_ctrl = AD4170_DIG_AUX1_RDY, // Used as RDY (end of conversion) #elif (INTERFACE_MODE == TDM_MODE) .dig_aux1_ctrl = AD4170_DIG_AUX1_DISABLED, @@ -113,6 +117,8 @@ struct ad4170_init_param ad4170_thermistor_config_params = { .setups = { // Setup 0 { + /* NOTE: chop_adc = AD4170_CHOP_IEXC_CD and AD4170_CHOP_IEXC_ABCD + * options are not available on the AD4190 */ .misc = { .chop_iexc = AD4170_CHOP_IEXC_OFF, .chop_adc = AD4170_CHOP_OFF, @@ -211,6 +217,7 @@ struct ad4170_init_param ad4170_thermistor_config_params = { { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA }, { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA } }, +#if !defined(DEV_AD4190) .fir_control = { .fir_mode = AD4170_FIR_DEFAULT, .coeff_set = AD4170_FIR_COEFF_SET0, @@ -223,6 +230,7 @@ struct ad4170_init_param ad4170_thermistor_config_params = { .hw_toggle = false, .hw_ldac = false } +#endif }, &gpio_init_sync_inb, diff --git a/projects/ad4170_iio/app/ad4170_thermocouple_config.c b/projects/ad4170_iio/app/ad4170_thermocouple_config.c index 157eb3e24..d20f06b04 100644 --- a/projects/ad4170_iio/app/ad4170_thermocouple_config.c +++ b/projects/ad4170_iio/app/ad4170_thermocouple_config.c @@ -2,7 +2,7 @@ * @file ad4170_thermocouple_config.c * @brief Thermocouple user configurations module for AD4170 IIO firmware ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -56,7 +56,11 @@ struct ad4170_init_param ad4170_thermocouple_config_params = { .pin_muxing = { .chan_to_gpio = AD4170_CHANNEL_NOT_TO_GPIO, #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) +#if defined(DEV_AD4190) + .dig_aux2_ctrl = AD4170_DIG_AUX2_SYNC, // Used as START Input. +#else .dig_aux2_ctrl = AD4170_DIG_AUX2_LDAC, // Used as h/w LDACB +#endif // DEV_AD4190 .dig_aux1_ctrl = AD4170_DIG_AUX1_RDY, // Used as RDY (end of conversion) #elif (INTERFACE_MODE == TDM_MODE) .dig_aux1_ctrl = AD4170_DIG_AUX1_DISABLED, @@ -108,6 +112,8 @@ struct ad4170_init_param ad4170_thermocouple_config_params = { /* Setup configurations */ .setups = { + /* NOTE: chop_adc = AD4170_CHOP_IEXC_CD and AD4170_CHOP_IEXC_ABCD + * options are not available on the AD4190 */ // Setup0: TC1 and TC2 { .misc = { @@ -179,6 +185,7 @@ struct ad4170_init_param ad4170_thermocouple_config_params = { { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA }, { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA } }, +#if !defined(DEV_AD4190) .fir_control = { .fir_mode = AD4170_FIR_DEFAULT, .coeff_set = AD4170_FIR_COEFF_SET0, @@ -191,6 +198,7 @@ struct ad4170_init_param ad4170_thermocouple_config_params = { .hw_toggle = false, .hw_ldac = false } +#endif }, &gpio_init_sync_inb, diff --git a/projects/ad4170_iio/app/ad4170_user_config.c b/projects/ad4170_iio/app/ad4170_user_config.c index b16ca49c2..01bb178c7 100644 --- a/projects/ad4170_iio/app/ad4170_user_config.c +++ b/projects/ad4170_iio/app/ad4170_user_config.c @@ -2,7 +2,7 @@ * @file ad4170_user_config.c * @brief Default user configurations file for AD4170 device ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -72,7 +72,11 @@ struct ad4170_init_param ad4170_user_config_params = { .pin_muxing = { .chan_to_gpio = AD4170_CHANNEL_NOT_TO_GPIO, #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) || (INTERFACE_MODE == SPI_DMA_MODE) +#if defined(DEV_AD4190) + .dig_aux2_ctrl = AD4170_DIG_AUX2_SYNC, // Used as START Input. +#else .dig_aux2_ctrl = AD4170_DIG_AUX2_LDAC, // Used as h/w LDACB +#endif // DEV_AD4190 .dig_aux1_ctrl = AD4170_DIG_AUX1_RDY, // Used as RDY (end of conversion) #elif (INTERFACE_MODE == TDM_MODE) .dig_aux1_ctrl = AD4170_DIG_AUX1_DISABLED, @@ -189,6 +193,8 @@ struct ad4170_init_param ad4170_user_config_params = { * Note: Change in the default setup configurations may effect the data capture. * Read the code comments before changing FS value or any other parameters */ .setups = { + /* NOTE: chop_adc = AD4170_CHOP_IEXC_CD and AD4170_CHOP_IEXC_ABCD + * options are not available on the AD4190 */ { .misc = {.chop_iexc = AD4170_CHOP_IEXC_OFF, .chop_adc = AD4170_CHOP_OFF, .burnout = AD4170_BURNOUT_OFF }, .afe = { @@ -272,6 +278,7 @@ struct ad4170_init_param ad4170_user_config_params = { { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA }, { .i_out_pin = AD4170_I_OUT_AIN0, .i_out_val = AD4170_I_OUT_0UA } }, +#if !defined (DEV_AD4190) .fir_control = { .fir_mode = AD4170_FIR_MODE, .coeff_set = AD4170_COEF_SET, @@ -284,6 +291,7 @@ struct ad4170_init_param ad4170_user_config_params = { .hw_toggle = false, .hw_ldac = false } +#endif }, &gpio_init_sync_inb, diff --git a/projects/ad4170_iio/app/ad4170_user_config.h b/projects/ad4170_iio/app/ad4170_user_config.h index ca996f98b..bdc365529 100644 --- a/projects/ad4170_iio/app/ad4170_user_config.h +++ b/projects/ad4170_iio/app/ad4170_user_config.h @@ -2,7 +2,7 @@ * @file ad4170_user_config.h * @brief Header for AD4170 default user configurations file ****************************************************************************** -* Copyright (c) 2021-22,24 Analog Devices, Inc. +* Copyright (c) 2021-22,2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. diff --git a/projects/ad4170_iio/app/app_config.c b/projects/ad4170_iio/app/app_config.c index f8535e49b..2005578be 100644 --- a/projects/ad4170_iio/app/app_config.c +++ b/projects/ad4170_iio/app/app_config.c @@ -3,7 +3,7 @@ * @brief Application configurations module * @details This module contains the configurations needed for IIO application ******************************************************************************** - * Copyright (c) 2021-24 Analog Devices, Inc. + * Copyright (c) 2021-2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -56,7 +56,8 @@ struct no_os_uart_init_param uart_init_params = { #endif }; -/* LDAC GPO init parameters. */ +/* LDAC GPO init parameters. + * NOTE: DIG_AUX_2 is used only as SYNC in case of AD4190 */ struct no_os_gpio_init_param gpio_init_ldac_n = { .number = DIG_AUX_2, .port = DIG_AUX_2_PORT, diff --git a/projects/ad4170_iio/app/app_config.h b/projects/ad4170_iio/app/app_config.h index f1d00611d..1931799ac 100644 --- a/projects/ad4170_iio/app/app_config.h +++ b/projects/ad4170_iio/app/app_config.h @@ -70,6 +70,11 @@ #define DEVICE_NAME "DEV_AD4170" #define ACTIVE_DEVICE_ID ID_AD4170 #define HW_MEZZANINE_NAME "EVAL-AD4170-4ARDZ" +#elif defined (DEV_AD4190) +#define ACTIVE_DEVICE_NAME "ad4190" +#define DEVICE_NAME "DEV_AD4190" +#define ACTIVE_DEVICE_ID ID_AD4190 +#define HW_MEZZANINE_NAME "EVAL-AD4190-4ARDZ" #else #warning No/Unsupported ADxxxxy symbol defined. AD4170 defined #define DEV_AD4170 @@ -128,8 +133,8 @@ /* Redefine the init params structure mapping w.r.t. platform */ #define ticker_int_extra_init_params mbed_ticker_int_extra_init_params #if defined(USE_VIRTUAL_COM_PORT) -#define vcom_extra_init_params mbed_vcom_extra_init_params -#define vcom_ops mbed_virtual_com_ops +#define uart_extra_init_params mbed_vcom_extra_init_params +#define uart_ops mbed_virtual_com_ops #else #define uart_extra_init_params mbed_uart_extra_init_params #define uart_ops mbed_uart_ops @@ -214,6 +219,9 @@ #if defined(DEV_AD4170) #define DIFFERENTIAL_CHNS 4 #define SINGLE_ENDED_CHNS 8 +#elif defined (DEV_AD4190) +#define DIFFERENTIAL_CHNS 4 +#define SINGLE_ENDED_CHNS 8 #endif /* Include user config files and params according to active/selected demo mode config */ @@ -295,6 +303,9 @@ /* Default sampling frequency for AD4170 (in SPS) */ #define AD4170_DEFLT_SAMPLING_FREQUENCY (AD4170_INTERNAL_CLOCK / FS_TO_ODR_CONV_SCALER) +/* Scale value for Filters - SINC5, SINC5_AVG and SINC3 */ +#define FILTER_SCALE 32 + /******************************************************************************/ /************************ Public Declarations *********************************/ /******************************************************************************/ diff --git a/projects/ad4170_iio/app/app_config_mbed.h b/projects/ad4170_iio/app/app_config_mbed.h index 0be385096..069fe0e44 100644 --- a/projects/ad4170_iio/app/app_config_mbed.h +++ b/projects/ad4170_iio/app/app_config_mbed.h @@ -2,7 +2,7 @@ * @file app_config_mbed.h * @brief Header file for Mbed platform configurations ******************************************************************************** - * Copyright (c) 2021-24 Analog Devices, Inc. + * Copyright (c) 2021-2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -95,6 +95,9 @@ /* Max SPI Speed */ #define AD4170_MAX_SPI_SPEED 22500000 +/* AD4170 Max sampling rate */ +#define AD4170_MAX_SAMPLING_RATE 32000 + /******************************************************************************/ /********************** Public/Extern Declarations ****************************/ /******************************************************************************/ diff --git a/projects/ad4170_iio/app/app_config_stm32.h b/projects/ad4170_iio/app/app_config_stm32.h index ee5a11776..ec9008f37 100644 --- a/projects/ad4170_iio/app/app_config_stm32.h +++ b/projects/ad4170_iio/app/app_config_stm32.h @@ -2,7 +2,7 @@ * @file app_config_stm32.h * @brief Header file for STM32 platform configurations ******************************************************************************** - * Copyright (c) 2023-24 Analog Devices, Inc. + * Copyright (c) 2023-2024-25 Analog Devices, Inc. * All rights reserved. * * This software is proprietary to Analog Devices, Inc. and its licensors. @@ -141,12 +141,27 @@ * a value specific to the NUCLEO-H563ZI platform tested with a 10MHz SPI clock. The maximum * ODR might vary across platforms and data continuity is not guaranteed above this ODR * on the IIO Client*/ + +/* Value corresponding to 24KSPS ODR (per channel) with Sinc5 average filter */ +#define FS_SINC5_AVG_24_KSPS 20 + +/* Value corresponding to 512ksps ODR (per channel) with Sinc5 filter */ +#define FS_SINC5_512_KSPS 1 + +/* Value corresponding to 62.5 ODR (per channel) with Sinc3 filter */ +#define FS_SINC3_62P5_KSPS 4 + #if (INTERFACE_MODE == SPI_INTERRUPT_MODE) -#define FS_CONFIG_VALUE 20 // Value corresponding to 24KSPS ODR (per channel) with Sinc5 average filter -#elif (INTERFACE_MODE == SPI_DMA_MODE) -#define FS_CONFIG_VALUE 1 // Value correspoinding to 512ksps ODR (per channel) with Sinc5 filter -#else // TDM_MODE -#define FS_CONFIG_VALUE 1 // Value correspoinding to 512ksps ODR (per channel) with Sinc5 filter +#define FS_CONFIG_VALUE FS_SINC5_AVG_24_KSPS +#define AD4170_MAX_SAMPLING_RATE 24000 +#else // TDM_MODE and SPI_DMA_MODE +#if defined (DEV_AD4170) +#define FS_CONFIG_VALUE FS_SINC5_512_KSPS +#define AD4170_MAX_SAMPLING_RATE 500000 +#elif defined (DEV_AD4190) +#define FS_CONFIG_VALUE FS_SINC3_62P5_KSPS +#define AD4170_MAX_SAMPLING_RATE 62500 +#endif #endif #define TICKER_INTERRUPT_PERIOD_uSEC (0) // unused @@ -174,6 +189,8 @@ extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart5; extern DMA_HandleTypeDef hdma_spi1_rx; extern DMA_HandleTypeDef hdma_tim8_ch1; +extern USBD_HandleTypeDef hUsbDeviceHS; +extern struct stm32_usb_uart_init_param stm32_vcom_extra_init_params; #endif extern bool data_capture_operation; extern struct iio_device_data *ad4170_iio_dev_data; @@ -194,10 +211,6 @@ extern struct no_os_dma_init_param ad4170_dma_init_param; extern struct stm32_dma_channel rxdma_channel; extern struct stm32_dma_channel txdma_channel; #endif -#if defined (TARGET_SDP_K1) -extern USBD_HandleTypeDef hUsbDeviceHS; -extern struct stm32_usb_uart_init_param stm32_vcom_extra_init_params; -#endif void tim8_config(void); void stm32_timer_stop(void);