precision-converters-firmware
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
ad4692_support.h File Reference

Support header file for AD4692. More...

#include "no_os_gpio.h"
#include "iio.h"
#include "iio_trigger.h"
#include "ad4692.h"
Include dependency graph for ad4692_support.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad4692_data_transfer_system
 AD4692 Data transfer system function pointers (per ADC mode) More...
 

Macros

#define AD4692_MAX_SLOTS_AS   128
 
#define CS_CHANGE   1
 
#define AD4692_N_BYTES_TXN_24BIT   5
 
#define AD4692_N_BYTES_TXN_16BIT   4
 
#define AD4692_N_BYTES_TXN_OFFSET   2
 
#define AD4692_N_CNV_TOGGLES   2
 
#define AD4692_EXIT_MANUAL_MODE   0x0
 
#define PWM_PERIOD_TO_FREQUENCY(x)   (1E9 / x)
 

Enumerations

enum  ad4692_sequencer_modes {
  STANDARD_SEQUENCER ,
  ADVANCED_SEQUENCER
}
 AD4692 sequencer modes. More...
 
enum  ad4692_readback_options {
  AVERAGED_DATA ,
  ACCUMULATOR_DATA
}
 AD4692 readback options. More...
 

Functions

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_configure_channel_priorities (uint8_t *chn_priorities, uint8_t *channel_sequence, uint8_t *num_as_slots, uint8_t *acc_count)
 Configure the advanced sequencer slots.
 
int ad4692_configure_acc_mask (uint16_t channel_mask, enum ad4692_sequencer_modes sequencer, uint8_t *chn_priorities)
 Configure the accumulator mask.
 
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.
 
void ad4692_get_tx_command (uint8_t *local_tx_data)
 Get the Tx buffer respective to the enabled channels.
 
void ad4692_update_active_channels (uint32_t ch_mask)
 Update active channels based on sequencer mode and channel mask.
 
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_prepare (void *dev, uint32_t ch_mask)
 Delegation: prepare transfer for active mode.
 
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_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_read_converted_data (struct ad4692_desc *desc, uint8_t chn, uint32_t *adc_data)
 Delegation: read converted data from 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.
 

Variables

struct ad4692_data_transfer_system ad4692_data_transfer_manual_mode
 
struct ad4692_data_transfer_system ad4692_data_transfer_cnv_clock_mode
 
struct ad4692_data_transfer_system ad4692_data_transfer_cnv_burst_mode
 
struct ad4692_data_transfer_system ad4692_data_transfer_spi_burst_mode
 
uint8_t ad4692_active_channels []
 
uint8_t num_of_active_channels
 
uint16_t channel_mask
 
uint8_t ad4692_acc_count []
 
uint8_t channel_priorities []
 
uint8_t n_data_bytes
 
uint8_t n_bytes_per_transaction
 
volatile bool ad4692_conversion_flag
 
volatile bool buf_size_updated
 
enum ad4692_sequencer_modes ad4692_sequencer_mode
 
enum ad4692_readback_options ad4692_readback_option
 
enum ad4692_int_osc_sel ad4692_osc_freq_id
 
struct iio_hw_trig * ad4692_hw_trig_desc
 

Detailed Description

Support header file for AD4692.

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.

Macro Definition Documentation

◆ AD4692_EXIT_MANUAL_MODE

#define AD4692_EXIT_MANUAL_MODE   0x0

◆ AD4692_MAX_SLOTS_AS

#define AD4692_MAX_SLOTS_AS   128

◆ AD4692_N_BYTES_TXN_16BIT

#define AD4692_N_BYTES_TXN_16BIT   4

◆ AD4692_N_BYTES_TXN_24BIT

#define AD4692_N_BYTES_TXN_24BIT   5

◆ AD4692_N_BYTES_TXN_OFFSET

#define AD4692_N_BYTES_TXN_OFFSET   2

◆ AD4692_N_CNV_TOGGLES

#define AD4692_N_CNV_TOGGLES   2

◆ CS_CHANGE

#define CS_CHANGE   1

◆ PWM_PERIOD_TO_FREQUENCY

#define PWM_PERIOD_TO_FREQUENCY (   x)    (1E9 / x)

Enumeration Type Documentation

◆ ad4692_readback_options

AD4692 readback options.

Enumerator
AVERAGED_DATA 
ACCUMULATOR_DATA 

◆ ad4692_sequencer_modes

AD4692 sequencer modes.

Enumerator
STANDARD_SEQUENCER 
ADVANCED_SEQUENCER 

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

◆ ad4692_acc_count

uint8_t ad4692_acc_count[]
extern

◆ ad4692_active_channels

uint8_t ad4692_active_channels[]
extern

◆ ad4692_conversion_flag

volatile bool ad4692_conversion_flag
extern

◆ ad4692_data_transfer_cnv_burst_mode

struct ad4692_data_transfer_system ad4692_data_transfer_cnv_burst_mode
extern

◆ ad4692_data_transfer_cnv_clock_mode

struct ad4692_data_transfer_system ad4692_data_transfer_cnv_clock_mode
extern

◆ ad4692_data_transfer_manual_mode

struct ad4692_data_transfer_system ad4692_data_transfer_manual_mode
extern

◆ ad4692_data_transfer_spi_burst_mode

struct ad4692_data_transfer_system ad4692_data_transfer_spi_burst_mode
extern

◆ ad4692_hw_trig_desc

struct iio_hw_trig* ad4692_hw_trig_desc
extern

◆ ad4692_osc_freq_id

enum ad4692_int_osc_sel ad4692_osc_freq_id
extern

◆ ad4692_readback_option

enum ad4692_readback_options ad4692_readback_option
extern

◆ ad4692_sequencer_mode

enum ad4692_sequencer_modes ad4692_sequencer_mode
extern

◆ buf_size_updated

volatile bool buf_size_updated
extern

◆ channel_mask

uint16_t channel_mask
extern

◆ channel_priorities

uint8_t channel_priorities[]
extern

◆ n_bytes_per_transaction

uint8_t n_bytes_per_transaction
extern

◆ n_data_bytes

uint8_t n_data_bytes
extern

◆ num_of_active_channels

uint8_t num_of_active_channels
extern