no-OS
Classes | Macros | Enumerations | Functions
ad7606.h File Reference

Header file for the ad7606 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_delay.h"
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
#include "no_os_pwm.h"
#include "clk_axi_clkgen.h"
Include dependency graph for ad7606.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad7606_config
 AD7606_REG_CONFIG configuration parameters. More...
 
struct  ad7606_range
 Operation range as specified in datasheet (in uV) More...
 
struct  ad7606_oversampling
 
struct  ad7606_digital_diag
 Oversampling settings. More...
 
struct  ad7606_axi_init_param
 AXI driver(s) initialization parameters. More...
 
struct  ad7606_init_param
 Device driver initialization parameters. More...
 

Macros

#define AD7606_REG_STATUS   0x01
 
#define AD7606_REG_CONFIG   0x02
 
#define AD7606_REG_RANGE_CH_ADDR(ch)   (0x03 + ((ch) >> 1))
 
#define AD7606_REG_BANDWIDTH   0x07
 
#define AD7606_REG_OVERSAMPLING   0x08
 
#define AD7606_REG_GAIN_CH(ch)   (0x09 + (ch))
 
#define AD7606_REG_OFFSET_CH(ch)   (0x11 + (ch))
 
#define AD7606_REG_PHASE_CH(ch)   (0x19 + (ch))
 
#define AD7606_REG_DIGITAL_DIAG_ENABLE   0x21
 
#define AD7606_REG_DIGITAL_DIAG_ERR   0x22
 
#define AD7606_REG_OPEN_DETECT_ENABLE   0x23
 
#define AD7606_REG_OPEN_DETECTED   0x24
 
#define AD7606_REG_AIN_OV_UV_DIAG_ENABLE   0x25
 
#define AD7606_REG_AIN_OV_DIAG_ERROR   0x26
 
#define AD7606_REG_AIN_UV_DIAG_ERROR   0x27
 
#define AD7606_REG_DIAGNOSTIC_MUX_CH(ch)   (0x28 + ((ch) >> 1))
 
#define AD7606_REG_OPEN_DETECT_QUEUE   0x2C
 
#define AD7606_REG_CLK_FS_COUNTER   0x2D
 
#define AD7606_REG_CLK_OS_COUNTER   0x2E
 
#define AD7606_REG_ID   0x2F
 
#define AD7606_STATUS_CHANNEL_MSK   NO_OS_GENMASK(2,0)
 
#define AD7606_AIN_UV_ERR_MSK   NO_OS_BIT(3)
 
#define AD7606_AIN_OV_ERR_MSK   NO_OS_BIT(4)
 
#define AD7606_OPEN_DETECTED_MSK   NO_OS_BIT(5)
 
#define AD7606_DIGITAL_ERROR_MSK   NO_OS_BIT(6)
 
#define AD7606_RESET_DETECT_MSK   NO_OS_BIT(7)
 
#define AD7606_CONFIG_OPERATION_MODE_MSK   NO_OS_GENMASK(1,0)
 
#define AD7606_CONFIG_DOUT_FORMAT_MSK   NO_OS_GENMASK(4,3)
 
#define AD7606_CONFIG_EXT_OS_CLOCK_MSK   NO_OS_BIT(5)
 
#define AD7606_CONFIG_STATUS_HEADER_MSK   NO_OS_BIT(6)
 
#define AD7606_RANGE_CH_MSK(ch)   (NO_OS_GENMASK(3, 0) << (4 * ((ch) % 2)))
 
#define AD7606_RANGE_CH_MODE(ch, mode)   ((NO_OS_GENMASK(3, 0) & mode) << (4 * ((ch) % 2)))
 
#define AD7606_OS_PAD_MSK   NO_OS_GENMASK(7,4)
 
#define AD7606_OS_RATIO_MSK   NO_OS_GENMASK(3,0)
 
#define AD7606_ID_DEVICE_ID_MSK   NO_OS_GENMASK(7,4)
 
#define AD7606_ID_SILICON_REVISION_MSK   NO_OS_GENMASK(3,0)
 
#define AD7606_GAIN_MSK   NO_OS_GENMASK(5,0)
 
#define AD7606_ROM_CRC_ERR_EN_MSK   NO_OS_BIT(0)
 
#define AD7606_MM_CRC_ERR_EN_MSK   NO_OS_BIT(1)
 
#define AD7606_INT_CRC_ERR_EN_MSK   NO_OS_BIT(2)
 
#define AD7606_SPI_WRITE_ERR_EN_MSK   NO_OS_BIT(3)
 
#define AD7606_SPI_READ_ERR_EN_MSK   NO_OS_BIT(4)
 
#define AD7606_BUSY_STUCK_HIGH_ERR_EN_MSK   NO_OS_BIT(5)
 
#define AD7606_CLK_FS_OS_COUNTER_EN_MSK   NO_OS_BIT(6)
 
#define AD7606_INTERFACE_CHECK_EN_MSK   NO_OS_BIT(7)
 
#define AD7606_DIAGN_MUX_CH_MSK(ch)   (NO_OS_GENMASK(2, 0) << (3 * (ch & 0x1)))
 
#define AD7606_SERIAL_RD_FLAG_MSK(x)   (NO_OS_BIT(6) | ((x) & 0x3F))
 
#define AD7606_SERIAL_WR_FLAG_MSK(x)   ((x) & 0x3F)
 
#define AD7606_PARALLEL_RD_FLAG_MSK(x)   (NO_OS_BIT(7) | ((x) & 0x7F))
 
#define AD7606_PARALLEL_WR_FLAG_MSK(x)   ((x) & 0x7F)
 
#define AD7606_MAX_CHANNELS   8
 

Enumerations

enum  ad7606_device_id {
  ID_AD7605_4,
  ID_AD7606_4,
  ID_AD7606_6,
  ID_AD7606_8,
  ID_AD7606B,
  ID_AD7606C_16,
  ID_AD7606C_18,
  ID_AD7608,
  ID_AD7609
}
 Device ID definitions. More...
 
enum  ad7606_osr {
  AD7606_OSR_1,
  AD7606_OSR_2,
  AD7606_OSR_4,
  AD7606_OSR_8,
  AD7606_OSR_16,
  AD7606_OSR_32,
  AD7606_OSR_64,
  AD7606_OSR_128,
  AD7606_OSR_256
}
 Oversampling ratio. More...
 
enum  ad7606_op_mode {
  AD7606_NORMAL,
  AD7606_STANDBY,
  AD7606_AUTOSTANDBY,
  AD7606_SHUTDOWN
}
 Operation mode. More...
 
enum  ad7606_dout_format {
  AD7606_1_DOUT,
  AD7606_2_DOUT,
  AD7606_4_DOUT,
  AD7606_8_DOUT
}
 Number of DOUT lines. More...
 
enum  ad7606_range_type {
  AD7606_HW_RANGE,
  AD7606_SW_RANGE_SINGLE_ENDED_UNIPOLAR,
  AD7606_SW_RANGE_SINGLE_ENDED_BIPOLAR,
  AD7606_SW_RANGE_DIFFERENTIAL_BIPOLAR
}
 Type of range for this channel. More...
 

Functions

const struct ad7606_rangead7606_get_ch_ranges (struct ad7606_dev *dev, uint8_t ch, uint32_t *num_ranges)
 Get the available channel ranges for the given channel. More...
 
int32_t ad7606_capture_pre_enable (struct ad7606_dev *dev)
 Prepares buffer capture for an AXI SPI Engine or AXI Parallel interface. More...
 
void ad7606_capture_post_disable (struct ad7606_dev *dev)
 Disables buffer capture for an AXI SPI Engine or AXI Parallel interface. More...
 
bool ad7606_sw_mode_enabled (struct ad7606_dev *dev)
 Returns true if SW mode is enabled. More...
 
int32_t ad7606_get_channels_number (struct ad7606_dev *dev)
 Returns the number of channels this ADC has. More...
 
int32_t ad7606_reg_read (struct ad7606_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
 Write a device register via SPI or AXI Parallel core. More...
 
int32_t ad7606_reg_write (struct ad7606_dev *dev, uint8_t reg_addr, uint8_t reg_data)
 Write a device register via SPI or AXI Parallel core. More...
 
int32_t ad7606_write_mask (struct ad7606_dev *dev, uint32_t addr, uint32_t mask, uint32_t val)
 
int32_t ad7606_spi_data_read (struct ad7606_dev *dev, uint32_t *data)
 Read conversion data. More...
 
int32_t ad7606_read_samples (struct ad7606_dev *dev, uint32_t *data, uint32_t samples)
 Read muliple raw samples from device. More...
 
int32_t ad7606_convst (struct ad7606_dev *dev)
 Toggle the CONVST pin to start a conversion. More...
 
int32_t ad7606_reset (struct ad7606_dev *dev)
 Reset the device by toggling the reset GPIO. More...
 
int32_t ad7606_set_oversampling (struct ad7606_dev *dev, struct ad7606_oversampling oversampling)
 Set the oversampling ratio. More...
 
int32_t ad7606_get_oversampling (struct ad7606_dev *dev, struct ad7606_oversampling *oversampling)
 Get the oversampling ratio. More...
 
int32_t ad7606_get_ch_scale (struct ad7606_dev *dev, uint8_t ch, double *scale)
 Get the value of scale for the channel. More...
 
int32_t ad7606_get_resolution_bits (struct ad7606_dev *dev)
 Get the resolution bits of this device. More...
 
int32_t ad7606_set_ch_range (struct ad7606_dev *dev, uint8_t ch, struct ad7606_range range)
 Set the channel operation range. More...
 
int32_t ad7606_set_ch_offset (struct ad7606_dev *dev, uint8_t ch, int8_t offset)
 Set the channel offset. More...
 
int32_t ad7606_set_ch_phase (struct ad7606_dev *dev, uint8_t ch, uint8_t phase)
 Set the channel phase. More...
 
int32_t ad7606_set_ch_gain (struct ad7606_dev *dev, uint8_t ch, uint8_t gain)
 Set the channel gain. More...
 
int32_t ad7606_set_config (struct ad7606_dev *dev, struct ad7606_config config)
 Set the device config register. More...
 
int32_t ad7606_set_digital_diag (struct ad7606_dev *dev, struct ad7606_digital_diag diag)
 Set the device digital diagnostics configuration. More...
 
int32_t ad7606_init (struct ad7606_dev **device, struct ad7606_init_param *init_param)
 Initialize the ad7606 device structure. More...
 
int32_t ad7606_data_correction_serial (struct ad7606_dev *dev, uint32_t *buf, int32_t *data, uint8_t *status)
 
int32_t ad7606_remove (struct ad7606_dev *dev)
 Free any resource used by the driver. More...
 

Detailed Description

Header file for the ad7606 Driver.

Author
Stefan Popa (stefa.nosp@m.n.po.nosp@m.pa@an.nosp@m.alog.nosp@m..com)
Darius Berghe (dariu.nosp@m.s.be.nosp@m.rghe@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2019, 2021(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ AD7606_AIN_OV_ERR_MSK

#define AD7606_AIN_OV_ERR_MSK   NO_OS_BIT(4)

◆ AD7606_AIN_UV_ERR_MSK

#define AD7606_AIN_UV_ERR_MSK   NO_OS_BIT(3)

◆ AD7606_BUSY_STUCK_HIGH_ERR_EN_MSK

#define AD7606_BUSY_STUCK_HIGH_ERR_EN_MSK   NO_OS_BIT(5)

◆ AD7606_CLK_FS_OS_COUNTER_EN_MSK

#define AD7606_CLK_FS_OS_COUNTER_EN_MSK   NO_OS_BIT(6)

◆ AD7606_CONFIG_DOUT_FORMAT_MSK

#define AD7606_CONFIG_DOUT_FORMAT_MSK   NO_OS_GENMASK(4,3)

◆ AD7606_CONFIG_EXT_OS_CLOCK_MSK

#define AD7606_CONFIG_EXT_OS_CLOCK_MSK   NO_OS_BIT(5)

◆ AD7606_CONFIG_OPERATION_MODE_MSK

#define AD7606_CONFIG_OPERATION_MODE_MSK   NO_OS_GENMASK(1,0)

◆ AD7606_CONFIG_STATUS_HEADER_MSK

#define AD7606_CONFIG_STATUS_HEADER_MSK   NO_OS_BIT(6)

◆ AD7606_DIAGN_MUX_CH_MSK

#define AD7606_DIAGN_MUX_CH_MSK (   ch)    (NO_OS_GENMASK(2, 0) << (3 * (ch & 0x1)))

◆ AD7606_DIGITAL_ERROR_MSK

#define AD7606_DIGITAL_ERROR_MSK   NO_OS_BIT(6)

◆ AD7606_GAIN_MSK

#define AD7606_GAIN_MSK   NO_OS_GENMASK(5,0)

◆ AD7606_ID_DEVICE_ID_MSK

#define AD7606_ID_DEVICE_ID_MSK   NO_OS_GENMASK(7,4)

◆ AD7606_ID_SILICON_REVISION_MSK

#define AD7606_ID_SILICON_REVISION_MSK   NO_OS_GENMASK(3,0)

◆ AD7606_INT_CRC_ERR_EN_MSK

#define AD7606_INT_CRC_ERR_EN_MSK   NO_OS_BIT(2)

◆ AD7606_INTERFACE_CHECK_EN_MSK

#define AD7606_INTERFACE_CHECK_EN_MSK   NO_OS_BIT(7)

◆ AD7606_MAX_CHANNELS

#define AD7606_MAX_CHANNELS   8

◆ AD7606_MM_CRC_ERR_EN_MSK

#define AD7606_MM_CRC_ERR_EN_MSK   NO_OS_BIT(1)

◆ AD7606_OPEN_DETECTED_MSK

#define AD7606_OPEN_DETECTED_MSK   NO_OS_BIT(5)

◆ AD7606_OS_PAD_MSK

#define AD7606_OS_PAD_MSK   NO_OS_GENMASK(7,4)

◆ AD7606_OS_RATIO_MSK

#define AD7606_OS_RATIO_MSK   NO_OS_GENMASK(3,0)

◆ AD7606_PARALLEL_RD_FLAG_MSK

#define AD7606_PARALLEL_RD_FLAG_MSK (   x)    (NO_OS_BIT(7) | ((x) & 0x7F))

◆ AD7606_PARALLEL_WR_FLAG_MSK

#define AD7606_PARALLEL_WR_FLAG_MSK (   x)    ((x) & 0x7F)

◆ AD7606_RANGE_CH_MODE

#define AD7606_RANGE_CH_MODE (   ch,
  mode 
)    ((NO_OS_GENMASK(3, 0) & mode) << (4 * ((ch) % 2)))

◆ AD7606_RANGE_CH_MSK

#define AD7606_RANGE_CH_MSK (   ch)    (NO_OS_GENMASK(3, 0) << (4 * ((ch) % 2)))

◆ AD7606_REG_AIN_OV_DIAG_ERROR

#define AD7606_REG_AIN_OV_DIAG_ERROR   0x26

◆ AD7606_REG_AIN_OV_UV_DIAG_ENABLE

#define AD7606_REG_AIN_OV_UV_DIAG_ENABLE   0x25

◆ AD7606_REG_AIN_UV_DIAG_ERROR

#define AD7606_REG_AIN_UV_DIAG_ERROR   0x27

◆ AD7606_REG_BANDWIDTH

#define AD7606_REG_BANDWIDTH   0x07

◆ AD7606_REG_CLK_FS_COUNTER

#define AD7606_REG_CLK_FS_COUNTER   0x2D

◆ AD7606_REG_CLK_OS_COUNTER

#define AD7606_REG_CLK_OS_COUNTER   0x2E

◆ AD7606_REG_CONFIG

#define AD7606_REG_CONFIG   0x02

◆ AD7606_REG_DIAGNOSTIC_MUX_CH

#define AD7606_REG_DIAGNOSTIC_MUX_CH (   ch)    (0x28 + ((ch) >> 1))

◆ AD7606_REG_DIGITAL_DIAG_ENABLE

#define AD7606_REG_DIGITAL_DIAG_ENABLE   0x21

◆ AD7606_REG_DIGITAL_DIAG_ERR

#define AD7606_REG_DIGITAL_DIAG_ERR   0x22

◆ AD7606_REG_GAIN_CH

#define AD7606_REG_GAIN_CH (   ch)    (0x09 + (ch))

◆ AD7606_REG_ID

#define AD7606_REG_ID   0x2F

◆ AD7606_REG_OFFSET_CH

#define AD7606_REG_OFFSET_CH (   ch)    (0x11 + (ch))

◆ AD7606_REG_OPEN_DETECT_ENABLE

#define AD7606_REG_OPEN_DETECT_ENABLE   0x23

◆ AD7606_REG_OPEN_DETECT_QUEUE

#define AD7606_REG_OPEN_DETECT_QUEUE   0x2C

◆ AD7606_REG_OPEN_DETECTED

#define AD7606_REG_OPEN_DETECTED   0x24

◆ AD7606_REG_OVERSAMPLING

#define AD7606_REG_OVERSAMPLING   0x08

◆ AD7606_REG_PHASE_CH

#define AD7606_REG_PHASE_CH (   ch)    (0x19 + (ch))

◆ AD7606_REG_RANGE_CH_ADDR

#define AD7606_REG_RANGE_CH_ADDR (   ch)    (0x03 + ((ch) >> 1))

◆ AD7606_REG_STATUS

#define AD7606_REG_STATUS   0x01

◆ AD7606_RESET_DETECT_MSK

#define AD7606_RESET_DETECT_MSK   NO_OS_BIT(7)

◆ AD7606_ROM_CRC_ERR_EN_MSK

#define AD7606_ROM_CRC_ERR_EN_MSK   NO_OS_BIT(0)

◆ AD7606_SERIAL_RD_FLAG_MSK

#define AD7606_SERIAL_RD_FLAG_MSK (   x)    (NO_OS_BIT(6) | ((x) & 0x3F))

◆ AD7606_SERIAL_WR_FLAG_MSK

#define AD7606_SERIAL_WR_FLAG_MSK (   x)    ((x) & 0x3F)

◆ AD7606_SPI_READ_ERR_EN_MSK

#define AD7606_SPI_READ_ERR_EN_MSK   NO_OS_BIT(4)

◆ AD7606_SPI_WRITE_ERR_EN_MSK

#define AD7606_SPI_WRITE_ERR_EN_MSK   NO_OS_BIT(3)

◆ AD7606_STATUS_CHANNEL_MSK

#define AD7606_STATUS_CHANNEL_MSK   NO_OS_GENMASK(2,0)

Enumeration Type Documentation

◆ ad7606_device_id

Device ID definitions.

Enumerator
ID_AD7605_4 

4-Channel DAS with 16-Bit, Bipolar Input, Simultaneous Sampling ADC

ID_AD7606_4 

4-Channel DAS with 16-Bit, Bipolar Input, Simultaneous Sampling ADC

ID_AD7606_6 

6-Channel DAS with 16-Bit, Bipolar Input, Simultaneous Sampling ADC

ID_AD7606_8 

8-Channel DAS with 16-Bit, Bipolar Input, Simultaneous Sampling ADC

ID_AD7606B 

8-Channel DAS with 16-Bit, 800 kSPS, Bipolar Input, Simultaneous Sampling ADC

ID_AD7606C_16 

8-Channel DAS with 16-Bit, 1 MSPS, Bipolar Input, Simultaneous Sampling ADC

ID_AD7606C_18 

8-Channel DAS with 18-Bit, 1 MSPS, Bipolar Input, Simultaneous Sampling ADC

ID_AD7608 

8-Channel DAS with 18-Bit, Bipolar, Simultaneous Sampling ADC

ID_AD7609 

8-Channel Differential DAS with 18-Bit, Bipolar, Simultaneous Sampling ADC

◆ ad7606_dout_format

Number of DOUT lines.

Enumerator
AD7606_1_DOUT 

DOUT A line is used

AD7606_2_DOUT 

DOUT A,B lines are used.

AD7606_4_DOUT 

DOUT A,B,C,D lines are used.

AD7606_8_DOUT 

DOUT A,B,C,D,E,F,G,H lines are used.

◆ ad7606_op_mode

Operation mode.

Enumerator
AD7606_NORMAL 

Normal operation mode

AD7606_STANDBY 

Standby mode, all the PGAs, and all the SAR ADCs enter a low power mode

AD7606_AUTOSTANDBY 

Autostandby mode, available only in software mode

AD7606_SHUTDOWN 

Shutdown mode, all circuitry is powered down

◆ ad7606_osr

enum ad7606_osr

Oversampling ratio.

Enumerator
AD7606_OSR_1 

Oversample by 1

AD7606_OSR_2 

Oversample by 2

AD7606_OSR_4 

Oversample by 4

AD7606_OSR_8 

Oversample by 8

AD7606_OSR_16 

Oversample by 16

AD7606_OSR_32 

Oversample by 32

AD7606_OSR_64 

Oversample by 64

AD7606_OSR_128 

Oversample by 128, available for chips that have software mode only

AD7606_OSR_256 

Oversample by 256, available for chips that have software mode only

◆ ad7606_range_type

Type of range for this channel.

Enumerator
AD7606_HW_RANGE 
AD7606_SW_RANGE_SINGLE_ENDED_UNIPOLAR 
AD7606_SW_RANGE_SINGLE_ENDED_BIPOLAR 
AD7606_SW_RANGE_DIFFERENTIAL_BIPOLAR 

Function Documentation

◆ ad7606_capture_post_disable()

void ad7606_capture_post_disable ( struct ad7606_dev dev)

Disables buffer capture for an AXI SPI Engine or AXI Parallel interface.

Parameters
dev- The device structure.
Here is the caller graph for this function:

◆ ad7606_capture_pre_enable()

int32_t ad7606_capture_pre_enable ( struct ad7606_dev dev)

Prepares buffer capture for an AXI SPI Engine or AXI Parallel interface.

Parameters
dev- The device structure.
Returns
0 on success, or negative error code.
Here is the caller graph for this function:

◆ ad7606_convst()

int32_t ad7606_convst ( struct ad7606_dev dev)

Toggle the CONVST pin to start a conversion.

If needed, this function also puts the device in ADC reading mode by a write at address zero.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EIO - SPI communication error. -EIO - CONVST GPIO not available. 0 - No errors encountered.

◆ ad7606_data_correction_serial()

int32_t ad7606_data_correction_serial ( struct ad7606_dev dev,
uint32_t *  buf,
int32_t *  data,
uint8_t *  status 
)

◆ ad7606_get_ch_ranges()

const struct ad7606_range* ad7606_get_ch_ranges ( struct ad7606_dev dev,
uint8_t  ch,
uint32_t *  num_ranges 
)

Get the available channel ranges for the given channel.

Parameters
dev- The device structure.
ch- The channel number
num_ranges- A pointer to store the number of returned ranges.
Returns
A pointer to the ranges of the devices, or NULL if 'dev' or 'num_ranges' is NULL.

◆ ad7606_get_ch_scale()

int32_t ad7606_get_ch_scale ( struct ad7606_dev dev,
uint8_t  ch,
double *  scale 
)

Get the value of scale for the channel.

Parameters
dev- The device structure.
ch- The channel number.
scale- Pointer where to store the channel scale.
Returns
ret - return code. Example: -EINVAL - Invalid input. 0 - No errors encountered.
Here is the caller graph for this function:

◆ ad7606_get_channels_number()

int32_t ad7606_get_channels_number ( struct ad7606_dev dev)

Returns the number of channels this ADC has.

Parameters
dev- The device structure.
Returns
ret - number of channels or -EINVAL if 'dev' is null.

◆ ad7606_get_oversampling()

int32_t ad7606_get_oversampling ( struct ad7606_dev dev,
struct ad7606_oversampling oversampling 
)

Get the oversampling ratio.

Return the current oversampling ratio.

Parameters
dev- The device structure.
oversampling- Pointer to an object where to store oversampling settings.
Returns
ret - return code. Example: -EINVAL is 'dev' or 'oversampling' are NULL. 0 - No errors encountered.

◆ ad7606_get_resolution_bits()

int32_t ad7606_get_resolution_bits ( struct ad7606_dev dev)

Get the resolution bits of this device.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - Invalid input. The number of resolution bits for this device.
Here is the caller graph for this function:

◆ ad7606_init()

int32_t ad7606_init ( struct ad7606_dev **  device,
struct ad7606_init_param init_param 
)

Initialize the ad7606 device structure.

Performs memory allocation of the device structure.

Parameters
device- Pointer to location of device structure to write.
init_param- Pointer to configuration of the driver.
Returns
ret - return code. Example: -ENOMEM - Memory allocation error. -EIO - SPI communication error. -EIO - GPIO initialization error. -ENODEV - Unexpected device id. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.
Here is the caller graph for this function:

◆ ad7606_read_samples()

int32_t ad7606_read_samples ( struct ad7606_dev dev,
uint32_t *  data,
uint32_t  samples 
)

Read muliple raw samples from device.

This function performs a series of conversion starts and then proceeds to reading the conversion data (after each conversion).

Parameters
dev- The device structure.
data- Pointer to location of buffer where to store the data.
samples- Number of samples to read
Returns
ret - return code. Example: -EIO - SPI communication error. -ETIME - Timeout while waiting for the BUSY signal. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.
Here is the caller graph for this function:

◆ ad7606_reg_read()

int32_t ad7606_reg_read ( struct ad7606_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_data 
)

Write a device register via SPI or AXI Parallel core.

The behavior of this function varies slightly depending on whether the operation is done via SPI or AXI core.

Parameters
dev- The device structure.
reg_addr- Register address in device memory.
reg_data- Value to write to register.
Returns
ret - return code. Example: -EIO - SPI communication error. -ENOTSUP - Device not in software mode. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.
Here is the caller graph for this function:

◆ ad7606_reg_write()

int32_t ad7606_reg_write ( struct ad7606_dev dev,
uint8_t  reg_addr,
uint8_t  reg_data 
)

Write a device register via SPI or AXI Parallel core.

The behavior of this function varies slightly depending on whether the operation is done via SPI or AXI core.

Parameters
dev- The device structure.
reg_addr- Register address in device memory.
reg_data- Value to write to register.
Returns
ret - return code. Example: -EIO - SPI communication error. -ENOTSUP - Device not in software mode. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.
Here is the caller graph for this function:

◆ ad7606_remove()

int32_t ad7606_remove ( struct ad7606_dev dev)

Free any resource used by the driver.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EIO - SPI communication error. 0 - No errors encountered.
Here is the caller graph for this function:

◆ ad7606_reset()

int32_t ad7606_reset ( struct ad7606_dev dev)

Reset the device by toggling the reset GPIO.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EIO - Reset GPIO not available. 0 - No errors encountered.

◆ ad7606_set_ch_gain()

int32_t ad7606_set_ch_gain ( struct ad7606_dev dev,
uint8_t  ch,
uint8_t  gain 
)

Set the channel gain.

Parameters
dev- The device structure.
ch- Channel number (0-7).
gain- Gain calibration amount.
Returns
ret - return code. Example: -EIO - SPI communication error. -EINVAL - Invalid input. -ENOTSUP - Device not in software mode. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_set_ch_offset()

int32_t ad7606_set_ch_offset ( struct ad7606_dev dev,
uint8_t  ch,
int8_t  offset 
)

Set the channel offset.

The offset parameter is a signed 8-bit integer ranging from -128 to 127 to make it intuitive and user-friendly.

This offset gets converted to the register representation where 0x80 is calibration offset 0, 0x0 is calibration offset -128 and 0xFF is calibration offset 127, etc.

Parameters
dev- The device structure.
ch- Channel number (0-7).
offset- Offset calibration amount (-128...127).
Returns
ret - return code. Example: -EIO - SPI communication error. -EINVAL - Invalid input. -ENOTSUP - Device not in software mode. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_set_ch_phase()

int32_t ad7606_set_ch_phase ( struct ad7606_dev dev,
uint8_t  ch,
uint8_t  phase 
)

Set the channel phase.

Parameters
dev- The device structure.
ch- Channel number (0-7).
phase- Phase calibration amount.
Returns
ret - return code. Example: -EIO - SPI communication error. -EINVAL - Invalid input. -ENOTSUP - Device not in software mode. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_set_ch_range()

int32_t ad7606_set_ch_range ( struct ad7606_dev dev,
uint8_t  ch,
struct ad7606_range  range 
)

Set the channel operation range.

Parameters
dev- The device structure.
ch- Channel number (0-7).
range- Operation range.
Returns
ret - return code. Example: -EIO - SPI communication error. -EINVAL - Invalid input. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_set_config()

int32_t ad7606_set_config ( struct ad7606_dev dev,
struct ad7606_config  config 
)

Set the device config register.

Configuration structure affects the CONFIG register of the device.

Parameters
dev- The device structure.
config- Configuration structure.
Returns
ret - return code. Example: -EIO - SPI communication error. -EIO - GPIO not available. -EINVAL - Invalid input. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_set_digital_diag()

int32_t ad7606_set_digital_diag ( struct ad7606_dev dev,
struct ad7606_digital_diag  diag 
)

Set the device digital diagnostics configuration.

Digital diagnostics structure affects the DIGITAL_DIAG register of the device.

Parameters
dev- The device structure.
diag- Configuration structure.
Returns
ret - return code. Example: -EIO - SPI communication error. -ENOTSUP - Device not in software mode. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_set_oversampling()

int32_t ad7606_set_oversampling ( struct ad7606_dev dev,
struct ad7606_oversampling  oversampling 
)

Set the oversampling ratio.

In hardware mode, it silently sets AD7606_OSR_64 if higher oversampling is provided.

Parameters
dev- The device structure.
oversampling- Oversampling settings.
Returns
ret - return code. Example: -EIO - SPI communication error. -EBADMSG - CRC computation mismatch. 0 - No errors encountered.

◆ ad7606_spi_data_read()

int32_t ad7606_spi_data_read ( struct ad7606_dev dev,
uint32_t *  data 
)

Read conversion data.

This function performs CRC16 computation and checking if enabled in the device. If the status is enabled in device settings, each sample of data will contain status information in the lowest 8 bits.

The output buffer provided by the user should be as wide as to be able to contain 1 sample from each channel since this function reads conversion data across all channels.

Parameters
dev- The device structure.
data- Pointer to location of buffer where to store the data.
Returns
ret - return code. Example: -EIO - SPI communication error. -EBADMSG - CRC computation mismatch. -ENOTSUP - Device bits per sample not supported. 0 - No errors encountered.

◆ ad7606_sw_mode_enabled()

bool ad7606_sw_mode_enabled ( struct ad7606_dev dev)

Returns true if SW mode is enabled.

Parameters
dev- The device structure.
Returns
true if software mode is enabled, false otherwise.

◆ ad7606_write_mask()

int32_t ad7606_write_mask ( struct ad7606_dev dev,
uint32_t  addr,
uint32_t  mask,
uint32_t  val 
)