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

Header file for the ad7689 driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no-os/spi.h"
Include dependency graph for ad7689.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad7689_config
 AD7689 configuration. More...
 
struct  ad7689_init_param
 
struct  ad7689_dev
 

Macros

#define AD7689_CFG_CFG_MSK   BIT(13)
 
#define AD7689_CFG_INCC_MSK   GENMASK(12,10)
 
#define AD7689_CFG_INX_MSK   GENMASK(9,7)
 
#define AD7689_CFG_BW_MSK   BIT(6)
 
#define AD7689_CFG_REF_MSK   GENMASK(5,3)
 
#define AD7689_CFG_SEQ_MSK   GENMASK(2,1)
 
#define AD7689_CFG_RB_MSK   BIT(0)
 

Enumerations

enum  ad7689_device_id {
  ID_AD7689,
  ID_AD7682,
  ID_AD7949,
  ID_AD7699
}
 Device ID definitions. More...
 
enum  ad7689_incc {
  AD7689_BIPOLAR_DIFFERENTIAL_PAIRS = 0x1,
  AD7689_BIPOLAR_COM,
  AD7689_TEMPERATURE_SENSOR,
  AD7689_UNIPOLAR_DIFFERENTIAL_PAIRS = 0x5,
  AD7689_UNIPOLAR_COM,
  AD7689_UNIPOLAR_GND
}
 Input channel configuration. More...
 
enum  ad7689_bw {
  AD7689_BW_QUARTER,
  AD7689_BW_FULL
}
 Low-pass filter bandwidth selection. More...
 
enum  ad7689_ref {
  AD7689_REF_INTERNAL_2p5V,
  AD7689_REF_INTERNAL_4p096V,
  AD7689_REF_EXTERNAL_TEMP,
  AD7689_REF_EXTERNAL_TEMP_IBUF,
  AD7689_REF_EXTERNAL = 0x6,
  AD7689_REF_IBUF
}
 Reference/buffer selection. More...
 
enum  ad7689_seq {
  AD7689_SEQ_DISABLE,
  AD7689_SEQ_UPDATE_CFG,
  AD7689_SEQ_SCAN_ALL_THEN_TEMP,
  AD7689_SEQ_SCAN_ALL
}
 Channel sequencer configuration. More...
 

Functions

int32_t ad7689_init (struct ad7689_dev **dev, struct ad7689_init_param *init_param)
 Initialize the ad7689 driver and create a descriptor. More...
 
int32_t ad7689_write_config (struct ad7689_dev *dev, struct ad7689_config *config)
 Write the device's CFG register. More...
 
int32_t ad7689_read_config (struct ad7689_dev *dev, struct ad7689_config *config)
 Read the device's CFG register. More...
 
int32_t ad7689_read (struct ad7689_dev *dev, uint16_t *data, uint32_t nb_samples)
 Read ADC samples. More...
 
int32_t ad7689_remove (struct ad7689_dev *dev)
 Remove the driver's descriptor by freeing the associated resources. More...
 

Detailed Description

Header file for the ad7689 driver.

Author
Darius Berghe (dariu.nosp@m.s.be.nosp@m.rghe@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2021(c) Analog Devices, Inc.

All rights reserved.

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

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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

◆ AD7689_CFG_BW_MSK

#define AD7689_CFG_BW_MSK   BIT(6)

◆ AD7689_CFG_CFG_MSK

#define AD7689_CFG_CFG_MSK   BIT(13)

◆ AD7689_CFG_INCC_MSK

#define AD7689_CFG_INCC_MSK   GENMASK(12,10)

◆ AD7689_CFG_INX_MSK

#define AD7689_CFG_INX_MSK   GENMASK(9,7)

◆ AD7689_CFG_RB_MSK

#define AD7689_CFG_RB_MSK   BIT(0)

◆ AD7689_CFG_REF_MSK

#define AD7689_CFG_REF_MSK   GENMASK(5,3)

◆ AD7689_CFG_SEQ_MSK

#define AD7689_CFG_SEQ_MSK   GENMASK(2,1)

Enumeration Type Documentation

◆ ad7689_bw

enum ad7689_bw

Low-pass filter bandwidth selection.

Enumerator
AD7689_BW_QUARTER 

1⁄4 of BW, uses an additional series resistor to further bandwidth limit the noise. Maximum throughput must be reduced to 1⁄4.

AD7689_BW_FULL 

Full bandwidth.

◆ ad7689_device_id

Device ID definitions.

Enumerator
ID_AD7689 

16-Bit, 8-Channel, 250 kSPS PulSAR ADC

ID_AD7682 

16-Bit, 4-Channel, 250 kSPS PulSAR ADC

ID_AD7949 

14-Bit, 8-Channel, 250 kSPS PulSAR ADC

ID_AD7699 

16-Bit, 8-Channel, 500 kSPS PulSAR ADC

◆ ad7689_incc

Input channel configuration.

Enumerator
AD7689_BIPOLAR_DIFFERENTIAL_PAIRS 

Bipolar differential pairs; INx− referenced to VREF/2 ± 0.1 V.

AD7689_BIPOLAR_COM 

Bipolar; INx referenced to COM = V REF /2 ± 0.1 V.

AD7689_TEMPERATURE_SENSOR 

Temperature sensor.

AD7689_UNIPOLAR_DIFFERENTIAL_PAIRS 

Unipolar differential pairs; INx− referenced to GND ± 0.1 V.

AD7689_UNIPOLAR_COM 

Unipolar, INx referenced to COM = GND ± 0.1 V.

AD7689_UNIPOLAR_GND 

Unipolar, INx referenced to GND.

◆ ad7689_ref

enum ad7689_ref

Reference/buffer selection.

Enumerator
AD7689_REF_INTERNAL_2p5V 

Internal reference and temperature sensor enabled. REF = 2.5 V buffered output.

AD7689_REF_INTERNAL_4p096V 

Internal reference and temperature sensor enabled. REF = 4.096 V buffered output.

AD7689_REF_EXTERNAL_TEMP 

Use external reference. Temperature sensor enabled. Internal buffer disabled.

AD7689_REF_EXTERNAL_TEMP_IBUF 

Use external reference. Internal buffer and temperature sensor enabled.

AD7689_REF_EXTERNAL 

Use external reference. Internal reference, internal buffer, and temperature sensor disabled.

AD7689_REF_IBUF 

Use external reference. Internal buffer enabled. Internal reference and temperature sensor disabled.

◆ ad7689_seq

enum ad7689_seq

Channel sequencer configuration.

Enumerator
AD7689_SEQ_DISABLE 

Disable sequencer.

AD7689_SEQ_UPDATE_CFG 

Update configuration during sequence.

AD7689_SEQ_SCAN_ALL_THEN_TEMP 

Scan IN0 to INX, then temperature.

AD7689_SEQ_SCAN_ALL 

Scan IN0 to INX.

Function Documentation

◆ ad7689_init()

int32_t ad7689_init ( struct ad7689_dev **  dev,
struct ad7689_init_param init_param 
)

Initialize the ad7689 driver and create a descriptor.

Parameters
dev- Device descriptor to create.
init_param- Initialization parameters.
Returns
Returns negative error code or SUCCESS in case of success. Example: -EINVAL - Bad input parameters. -ENOMEM - Failed to allocate memory. SUCCESS - No errors encountered.

◆ ad7689_read()

int32_t ad7689_read ( struct ad7689_dev dev,
uint16_t *  data,
uint32_t  nb_samples 
)

Read ADC samples.

This function uses the RAC mode to perform the SPI transactions.

Parameters
dev- Device descriptor.
data- pointer to a large enough buffer where the data gets stored.
nb_samples- Number of samples to read.
Returns
Returns negative error code or SUCCESS in case of success. Example: -EINVAL - Bad input parameters. SUCCESS - No errors encountered.

◆ ad7689_read_config()

int32_t ad7689_read_config ( struct ad7689_dev dev,
struct ad7689_config config 
)

Read the device's CFG register.

If the readback is enabled when making this call, one SPI transaction is enough to retrieve the CFG register.

If the readback is disabled when making this call, it is temporarily enabled, then disabled back. 3 SPI transactions are needed to retrieve the CFG register.

Parameters
dev- Device descriptor.
config- pointer to location where the read configuration gets stored.
Returns
Returns negative error code or SUCCESS in case of success. Example: -EINVAL - Bad input parameters. SUCCESS - No errors encountered.

◆ ad7689_remove()

int32_t ad7689_remove ( struct ad7689_dev dev)

Remove the driver's descriptor by freeing the associated resources.

Parameters
dev- Device descriptor.
Returns
Returns negative error code or SUCCESS in case of success. Example: -EINVAL - Bad input parameters. SUCCESS - No errors encountered.

◆ ad7689_write_config()

int32_t ad7689_write_config ( struct ad7689_dev dev,
struct ad7689_config config 
)

Write the device's CFG register.

Parameters
dev- Device descriptor.
config- Configuration to write.
Returns
Returns negative error code or SUCCESS in case of success. Example: -EINVAL - Bad input parameters. SUCCESS - No errors encountered.
Here is the caller graph for this function: