precision-converters-firmware
Loading...
Searching...
No Matches
Functions | Variables
ad4692_support.c File Reference

Support file for AD4692 device. More...

#include "string.h"
#include "ad4692_support.h"
#include "ad4692_iio.h"
#include "app_config.h"
#include "no_os_error.h"
#include "no_os_delay.h"
#include "no_os_util.h"
Include dependency graph for ad4692_support.c:

Functions

int32_t ad4692_data_transfer_init (struct ad4692_desc *desc, enum ad4692_spi_mode mode)
 Initialize the data transfer system for a given ADC mode.
 
int32_t ad4692_data_transfer_read_converted_data (struct ad4692_desc *desc, uint8_t chn, uint32_t *adc_data)
 Delegation: read converted data from active mode.
 
void ad4692_update_active_channels (uint32_t ch_mask)
 Update active channels based on sequencer mode and channel mask.
 
int32_t ad4692_data_transfer_prepare (void *dev, uint32_t ch_mask)
 Delegation: prepare transfer for active mode.
 
int32_t ad4692_data_transfer_end (void *dev)
 Delegation: end transfer for active mode.
 
int32_t ad4692_data_transfer_remove (struct ad4692_desc *desc)
 Delegation: remove active mode resources.
 
int32_t ad4692_data_transfer_submit (struct iio_device_data *iio_dev_data)
 Delegation: submit samples for active mode.
 
int32_t ad4692_data_transfer_trigger_handler (struct iio_device_data *iio_dev_data)
 Delegation: trigger handler for active mode.
 
int32_t ad4692_data_transfer_update_freq (uint32_t *sampling_rate)
 Delegation: update sampling frequency for active mode.
 
uint32_t ad4692_get_max_sampling_rate (enum ad4692_spi_mode mode)
 Get maximum sampling rate for a given ADC mode.
 
void ad4692_get_tx_command (uint8_t *local_tx_data)
 Get the Tx buffer respective to the enabled channels.
 
int ad4692_configure_acc_mask (uint16_t channel_mask, enum ad4692_sequencer_modes sequencer, uint8_t *chn_priorities)
 Configure the accumulator mask.
 
int ad4692_configure_channel_priorities (uint8_t *chn_priorities, uint8_t *channel_sequence, uint8_t *num_of_as_slots, uint8_t *acc_count)
 Configure the advanced sequencer slots.
 
int ad4692_configure_channel (struct ad4692_desc *desc)
 Configure the per channel accumulator count limit and enable the desired channels in the AD4692 device.
 
int ad4692_exit_manual_mode (struct ad4692_desc *desc)
 Exit manual mode and switch to CNV clock mode.
 
int ad4692_configure_pwm_rate (struct no_os_pwm_desc *desc, uint32_t sampling_rate)
 Configure PWM with optimal prescaler for given sampling rate.
 

Variables

volatile bool buf_size_updated = false
 

Detailed Description

Support file for AD4692 device.

Copyright (c) 2026 Analog Devices, Inc.

All rights reserved.

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.

Function Documentation

◆ ad4692_configure_acc_mask()

int ad4692_configure_acc_mask ( uint16_t  channel_mask,
enum ad4692_sequencer_modes  sequencer,
uint8_t *  chn_priorities 
)

Configure the accumulator mask.

Parameters
channel_mask[in]- Channel mask (Applicable in case of standard sequencer)
sequencer[in]- Sequencer mode
chn_priorities[in]- Channel priority (Applicable in case of advanced sequencer)
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad4692_configure_channel()

int ad4692_configure_channel ( struct ad4692_desc *  desc)

Configure the per channel accumulator count limit and enable the desired channels in the AD4692 device.

Parameters
desc[in]- AD4692 device descriptor
Returns
0 in case of success, negative error code otherwise

◆ ad4692_configure_channel_priorities()

int ad4692_configure_channel_priorities ( uint8_t *  chn_priorities,
uint8_t *  channel_sequence,
uint8_t *  num_of_as_slots,
uint8_t *  acc_count 
)

Configure the advanced sequencer slots.

Parameters
chn_priorities[in]- channel priorities to be configured
channel_sequence[out]- Channel sequence as configured in the AS Slots
num_of_as_slots[out]- Number of slots in the advanced sequencer
acc_count[in]- Accumulator count limit
Returns
0 in case of success, negative error code otherwise.

This function configures the advanced sequencer slots based on the priorities assigned to each channel(max 2 priorities are allowed in the application). Example: If the user configures the following channels as P1 (highest priority): Ch0,Ch1,Ch2 and the following as P2 (Least priority): Ch3,Ch4 Then the advanced sequencer configurations would look like: Ch0-Ch1-Ch2-Ch3-Ch0-Ch1-Ch2-Ch4

Here is the caller graph for this function:

◆ ad4692_configure_pwm_rate()

int ad4692_configure_pwm_rate ( struct no_os_pwm_desc *  desc,
uint32_t  sampling_rate 
)

Configure PWM with optimal prescaler for given sampling rate.

Parameters
desc[in]- PWM descriptor to configure
sampling_rate[in]- Desired sampling rate in samples per second
Returns
0 in case of success, negative error code otherwise

◆ ad4692_data_transfer_end()

int32_t ad4692_data_transfer_end ( void *  dev)

Delegation: end transfer for active mode.

Parameters
dev[in]- IIO device instance
Returns
0 in case of success, -EINVAL if no active mode, 0 if function not implemented

◆ ad4692_data_transfer_init()

int32_t ad4692_data_transfer_init ( struct ad4692_desc *  desc,
enum ad4692_spi_mode  mode 
)

Initialize the data transfer system for a given ADC mode.

Parameters
desc[in]- AD4692 device descriptor
mode[in]- ADC mode to initialize
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad4692_data_transfer_prepare()

int32_t ad4692_data_transfer_prepare ( void *  dev,
uint32_t  ch_mask 
)

Delegation: prepare transfer for active mode.

Parameters
dev[in]- IIO device instance
ch_mask[in]- Channel mask indicating which channels to enable
Returns
0 in case of success, -EINVAL if no active mode, 0 if function not implemented

◆ ad4692_data_transfer_read_converted_data()

int32_t ad4692_data_transfer_read_converted_data ( struct ad4692_desc *  desc,
uint8_t  chn,
uint32_t *  adc_data 
)

Delegation: read converted data from active mode.

Parameters
desc[in]- AD4692 device descriptor
chn[in]- Channel number to read
adc_data[out]- Pointer to store the converted data
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad4692_data_transfer_remove()

int32_t ad4692_data_transfer_remove ( struct ad4692_desc *  desc)

Delegation: remove active mode resources.

Parameters
desc[in]- AD4692 device descriptor
Returns
0 in case of success, -EINVAL if no active mode, 0 if function not implemented
Here is the caller graph for this function:

◆ ad4692_data_transfer_submit()

int32_t ad4692_data_transfer_submit ( struct iio_device_data *  iio_dev_data)

Delegation: submit samples for active mode.

Parameters
iio_dev_data[in]- IIO device data instance
Returns
0 in case of success, -EINVAL if no active mode, 0 if function not implemented

◆ ad4692_data_transfer_trigger_handler()

int32_t ad4692_data_transfer_trigger_handler ( struct iio_device_data *  iio_dev_data)

Delegation: trigger handler for active mode.

Parameters
iio_dev_data[in]- IIO device data instance
Returns
0 in case of success, -EINVAL if no active mode, 0 if function not implemented

◆ ad4692_data_transfer_update_freq()

int32_t ad4692_data_transfer_update_freq ( uint32_t *  sampling_rate)

Delegation: update sampling frequency for active mode.

Parameters
sampling_rate[in,out]- Pointer to requested/actual sampling rate
Returns
0 in case of success, -EINVAL if no active mode, 0 if function not implemented
Here is the caller graph for this function:

◆ ad4692_exit_manual_mode()

int ad4692_exit_manual_mode ( struct ad4692_desc *  desc)

Exit manual mode and switch to CNV clock mode.

Parameters
desc[in]- AD4692 device descriptor
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad4692_get_max_sampling_rate()

uint32_t ad4692_get_max_sampling_rate ( enum ad4692_spi_mode  mode)

Get maximum sampling rate for a given ADC mode.

Parameters
mode[in]- ADC mode
Returns
Maximum sampling rate in samples per second
Here is the caller graph for this function:

◆ ad4692_get_tx_command()

void ad4692_get_tx_command ( uint8_t *  local_tx_data)

Get the Tx buffer respective to the enabled channels.

Parameters
local_tx_data[out]- Tx buffer to populate with channel commands
Returns
None

◆ ad4692_update_active_channels()

void ad4692_update_active_channels ( uint32_t  ch_mask)

Update active channels based on sequencer mode and channel mask.

Parameters
ch_mask[in]- Channel mask (used in standard sequencer mode)

Variable Documentation

◆ buf_size_updated

volatile bool buf_size_updated = false