precision-converters-firmware
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
ad4692_iio.c File Reference

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"
Include dependency graph for ad4692_iio.c:

Macros

#define AD4692_IIO_TRIGGER_NAME   "ad4692_iio_trigger"
 
#define adc_data_buffer   SDRAM_START_ADDRESS
 
#define DATA_BUFFER_SIZE   SDRAM_SIZE_BYTES - (N_CYCLE_OFFSET * BYTES_PER_SAMPLE)
 
#define DATA_BUFFER_SIZE_CONT   (32768)
 
#define AD4692_DEFAULT_CHN_SCAN
 
#define AD4692_IIO_CH(_name, _dev, _idx)
 
#define BUF_READ_TIMEOUT   0xffffffff
 
#define ACC_COUNT_MIN_VAL   0
 
#define ACC_COUNT_MAX_VAL   64
 
#define ADC_MAX_COUNT_UNIPOLAR   (uint32_t) ((1 << ADC_RESOLUTION) - 1)
 
#define AD4692_SCALE   (((float) (AD4692_VREF) / 1000000.0f) / (float)(ADC_MAX_COUNT_UNIPOLAR) * 1000.0f)
 
#define AD4692_OFFSET   0
 
#define AD4692_MAX_PRIORITIES   2
 
#define AD4692_RES_16   16
 
#define AD4692_RES_24   24
 

Enumerations

enum  ad4692_board_attribute_ids {
  PRIORITY ,
  PRIORITY_AVAILABLE
}
 

Functions

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.
 
void ad4692_data_capture_callback (void *ctx)
 Interrupt Service Routine to monitor end of conversion event.
 
void iio_params_deinit (void)
 DeInitialize the IIO parameters.
 
int32_t iio_adc_remove (void)
 Remove the AD4692 Instance & IIO device.
 
int32_t iio_app_remove (void)
 Remove the IIO application and free the allocated resources.
 
int32_t iio_app_initialize (void)
 Initialize the AD4692 IIO Application.
 
void iio_app_event_handler (void)
 Run the ad4692 IIO event handler.
 

Variables

struct scan_type ad4692_iio_scan_type [NUM_OF_IIO_DEVICES][NO_OF_CHANNELS]
 
struct ad4692_desc * ad4692_dev = NULL
 
struct iio_hw_trig * ad4692_hw_trig_desc
 
uint8_t ad4692_active_channels [NO_OF_CHANNELS]
 
uint8_t num_of_active_channels = 0
 
volatile bool ad4692_conversion_flag = false
 
uint16_t channel_mask = 0x1
 
uint8_t ad4692_acc_count [NO_OF_CHANNELS] = { 0x0 }
 
enum ad4692_sequencer_modes ad4692_sequencer_mode = STANDARD_SEQUENCER
 
enum ad4692_interface_modes ad4692_interface_mode = SPI_DMA
 
enum ad4692_data_capture_modes ad4692_data_capture_mode = BURST_DATA_CAPTURE
 
enum ad4692_readback_options ad4692_readback_option = AVERAGED_DATA
 
enum ad4692_int_osc_sel ad4692_osc_freq_id = AD4692_OSC_1MHZ
 
uint32_t ad4692_sampling_frequency
 
uint8_t channel_priorities [NO_OF_CHANNELS] = { 0x0 }
 
uint8_t channel_sequence [AD4692_MAX_SLOTS_AS] = { 0x0 }
 
uint8_t num_of_as_slots = 0
 
uint8_t n_data_bytes
 
uint8_t n_bytes_per_transaction = AD4692_N_BYTES_TXN_16BIT
 
struct stm32_spi_init_param * spi_init_param
 
struct iio_init_param iio_init_params
 

Detailed Description

Implementation of AD4692 IIO application interfaces.

This module acts as an interface for AD4692 IIO application

Copyright (c) 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.

Macro Definition Documentation

◆ ACC_COUNT_MAX_VAL

#define ACC_COUNT_MAX_VAL   64

◆ ACC_COUNT_MIN_VAL

#define ACC_COUNT_MIN_VAL   0

◆ AD4692_DEFAULT_CHN_SCAN

#define AD4692_DEFAULT_CHN_SCAN
Value:
{\
.sign = 'u',\
.realbits = ADC_RESOLUTION,\
.storagebits = CHN_STORAGE_BITS,\
.shift = 0,\
.is_big_endian = true\
}
#define CHN_STORAGE_BITS
Definition ad2s1210_iio.c:70
#define ADC_RESOLUTION
Definition app_config.h:161

◆ AD4692_IIO_CH

#define AD4692_IIO_CH (   _name,
  _dev,
  _idx 
)
Value:
{\
.name = _name,\
.ch_type = IIO_VOLTAGE,\
.ch_out = false,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = ad4692_iio_scan_type[_dev],\
.attributes = ad4692_iio_ch_attributes[_dev]\
}
struct scan_type ad4692_iio_scan_type[NUM_OF_IIO_DEVICES][NO_OF_CHANNELS]
Definition ad4692_iio.c:63

◆ AD4692_IIO_TRIGGER_NAME

#define AD4692_IIO_TRIGGER_NAME   "ad4692_iio_trigger"

◆ AD4692_MAX_PRIORITIES

#define AD4692_MAX_PRIORITIES   2

◆ AD4692_OFFSET

#define AD4692_OFFSET   0

◆ AD4692_RES_16

#define AD4692_RES_16   16

◆ AD4692_RES_24

#define AD4692_RES_24   24

◆ AD4692_SCALE

#define AD4692_SCALE   (((float) (AD4692_VREF) / 1000000.0f) / (float)(ADC_MAX_COUNT_UNIPOLAR) * 1000.0f)

◆ adc_data_buffer

#define adc_data_buffer   SDRAM_START_ADDRESS

◆ ADC_MAX_COUNT_UNIPOLAR

#define ADC_MAX_COUNT_UNIPOLAR   (uint32_t) ((1 << ADC_RESOLUTION) - 1)

◆ BUF_READ_TIMEOUT

#define BUF_READ_TIMEOUT   0xffffffff

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   SDRAM_SIZE_BYTES - (N_CYCLE_OFFSET * BYTES_PER_SAMPLE)

◆ DATA_BUFFER_SIZE_CONT

#define DATA_BUFFER_SIZE_CONT   (32768)

Enumeration Type Documentation

◆ ad4692_board_attribute_ids

Enumerator
PRIORITY 
PRIORITY_AVAILABLE 

Function Documentation

◆ ad4692_data_capture_callback()

void ad4692_data_capture_callback ( void *  ctx)

Interrupt Service Routine to monitor end of conversion event.

Parameters
ctx[in]- Callback context (unused)
Returns
none

◆ ad4692_iio_attr_available_get()

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.

Parameters
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
Returns
len in case of SUCCESS, negative error code otherwise

◆ ad4692_iio_attr_available_set()

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.

Parameters
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
Returns
len in case of success, negative error code otherwise

◆ ad4692_iio_attr_get()

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.

Parameters
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
Returns
Number of characters read/written, negative error code otherwise

◆ ad4692_iio_attr_set()

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.

Parameters
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
Returns
len in case of success, negative error code otherwise

◆ iio_adc_remove()

int32_t iio_adc_remove ( void  )

Remove the AD4692 Instance & IIO device.

Returns
0
Here is the caller graph for this function:

◆ iio_app_event_handler()

void iio_app_event_handler ( void  )

Run the ad4692 IIO event handler.

Run the AD3530R IIO event handler.

Returns
None

◆ iio_app_initialize()

int32_t iio_app_initialize ( void  )

Initialize the AD4692 IIO Application.

Initialize the IIO interface for AD3530R IIO device.

Returns
0 in case of success, negative value otherwise
Here is the caller graph for this function:

◆ iio_app_remove()

int32_t iio_app_remove ( void  )

Remove the IIO application and free the allocated resources.

Returns
0
Here is the caller graph for this function:

◆ iio_params_deinit()

void iio_params_deinit ( void  )

DeInitialize the IIO parameters.

Here is the caller graph for this function:

Variable Documentation

◆ ad4692_acc_count

uint8_t ad4692_acc_count[NO_OF_CHANNELS] = { 0x0 }

◆ ad4692_active_channels

uint8_t ad4692_active_channels[NO_OF_CHANNELS]

◆ ad4692_conversion_flag

volatile bool ad4692_conversion_flag = false

◆ ad4692_data_capture_mode

enum ad4692_data_capture_modes ad4692_data_capture_mode = BURST_DATA_CAPTURE

◆ ad4692_dev

struct ad4692_desc* ad4692_dev = NULL

◆ ad4692_hw_trig_desc

struct iio_hw_trig* ad4692_hw_trig_desc

◆ ad4692_iio_scan_type

struct scan_type ad4692_iio_scan_type[NUM_OF_IIO_DEVICES][NO_OF_CHANNELS]

◆ ad4692_interface_mode

enum ad4692_interface_modes ad4692_interface_mode = SPI_DMA

◆ ad4692_osc_freq_id

enum ad4692_int_osc_sel ad4692_osc_freq_id = AD4692_OSC_1MHZ

◆ ad4692_readback_option

enum ad4692_readback_options ad4692_readback_option = AVERAGED_DATA

◆ ad4692_sampling_frequency

uint32_t ad4692_sampling_frequency

◆ ad4692_sequencer_mode

enum ad4692_sequencer_modes ad4692_sequencer_mode = STANDARD_SEQUENCER

◆ channel_mask

uint16_t channel_mask = 0x1

◆ channel_priorities

uint8_t channel_priorities[NO_OF_CHANNELS] = { 0x0 }

◆ channel_sequence

uint8_t channel_sequence[AD4692_MAX_SLOTS_AS] = { 0x0 }

◆ iio_init_params

struct iio_init_param iio_init_params
Initial value:
= {
.phy_type = USE_UART,
}

◆ n_bytes_per_transaction

uint8_t n_bytes_per_transaction = AD4692_N_BYTES_TXN_16BIT

◆ n_data_bytes

uint8_t n_data_bytes

◆ num_of_active_channels

uint8_t num_of_active_channels = 0

◆ num_of_as_slots

uint8_t num_of_as_slots = 0

◆ spi_init_param

struct stm32_spi_init_param* spi_init_param