no-OS
Loading...
Searching...
No Matches
ad5592r-base.h File Reference

Header file of AD5592R Base Driver. More...

#include "stdint.h"
#include "no_os_delay.h"
#include "no_os_spi.h"
#include "no_os_i2c.h"
#include "no_os_gpio.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
#include <stdbool.h>
Include dependency graph for ad5592r-base.h:

Classes

struct  ad5592r_rw_ops
 
struct  ad5592r_init_param
 
struct  ad5592r_dev
 

Macros

#define CH_MODE_UNUSED   0
 
#define CH_MODE_ADC   1
 
#define CH_MODE_DAC   2
 
#define CH_MODE_DAC_AND_ADC   3
 
#define CH_MODE_GPI   4
 
#define CH_MODE_GPO   5
 
#define CH_OFFSTATE_PULLDOWN   0
 
#define CH_OFFSTATE_OUT_LOW   1
 
#define CH_OFFSTATE_OUT_HIGH   2
 
#define CH_OFFSTATE_OUT_TRISTATE   3
 
#define AD5592R_REG_PD_PD_ALL   NO_OS_BIT(10)
 
#define AD5592R_REG_PD_EN_REF   NO_OS_BIT(9)
 
#define AD5592R_REG_CTRL_ADC_PC_BUFF   NO_OS_BIT(9)
 
#define AD5592R_REG_CTRL_ADC_BUFF_EN   NO_OS_BIT(8)
 
#define AD5592R_REG_CTRL_CONFIG_LOCK   NO_OS_BIT(7)
 
#define AD5592R_REG_CTRL_W_ALL_DACS   NO_OS_BIT(6)
 
#define AD5592R_REG_CTRL_ADC_RANGE   NO_OS_BIT(5)
 
#define AD5592R_REG_CTRL_DAC_RANGE   NO_OS_BIT(4)
 
#define AD5592R_REG_ADC_SEQ_REP   NO_OS_BIT(9)
 
#define AD5592R_REG_ADC_SEQ_TEMP_READBACK   NO_OS_BIT(8)
 
#define AD5592R_REG_ADC_SEQ_CODE_MSK(x)
 
#define AD5592R_REG_GPIO_OUT_EN_ADC_NOT_BUSY   NO_OS_BIT(8)
 
#define AD5592R_REG_LDAC_IMMEDIATE_OUT   0x00
 
#define AD5592R_REG_LDAC_INPUT_REG_ONLY   0x01
 
#define AD5592R_REG_LDAC_INPUT_REG_OUT   0x02
 
#define INTERNAL_VREF_VOLTAGE   2.5
 
#define AD5592R_MIN_VREF_MV   1000
 
#define AD5592R_MAX_VREF_MV   5500
 
#define AD5592R_TEMPERATURE_CHANNEL   8
 
#define NUM_OF_CHANNELS   8
 

Enumerations

enum  ad5592r_registers {
  AD5592R_REG_NOOP = 0x0 ,
  AD5592R_REG_DAC_READBACK = 0x1 ,
  AD5592R_REG_ADC_SEQ = 0x2 ,
  AD5592R_REG_CTRL = 0x3 ,
  AD5592R_REG_ADC_EN = 0x4 ,
  AD5592R_REG_DAC_EN = 0x5 ,
  AD5592R_REG_PULLDOWN = 0x6 ,
  AD5592R_REG_LDAC = 0x7 ,
  AD5592R_REG_GPIO_OUT_EN = 0x8 ,
  AD5592R_REG_GPIO_SET = 0x9 ,
  AD5592R_REG_GPIO_IN_EN = 0xA ,
  AD5592R_REG_PD = 0xB ,
  AD5592R_REG_OPEN_DRAIN = 0xC ,
  AD5592R_REG_TRISTATE = 0xD ,
  AD5592R_REG_RESET = 0xF
}
 
enum  ad559xr_range {
  ZERO_TO_VREF ,
  ZERO_TO_2VREF
}
 

Functions

int32_t ad5592r_base_reg_write (struct ad5592r_dev *dev, uint8_t reg, uint16_t value)
 
int32_t ad5592r_base_reg_read (struct ad5592r_dev *dev, uint8_t reg, uint16_t *value)
 
int32_t ad5592r_gpio_get (struct ad5592r_dev *dev, uint8_t offset)
 
int32_t ad5592r_gpio_set (struct ad5592r_dev *dev, uint8_t offset, int32_t value)
 
int32_t ad5592r_gpio_direction_input (struct ad5592r_dev *dev, uint8_t offset)
 
int32_t ad5592r_gpio_direction_output (struct ad5592r_dev *dev, uint8_t offset, int32_t value)
 
int32_t ad5592r_software_reset (struct ad5592r_dev *dev)
 
int32_t ad5592r_set_channel_modes (struct ad5592r_dev *dev)
 
int32_t ad5592r_reset_channel_modes (struct ad5592r_dev *dev)
 
int32_t ad5592r_set_adc_range (struct ad5592r_dev *dev, enum ad559xr_range adc_range)
 
int32_t ad5592r_set_dac_range (struct ad5592r_dev *dev, enum ad559xr_range dac_range)
 
int32_t ad5592r_power_down (struct ad5592r_dev *dev, uint8_t chan, bool enable)
 
int32_t ad5592r_set_int_ref (struct ad5592r_dev *dev, bool enable)
 
int32_t ad5592r_set_ext_ref (struct ad5592r_dev *dev, uint32_t vref_mv)
 
int32_t ad5592r_get_ref (struct ad5592r_dev *dev, uint32_t *vref_mv)
 
int32_t ad5592r_set_adc_buffer (struct ad5592r_dev *dev, bool enable)
 
int32_t ad5592r_base_reg_update (struct ad5592r_dev *dev, uint16_t reg_addr, uint16_t data, uint16_t mask)
 
int32_t ad5592r_set_repetition (struct ad5592r_dev *dev, bool repeat)
 

Detailed Description

Header file of AD5592R Base Driver.

Author
Mircea Caprioru (mirce.nosp@m.a.ca.nosp@m.prior.nosp@m.u@an.nosp@m.alog..nosp@m.com)
Niel Acuna (niel..nosp@m.acun.nosp@m.a@ana.nosp@m.log..nosp@m.com)

Copyright 2018, 2020, 2025, 2026 (c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ AD5592R_MAX_VREF_MV

#define AD5592R_MAX_VREF_MV   5500

◆ AD5592R_MIN_VREF_MV

#define AD5592R_MIN_VREF_MV   1000

◆ AD5592R_REG_ADC_SEQ_CODE_MSK

#define AD5592R_REG_ADC_SEQ_CODE_MSK ( x)
Value:
((x) & 0x0FFF)

◆ AD5592R_REG_ADC_SEQ_REP

#define AD5592R_REG_ADC_SEQ_REP   NO_OS_BIT(9)

◆ AD5592R_REG_ADC_SEQ_TEMP_READBACK

#define AD5592R_REG_ADC_SEQ_TEMP_READBACK   NO_OS_BIT(8)

◆ AD5592R_REG_CTRL_ADC_BUFF_EN

#define AD5592R_REG_CTRL_ADC_BUFF_EN   NO_OS_BIT(8)

◆ AD5592R_REG_CTRL_ADC_PC_BUFF

#define AD5592R_REG_CTRL_ADC_PC_BUFF   NO_OS_BIT(9)

◆ AD5592R_REG_CTRL_ADC_RANGE

#define AD5592R_REG_CTRL_ADC_RANGE   NO_OS_BIT(5)

◆ AD5592R_REG_CTRL_CONFIG_LOCK

#define AD5592R_REG_CTRL_CONFIG_LOCK   NO_OS_BIT(7)

◆ AD5592R_REG_CTRL_DAC_RANGE

#define AD5592R_REG_CTRL_DAC_RANGE   NO_OS_BIT(4)

◆ AD5592R_REG_CTRL_W_ALL_DACS

#define AD5592R_REG_CTRL_W_ALL_DACS   NO_OS_BIT(6)

◆ AD5592R_REG_GPIO_OUT_EN_ADC_NOT_BUSY

#define AD5592R_REG_GPIO_OUT_EN_ADC_NOT_BUSY   NO_OS_BIT(8)

◆ AD5592R_REG_LDAC_IMMEDIATE_OUT

#define AD5592R_REG_LDAC_IMMEDIATE_OUT   0x00

◆ AD5592R_REG_LDAC_INPUT_REG_ONLY

#define AD5592R_REG_LDAC_INPUT_REG_ONLY   0x01

◆ AD5592R_REG_LDAC_INPUT_REG_OUT

#define AD5592R_REG_LDAC_INPUT_REG_OUT   0x02

◆ AD5592R_REG_PD_EN_REF

#define AD5592R_REG_PD_EN_REF   NO_OS_BIT(9)

◆ AD5592R_REG_PD_PD_ALL

#define AD5592R_REG_PD_PD_ALL   NO_OS_BIT(10)

◆ AD5592R_TEMPERATURE_CHANNEL

#define AD5592R_TEMPERATURE_CHANNEL   8

◆ CH_MODE_ADC

#define CH_MODE_ADC   1

◆ CH_MODE_DAC

#define CH_MODE_DAC   2

◆ CH_MODE_DAC_AND_ADC

#define CH_MODE_DAC_AND_ADC   3

◆ CH_MODE_GPI

#define CH_MODE_GPI   4

◆ CH_MODE_GPO

#define CH_MODE_GPO   5

◆ CH_MODE_UNUSED

#define CH_MODE_UNUSED   0

◆ CH_OFFSTATE_OUT_HIGH

#define CH_OFFSTATE_OUT_HIGH   2

◆ CH_OFFSTATE_OUT_LOW

#define CH_OFFSTATE_OUT_LOW   1

◆ CH_OFFSTATE_OUT_TRISTATE

#define CH_OFFSTATE_OUT_TRISTATE   3

◆ CH_OFFSTATE_PULLDOWN

#define CH_OFFSTATE_PULLDOWN   0

◆ INTERNAL_VREF_VOLTAGE

#define INTERNAL_VREF_VOLTAGE   2.5

◆ NUM_OF_CHANNELS

#define NUM_OF_CHANNELS   8

Enumeration Type Documentation

◆ ad5592r_registers

Enumerator
AD5592R_REG_NOOP 
AD5592R_REG_DAC_READBACK 
AD5592R_REG_ADC_SEQ 
AD5592R_REG_CTRL 
AD5592R_REG_ADC_EN 
AD5592R_REG_DAC_EN 
AD5592R_REG_PULLDOWN 
AD5592R_REG_LDAC 
AD5592R_REG_GPIO_OUT_EN 
AD5592R_REG_GPIO_SET 
AD5592R_REG_GPIO_IN_EN 
AD5592R_REG_PD 
AD5592R_REG_OPEN_DRAIN 
AD5592R_REG_TRISTATE 
AD5592R_REG_RESET 

◆ ad559xr_range

Enumerator
ZERO_TO_VREF 
ZERO_TO_2VREF 

Function Documentation

◆ ad5592r_base_reg_read()

int32_t ad5592r_base_reg_read ( struct ad5592r_dev * dev,
uint8_t reg,
uint16_t * value )

Read register.

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

◆ ad5592r_base_reg_update()

int32_t ad5592r_base_reg_update ( struct ad5592r_dev * dev,
uint16_t reg_addr,
uint16_t data,
uint16_t mask )

Register update

Parameters
dev- The device structure.
reg_addr- The Register address
data- The data to be written
mask- The mask
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_base_reg_write()

int32_t ad5592r_base_reg_write ( struct ad5592r_dev * dev,
uint8_t reg,
uint16_t value )

Write register.

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

◆ ad5592r_get_ref()

int32_t ad5592r_get_ref ( struct ad5592r_dev * dev,
uint32_t * vref_mv )

Get the device voltage reference.

Parameters
[in]devThe device structure.
[out]vref_mvThe voltage reference in millivolts.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_gpio_direction_input()

int32_t ad5592r_gpio_direction_input ( struct ad5592r_dev * dev,
uint8_t offset )

Set GPIO as input

Parameters
dev- The device structure.
offset- The channel number.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_gpio_direction_output()

int32_t ad5592r_gpio_direction_output ( struct ad5592r_dev * dev,
uint8_t offset,
int32_t value )

Set GPIO as output

Parameters
dev- The device structure.
offset- The channel number.
value- GPIO value to set.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_gpio_get()

int32_t ad5592r_gpio_get ( struct ad5592r_dev * dev,
uint8_t offset )

Get GPIO value

Parameters
dev- The device structure.
offset- The channel number.
Returns
0 or 1 depending on the GPIO value.

◆ ad5592r_gpio_set()

int32_t ad5592r_gpio_set ( struct ad5592r_dev * dev,
uint8_t offset,
int32_t value )

Set GPIO value

Parameters
dev- The device structure.
offset- The channel number.
value- the GPIO value (0 or 1)

◆ ad5592r_power_down()

int32_t ad5592r_power_down ( struct ad5592r_dev * dev,
uint8_t chan,
bool enable )

Set Power Down DAC Channel of the device

Parameters
dev- The device structure.
chan- The channel number.
enable- Status to enable/disable power down.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_reset_channel_modes()

int32_t ad5592r_reset_channel_modes ( struct ad5592r_dev * dev)

Reset channels and set GPIO to unused.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_set_adc_buffer()

int32_t ad5592r_set_adc_buffer ( struct ad5592r_dev * dev,
bool enable )

Set ADC Buffer for the device

Parameters
dev- The device structure.
enable- Status to enable/disable adc buffer.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_set_adc_range()

int32_t ad5592r_set_adc_range ( struct ad5592r_dev * dev,
enum ad559xr_range adc_range )

Set ADC Range of the device

Parameters
dev- The device structure.
adc_range- ADC Range
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_set_channel_modes()

int32_t ad5592r_set_channel_modes ( struct ad5592r_dev * dev)

Set channels modes.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_set_dac_range()

int32_t ad5592r_set_dac_range ( struct ad5592r_dev * dev,
enum ad559xr_range dac_range )

Set DAC Range of the device

Parameters
dev- The device structure.
dac_range- DAC Range
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_set_ext_ref()

int32_t ad5592r_set_ext_ref ( struct ad5592r_dev * dev,
uint32_t vref_mv )

Get the device voltage reference.

Parameters
[in]devThe device structure.
[in]vref_mvThe voltage reference in millivolts.
Returns
0 in case of success
-ENODEV when dev is NULL
-ERANGE when vref is outside of the valid values for ad559xr vref

◆ ad5592r_set_int_ref()

int32_t ad5592r_set_int_ref ( struct ad5592r_dev * dev,
bool enable )

Set Reference Select option for the device

Parameters
dev- The device structure.
enable- Status to enable/disable internal reference.
Returns
0 in case of success, negative error code otherwise

◆ ad5592r_set_repetition()

int32_t ad5592r_set_repetition ( struct ad5592r_dev * dev,
bool repeat )

◆ ad5592r_software_reset()

int32_t ad5592r_software_reset ( struct ad5592r_dev * dev)

Software reset device.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise