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

Header file of AD7616 Driver. More...

#include "no_os_gpio.h"
#include <stdint.h>
Include dependency graph for ad7616.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad7616_dev
 
struct  ad7616_init_param
 
struct  ad7616_conversion_result
 
struct  ad7616_sequencer_layer
 

Macros

#define AD7616_REG_PCORE_VERSION   0x400
 
#define AD7616_REG_ID   0x404
 
#define AD7616_REG_UP_SCRATCH   0x408
 
#define AD7616_REG_UP_IF_TYPE   0x40C
 
#define AD7616_REG_UP_CTRL   0x440
 
#define AD7616_REG_UP_CONV_RATE   0x444
 
#define AD7616_REG_UP_BURST_LENGTH   0x448
 
#define AD7616_REG_UP_READ_DATA   0x44C
 
#define AD7616_REG_UP_WRITE_DATA   0x450
 
#define AD7616_CTRL_RESETN   (1 << 0)
 
#define AD7616_CTRL_CNVST_EN   (1 << 1)
 
#define AD7616_REG_CONFIG   0x02
 
#define AD7616_REG_CHANNEL   0x03
 
#define AD7616_REG_INPUT_RANGE_A1   0x04
 
#define AD7616_REG_INPUT_RANGE_A2   0x05
 
#define AD7616_REG_INPUT_RANGE_B1   0x06
 
#define AD7616_REG_INPUT_RANGE_B2   0x07
 
#define AD7616_REG_SEQUENCER_STACK(x)   (0x20 + (x))
 
#define AD7616_SDEF   (1 << 7)
 
#define AD7616_BURSTEN(x)   ((x & 1) << 6)
 
#define AD7616_BURSTEN_MASK   (1 << 6)
 
#define AD7616_SEQEN(x)   ((x & 1) << 5)
 
#define AD7616_SEQEN_MASK   (1 << 5)
 
#define AD7616_OS(x)   (((x) & 0x7) << 2)
 
#define AD7616_STATUSEN   (1 << 1)
 
#define AD7616_STATUSEN_MASK   (1 << 1)
 
#define AD7616_CRCEN   (1 << 0)
 
#define AD7616_CRCEN_MASK   (1 << 0)
 
#define AD7616_CHA_MASK   0xF
 
#define AD7616_CHB_MASK   0xF0
 
#define AD7616_CHB_OFFSET   4
 
#define AD7616_CHANNELS_MASK   0xFF
 
#define AD7616_INPUT_RANGE(ch, x)   (((x) & 0x3) << (((ch) & 0x3) * 2))
 
#define AD7616_ADDR(x)   (((x) & 0x7F) << 9)
 
#define AD7616_SSREN   (1 << 8)
 
#define AD7616_BSEL(x)   (((x) & 0xF) << 4)
 
#define AD7616_ASEL(x)   (((x) & 0xF) << 0)
 
#define AD7616_STATUS_A(x)   (((x) & 0xF) << 12)
 
#define AD7616_STATUS_B(x)   (((x) & 0xF) << 8)
 
#define AD7616_STATUS_CRC(x)   (((x) & 0xFF) << 0)
 
#define AD7616_CHANNEL_A_SELF_TEST_VALUE   0xAAAA
 
#define AD7616_CHANNEL_B_SELF_TEST_VALUE   0x5555
 
#define AD7616_TRIGGER_PULSE_WIDTH_NS   50
 

Enumerations

enum  ad7616_mode {
  AD7616_SW,
  AD7616_HW
}
 
enum  ad7616_interface {
  AD7616_SERIAL,
  AD7616_PARALLEL
}
 
enum  ad7616_ch {
  AD7616_VA0,
  AD7616_VA1,
  AD7616_VA2,
  AD7616_VA3,
  AD7616_VA4,
  AD7616_VA5,
  AD7616_VA6,
  AD7616_VA7,
  AD7616_VA_VCC,
  AD7616_VA_ALDO,
  AD7616_VA_RESERVED1,
  AD7616_VA_SELF_TEST,
  AD7616_VA_RESERVED2,
  AD7616_VB0,
  AD7616_VB1,
  AD7616_VB2,
  AD7616_VB3,
  AD7616_VB4,
  AD7616_VB5,
  AD7616_VB6,
  AD7616_VB7,
  AD7616_VB_VCC,
  AD7616_VB_ALDO,
  AD7616_VB_RESERVED1,
  AD7616_VB_SELF_TEST,
  AD7616_VB_RESERVED2
}
 
enum  ad7616_range {
  AD7616_2V5 = 1,
  AD7616_5V = 2,
  AD7616_10V = 3
}
 
enum  ad7616_osr {
  AD7616_OSR_0,
  AD7616_OSR_2,
  AD7616_OSR_4,
  AD7616_OSR_8,
  AD7616_OSR_16,
  AD7616_OSR_32,
  AD7616_OSR_64,
  AD7616_OSR_128
}
 

Functions

int32_t ad7616_read (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 
int32_t ad7616_write (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 
int32_t ad7616_read_mask (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t *data)
 
int32_t ad7616_write_mask (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
 
int32_t ad7616_spi_read (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 
int32_t ad7616_spi_write (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 
int32_t ad7616_par_read (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 
int32_t ad7616_par_write (struct ad7616_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 
int32_t ad7616_reset (struct ad7616_dev *dev)
 
int32_t ad7616_set_range (struct ad7616_dev *dev, enum ad7616_ch ch, enum ad7616_range range)
 
int32_t ad7616_set_mode (struct ad7616_dev *dev, enum ad7616_mode mode)
 
int32_t ad7616_set_oversampling_ratio (struct ad7616_dev *dev, enum ad7616_osr osr)
 
int32_t ad7616_read_data_serial (struct ad7616_dev *dev, struct ad7616_conversion_result *results, uint32_t samples)
 Read conversion result from device, checking with CRC if enabled. More...
 
int32_t ad7616_read_data_parallel (struct ad7616_dev *dev, uint32_t *buf, uint32_t samples)
 Read from device in parallel mode. Enter register mode to read/write registers. More...
 
int32_t ad7616_core_setup (struct ad7616_dev *dev)
 
int32_t ad7616_setup (struct ad7616_dev **device, struct ad7616_init_param *init_param)
 
void ad7616_remove (struct ad7616_dev *device)
 
int32_t ad7616_read_channel_source (struct ad7616_dev *dev, enum ad7616_ch *ch_a, enum ad7616_ch *ch_b)
 Read the current selected channels. More...
 
int32_t ad7616_select_channel_source (struct ad7616_dev *dev, enum ad7616_ch ch)
 Select a new source for a channel. More...
 
int32_t ad7616_setup_sequencer (struct ad7616_dev *dev, struct ad7616_sequencer_layer *layers, uint32_t layers_nb, uint8_t burst)
 Setup the sequencer layers. More...
 
int32_t ad7616_disable_sequencer (struct ad7616_dev *dev)
 

Detailed Description

Header file of AD7616 Driver.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)

Copyright 2016(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

◆ AD7616_ADDR

#define AD7616_ADDR (   x)    (((x) & 0x7F) << 9)

◆ AD7616_ASEL

#define AD7616_ASEL (   x)    (((x) & 0xF) << 0)

◆ AD7616_BSEL

#define AD7616_BSEL (   x)    (((x) & 0xF) << 4)

◆ AD7616_BURSTEN

#define AD7616_BURSTEN (   x)    ((x & 1) << 6)

◆ AD7616_BURSTEN_MASK

#define AD7616_BURSTEN_MASK   (1 << 6)

◆ AD7616_CHA_MASK

#define AD7616_CHA_MASK   0xF

◆ AD7616_CHANNEL_A_SELF_TEST_VALUE

#define AD7616_CHANNEL_A_SELF_TEST_VALUE   0xAAAA

◆ AD7616_CHANNEL_B_SELF_TEST_VALUE

#define AD7616_CHANNEL_B_SELF_TEST_VALUE   0x5555

◆ AD7616_CHANNELS_MASK

#define AD7616_CHANNELS_MASK   0xFF

◆ AD7616_CHB_MASK

#define AD7616_CHB_MASK   0xF0

◆ AD7616_CHB_OFFSET

#define AD7616_CHB_OFFSET   4

◆ AD7616_CRCEN

#define AD7616_CRCEN   (1 << 0)

◆ AD7616_CRCEN_MASK

#define AD7616_CRCEN_MASK   (1 << 0)

◆ AD7616_CTRL_CNVST_EN

#define AD7616_CTRL_CNVST_EN   (1 << 1)

◆ AD7616_CTRL_RESETN

#define AD7616_CTRL_RESETN   (1 << 0)

◆ AD7616_INPUT_RANGE

#define AD7616_INPUT_RANGE (   ch,
 
)    (((x) & 0x3) << (((ch) & 0x3) * 2))

◆ AD7616_OS

#define AD7616_OS (   x)    (((x) & 0x7) << 2)

◆ AD7616_REG_CHANNEL

#define AD7616_REG_CHANNEL   0x03

◆ AD7616_REG_CONFIG

#define AD7616_REG_CONFIG   0x02

◆ AD7616_REG_ID

#define AD7616_REG_ID   0x404

◆ AD7616_REG_INPUT_RANGE_A1

#define AD7616_REG_INPUT_RANGE_A1   0x04

◆ AD7616_REG_INPUT_RANGE_A2

#define AD7616_REG_INPUT_RANGE_A2   0x05

◆ AD7616_REG_INPUT_RANGE_B1

#define AD7616_REG_INPUT_RANGE_B1   0x06

◆ AD7616_REG_INPUT_RANGE_B2

#define AD7616_REG_INPUT_RANGE_B2   0x07

◆ AD7616_REG_PCORE_VERSION

#define AD7616_REG_PCORE_VERSION   0x400

◆ AD7616_REG_SEQUENCER_STACK

#define AD7616_REG_SEQUENCER_STACK (   x)    (0x20 + (x))

◆ AD7616_REG_UP_BURST_LENGTH

#define AD7616_REG_UP_BURST_LENGTH   0x448

◆ AD7616_REG_UP_CONV_RATE

#define AD7616_REG_UP_CONV_RATE   0x444

◆ AD7616_REG_UP_CTRL

#define AD7616_REG_UP_CTRL   0x440

◆ AD7616_REG_UP_IF_TYPE

#define AD7616_REG_UP_IF_TYPE   0x40C

◆ AD7616_REG_UP_READ_DATA

#define AD7616_REG_UP_READ_DATA   0x44C

◆ AD7616_REG_UP_SCRATCH

#define AD7616_REG_UP_SCRATCH   0x408

◆ AD7616_REG_UP_WRITE_DATA

#define AD7616_REG_UP_WRITE_DATA   0x450

◆ AD7616_SDEF

#define AD7616_SDEF   (1 << 7)

◆ AD7616_SEQEN

#define AD7616_SEQEN (   x)    ((x & 1) << 5)

◆ AD7616_SEQEN_MASK

#define AD7616_SEQEN_MASK   (1 << 5)

◆ AD7616_SSREN

#define AD7616_SSREN   (1 << 8)

◆ AD7616_STATUS_A

#define AD7616_STATUS_A (   x)    (((x) & 0xF) << 12)

◆ AD7616_STATUS_B

#define AD7616_STATUS_B (   x)    (((x) & 0xF) << 8)

◆ AD7616_STATUS_CRC

#define AD7616_STATUS_CRC (   x)    (((x) & 0xFF) << 0)

◆ AD7616_STATUSEN

#define AD7616_STATUSEN   (1 << 1)

◆ AD7616_STATUSEN_MASK

#define AD7616_STATUSEN_MASK   (1 << 1)

◆ AD7616_TRIGGER_PULSE_WIDTH_NS

#define AD7616_TRIGGER_PULSE_WIDTH_NS   50

Enumeration Type Documentation

◆ ad7616_ch

enum ad7616_ch
Enumerator
AD7616_VA0 
AD7616_VA1 
AD7616_VA2 
AD7616_VA3 
AD7616_VA4 
AD7616_VA5 
AD7616_VA6 
AD7616_VA7 
AD7616_VA_VCC 
AD7616_VA_ALDO 
AD7616_VA_RESERVED1 
AD7616_VA_SELF_TEST 
AD7616_VA_RESERVED2 
AD7616_VB0 
AD7616_VB1 
AD7616_VB2 
AD7616_VB3 
AD7616_VB4 
AD7616_VB5 
AD7616_VB6 
AD7616_VB7 
AD7616_VB_VCC 
AD7616_VB_ALDO 
AD7616_VB_RESERVED1 
AD7616_VB_SELF_TEST 
AD7616_VB_RESERVED2 

◆ ad7616_interface

Enumerator
AD7616_SERIAL 
AD7616_PARALLEL 

◆ ad7616_mode

Enumerator
AD7616_SW 
AD7616_HW 

◆ ad7616_osr

enum ad7616_osr
Enumerator
AD7616_OSR_0 
AD7616_OSR_2 
AD7616_OSR_4 
AD7616_OSR_8 
AD7616_OSR_16 
AD7616_OSR_32 
AD7616_OSR_64 
AD7616_OSR_128 

◆ ad7616_range

Enumerator
AD7616_2V5 
AD7616_5V 
AD7616_10V 

Function Documentation

◆ ad7616_core_setup()

int32_t ad7616_core_setup ( struct ad7616_dev dev)
Here is the caller graph for this function:

◆ ad7616_disable_sequencer()

int32_t ad7616_disable_sequencer ( struct ad7616_dev dev)

◆ ad7616_par_read()

int32_t ad7616_par_read ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t *  reg_data 
)

PAR read from device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_par_write()

int32_t ad7616_par_write ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t  reg_data 
)

PAR write to device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_read()

int32_t ad7616_read ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t *  reg_data 
)

Read from device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.

◆ ad7616_read_channel_source()

int32_t ad7616_read_channel_source ( struct ad7616_dev dev,
enum ad7616_ch ch_a,
enum ad7616_ch ch_b 
)

Read the current selected channels.

Parameters
dev- The device structure
ch_a- Pointer to store the current source for channel A
ch_b- Pointer to store the current source for channel B
Returns
0 on success, an error code otherwise
Here is the caller graph for this function:

◆ ad7616_read_data_parallel()

int32_t ad7616_read_data_parallel ( struct ad7616_dev dev,
uint32_t *  buf,
uint32_t  samples 
)

Read from device in parallel mode. Enter register mode to read/write registers.

Parameters
dev- ad7616_dev device handler.
buf- data buffer.
samples- sample number.
Returns
0 in case of success, -1 otherwise.
Here is the caller graph for this function:

◆ ad7616_read_data_serial()

int32_t ad7616_read_data_serial ( struct ad7616_dev dev,
struct ad7616_conversion_result results,
uint32_t  samples 
)

Read conversion result from device, checking with CRC if enabled.

Parameters
dev- ad7616_dev device handler.
results- results buffer.
samples- sample number.
Returns
0 in case of success, -1 otherwise.
Here is the caller graph for this function:

◆ ad7616_read_mask()

int32_t ad7616_read_mask ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t  mask,
uint16_t *  data 
)

Read from device using a mask.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_remove()

void ad7616_remove ( struct ad7616_dev device)

◆ ad7616_reset()

int32_t ad7616_reset ( struct ad7616_dev dev)

Perform a full reset of the device.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_select_channel_source()

int32_t ad7616_select_channel_source ( struct ad7616_dev dev,
enum ad7616_ch  ch 
)

Select a new source for a channel.

Parameters
dev- The device structure.
ch- The new channel source
Returns
0 on success, an error code otherwise
Here is the caller graph for this function:

◆ ad7616_set_mode()

int32_t ad7616_set_mode ( struct ad7616_dev dev,
enum ad7616_mode  mode 
)

Set the operation mode (software or hardware).

Parameters
dev- The device structure.
mode- The operation mode. Accepted values: AD7616_SW AD7616_HW
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_set_oversampling_ratio()

int32_t ad7616_set_oversampling_ratio ( struct ad7616_dev dev,
enum ad7616_osr  osr 
)

Set the oversampling ratio.

Parameters
dev- The device structure.
osr- The oversampling ratio. Accepted values: AD7616_OSR_0 AD7616_OSR_2 AD7616_OSR_4 AD7616_OSR_8 AD7616_OSR_16 AD7616_OSR_32 AD7616_OSR_64 AD7616_OSR_128
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_set_range()

int32_t ad7616_set_range ( struct ad7616_dev dev,
enum ad7616_ch  ch,
enum ad7616_range  range 
)

Set the analog input range for the selected analog input channel.

Parameters
dev- The device structure.
ch- The channel number. Accepted values: AD7616_VA0 AD7616_VA1 AD7616_VA2 AD7616_VA3 AD7616_VA4 AD7616_VA5 AD7616_VA6 AD7616_VA7 AD7616_VB0 AD7616_VB1 AD7616_VB2 AD7616_VB3 AD7616_VB4 AD7616_VB5 AD7616_VB6 AD7616_VB7
range- The analog input range. Accepted values: AD7616_2V5 AD7616_5V AD7616_10V
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_setup()

int32_t ad7616_setup ( struct ad7616_dev **  device,
struct ad7616_init_param init_param 
)

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_setup_sequencer()

int32_t ad7616_setup_sequencer ( struct ad7616_dev dev,
struct ad7616_sequencer_layer layers,
uint32_t  layers_nb,
uint8_t  burst 
)

Setup the sequencer layers.

Parameters
devThe device structure
layersArrays of layers
layers_nbNubers of items in the layers array.
burst1 if needed, 0 otherwise
Returns
0 on success, an error value otherwise

◆ ad7616_spi_read()

int32_t ad7616_spi_read ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t *  reg_data 
)

SPI read from device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_spi_write()

int32_t ad7616_spi_write ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t  reg_data 
)

SPI write to device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_write()

int32_t ad7616_write ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t  reg_data 
)

Write to device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7616_write_mask()

int32_t ad7616_write_mask ( struct ad7616_dev dev,
uint8_t  reg_addr,
uint16_t  mask,
uint16_t  data 
)

SPI write to device using a mask.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: