|
precision-converters-firmware
|
Implementation of AD4692 IIO application interfaces. More...
#include <string.h>#include "ad4692_user_config.h"#include "ad4692_support.h"#include "ad4692_iio.h"#include "iio_trigger.h"#include "no_os_error.h"#include "no_os_delay.h"#include "no_os_util.h"#include "no_os_alloc.h"#include "app_config.h"#include "common.h"#include "ad4692.h"#include "version.h"#include "ad4692_attrs.h"
Enumerations | |
| enum | ad4692_board_attribute_ids { PRIORITY , PRIORITY_AVAILABLE } |
| enum | ad4692_readback_options { AVERAGED_DATA , ACCUMULATOR_DATA } |
Functions | |
| int | ad4692_update_sampling_frequency (uint32_t *sampling_rate) |
| Set the sampling rate and get the updated value supported by MCU platform. | |
| int | ad4692_iio_attr_get (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv) |
| Getter/Setter for the raw, offset and scale attribute value. | |
| int | ad4692_iio_attr_set (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv) |
| Setter function for AD4692 attributes. | |
| int | ad4692_iio_attr_available_get (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv) |
| Attribute available getter function for AD4692 attributes. | |
| int | ad4692_iio_attr_available_set (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv) |
| Attribute available setter function for AD4692 attributes. | |
| int32_t | ad4692_trigger_handler (struct iio_device_data *iio_dev_data) |
| Push data into IIO buffer when trigger handler IRQ is invoked. | |
| void | ad4692_data_capture_callback (void *ctx) |
| Interrupt Service Routine to monitor end of conversion event. | |
| int32_t | ad4692_configure_sampling_rate (void) |
| int32_t | iio_app_initialize (void) |
| Initialize the AD4692 IIO Application. | |
| void | iio_params_deinit (void) |
| DeInitialize the IIO parameters. | |
| void | iio_app_event_handler (void) |
| Run the ad4692 IIO event handler. | |
Implementation of AD4692 IIO application interfaces.
This module acts as an interface for AD4692 IIO application
Copyright (c) 2024, 2026 Analog Devices, Inc.
This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.
| #define ACC_COUNT_MAX_VAL 64 |
| #define ACC_COUNT_MIN_VAL 0 |
| #define AD4692_ADC_MODE_STOP_STATE_MASK NO_OS_BIT(5) |
| #define AD4692_DEFAULT_CHN_SCAN |
| #define AD4692_EXIT_MANUAL_MODE 0x0 |
| #define AD4692_IIO_CH | ( | _name, | |
| _dev, | |||
| _idx | |||
| ) |
| #define AD4692_IIO_TRIGGER_NAME "ad4692_iio_trigger" |
| #define AD4692_MAX_PRIORITIES 2 |
| #define AD4692_N_BYTES_CNV_CLOCK_16BIT 4 |
| #define AD4692_N_BYTES_CNV_CLOCK_24BIT 5 |
| #define AD4692_N_CNV_TOGGLES 2 |
| #define AD4692_OFFSET 0 |
| #define AD4692_RES_16 16 |
| #define AD4692_RES_24 24 |
| #define AD4692_SCALE (((float) (AD4692_VREF) / 1000000.0f) / (float)(ADC_MAX_COUNT_UNIPOLAR) * 1000.0f) |
| #define AD4692_STOP_STATE_DATA_READYb 0x1 |
| #define adc_data_buffer SDRAM_START_ADDRESS + (N_CYCLE_OFFSET * BYTES_PER_SAMPLE) |
| #define ADC_MAX_COUNT_UNIPOLAR (uint32_t) ((1 << ADC_RESOLUTION) - 1) |
| #define BUF_READ_TIMEOUT 0xffffffff |
| #define CS_CHANGE 1 |
| #define DATA_BUFFER_SIZE SDRAM_SIZE_BYTES |
| #define DATA_BUFFER_SIZE_CONT (32768) |
| #define MAX_DMA_NDTR (no_os_min(65532, (MAX_LOCAL_BUF_SIZE))) |
| #define MAX_LOCAL_BUF_SIZE 65536 |
| #define PWM_PERIOD_TO_FREQUENCY | ( | x | ) | (1000000000.0 / x) |
| int32_t ad4692_configure_sampling_rate | ( | void | ) |

| void ad4692_data_capture_callback | ( | void * | ctx | ) |
Interrupt Service Routine to monitor end of conversion event.
| ctx[in] | - Callback context (unused) |
| int ad4692_iio_attr_available_get | ( | void * | device, |
| char * | buf, | ||
| uint32_t | len, | ||
| const struct iio_ch_info * | channel, | ||
| intptr_t | priv | ||
| ) |
Attribute available getter function for AD4692 attributes.
| device[in,out]- | Pointer to IIO device instance |
| buf[in]- | IIO input data buffer |
| len[in]- | Number of input bytes |
| channel[in] | - input channel |
| priv[in] | - Attribute private ID |
| int ad4692_iio_attr_available_set | ( | void * | device, |
| char * | buf, | ||
| uint32_t | len, | ||
| const struct iio_ch_info * | channel, | ||
| intptr_t | priv | ||
| ) |
Attribute available setter function for AD4692 attributes.
| device[in,out]- | Pointer to IIO device instance |
| buf[in]- | IIO input data buffer |
| len[in]- | Number of input bytes |
| channel[in] | - input channel |
| priv[in] | - Attribute private ID |
| int ad4692_iio_attr_get | ( | void * | device, |
| char * | buf, | ||
| uint32_t | len, | ||
| const struct iio_ch_info * | channel, | ||
| intptr_t | priv | ||
| ) |
Getter/Setter for the raw, offset and scale attribute value.
| device[in,out]- | Pointer to IIO device instance |
| buf[in]- | IIO input data buffer |
| len[in]- | Number of input bytes |
| channel[in] | - input channel |
| priv[in] | - Attribute private ID |
| int ad4692_iio_attr_set | ( | void * | device, |
| char * | buf, | ||
| uint32_t | len, | ||
| const struct iio_ch_info * | channel, | ||
| intptr_t | priv | ||
| ) |
Setter function for AD4692 attributes.
| device[in,out]- | Pointer to IIO device instance |
| buf[in]- | IIO input data buffer |
| len[in]- | Number of expected bytes |
| channel[in] | - input channel |
| priv[in] | - Attribute private ID |
| int32_t ad4692_trigger_handler | ( | struct iio_device_data * | iio_dev_data | ) |
Push data into IIO buffer when trigger handler IRQ is invoked.
| iio_dev_data[in] | - IIO device data instance |
| int ad4692_update_sampling_frequency | ( | uint32_t * | sampling_rate | ) |
Set the sampling rate and get the updated value supported by MCU platform.

| void iio_app_event_handler | ( | void | ) |
Run the ad4692 IIO event handler.
Run the AD405X IIO event handler.
| int32_t iio_app_initialize | ( | void | ) |
Initialize the AD4692 IIO Application.
Initialize the IIO interface for AD405X IIO device.

| void iio_params_deinit | ( | void | ) |
DeInitialize the IIO parameters.

| uint8_t ad4692_acc_count[NO_OF_CHANNELS] = { 0x0 } |
| enum ad4692_data_capture_modes ad4692_data_capture_mode = BURST |
| struct ad4692_desc* ad4692_dev = NULL |
| volatile bool ad4692_dma_buff_full = false |
| struct scan_type ad4692_iio_scan_type[NUM_OF_IIO_DEVICES][NO_OF_CHANNELS] |
| enum ad4692_interface_modes ad4692_interface_mode = SPI_DMA |
| enum ad4692_readback_options ad4692_readback_option = AVERAGED_DATA |
| uint32_t ad4692_sampling_frequency |
| uint32_t ad4692_sampling_frequency_max |
| struct no_os_spi_msg ad4692_spi_msg_manual_mode |
| volatile uint32_t* buff_start_addr |
| uint32_t callback_count = 0 |
| volatile uint8_t chan_id = 0 |
| uint16_t channel_mask = 0x1 |
| uint8_t channel_priorities[NO_OF_CHANNELS] = { 0x0 } |
| uint8_t channel_sequence[AD4692_MAX_SLOTS_AS] = { 0x0 } |
| uint8_t data_buff[BYTES_PER_SAMPLE] = { 0x0 } |
| uint32_t data_read |
| volatile bool dma_config_updated = false |
| volatile struct iio_device_data* iio_dev_data_g |
| struct iio_init_param iio_init_params |
| uint8_t local_buf[MAX_LOCAL_BUF_SIZE+(NO_OF_CHANNELS *N_CYCLE_OFFSET)] |
| uint8_t n_data_bytes |
| uint32_t nb_of_samples_g |
| uint8_t num_of_active_channels = 0 |
| uint8_t num_of_as_slots = 0 |
| struct stm32_spi_init_param* spi_init_param |