no-OS
Loading...
Searching...
No Matches
ad5761r.h File Reference

Header file of AD5761R Driver. More...

#include <stdint.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
Include dependency graph for ad5761r.h:

Classes

struct  ad5761r_dev
 
struct  ad5761r_init_param
 

Macros

#define AD5761R_INPUT_ZERO_BIT   (1 << 20)
 
#define AD5761R_INPUT_ADDR_CMD(x)
 
#define AD5761R_INPUT_DATA(x)
 
#define AD5761R_DATA(x)
 
#define AD5721R_DATA(x)
 
#define CMD_NOP   0x0
 
#define CMD_WR_TO_INPUT_REG   0x1
 
#define CMD_UPDATE_DAC_REG   0x2
 
#define CMD_WR_UPDATE_DAC_REG   0x3
 
#define CMD_WR_CTRL_REG   0x4
 
#define CMD_NOP_ALT_1   0x5
 
#define CMD_NOP_ALT_2   0x6
 
#define CMD_SW_DATA_RESET   0x7
 
#define CMD_RESERVED   0x8
 
#define CMD_DIS_DAISY_CHAIN   0x9
 
#define CMD_RD_INPUT_REG   0xA
 
#define CMD_RD_DAC_REG   0xB
 
#define CMD_RD_CTRL_REG   0xC
 
#define CMD_NOP_ALT_3   0xD
 
#define CMD_NOP_ALT_4   0xE
 
#define CMD_SW_FULL_RESET   0xF
 
#define AD5761R_CTRL_SC   (1 << 12)
 
#define AD5761R_CTRL_BO   (1 << 11)
 
#define AD5761R_CTRL_CV(x)
 
#define AD5761R_CTRL_OVR   (1 << 8)
 
#define AD5761R_CTRL_B2C   (1 << 7)
 
#define AD5761R_CTRL_ETS   (1 << 6)
 
#define AD5761R_CTRL_IRO   (1 << 5)
 
#define AD5761R_CTRL_PV(x)
 
#define AD5761R_CTRL_RA(x)
 
#define AD5761R_DIS_DAISY_CHAIN_DDC(x)
 

Enumerations

enum  ad5761r_type {
  AD5761R ,
  AD5721R
}
 
enum  ad5761r_reg {
  AD5761R_REG_INPUT ,
  AD5761R_REG_DAC ,
  AD5761R_REG_CTRL
}
 
enum  ad5761r_scale {
  AD5761R_SCALE_ZERO ,
  AD5761R_SCALE_HALF ,
  AD5761R_SCALE_FULL
}
 
enum  ad5761r_range {
  AD5761R_RANGE_M_10V_TO_P_10V ,
  AD5761R_RANGE_0_V_TO_P_10V ,
  AD5761R_RANGE_M_5V_TO_P_5V ,
  AD5761R_RANGE_0V_TO_P_5V ,
  AD5761R_RANGE_M_2V5_TO_P_7V5 ,
  AD5761R_RANGE_M_3V_TO_P_3V ,
  AD5761R_RANGE_0V_TO_P_16V ,
  AD5761R_RANGE_0V_TO_P_20V
}
 

Functions

int32_t ad5761r_init (struct ad5761r_dev **device, struct ad5761r_init_param init_param)
 
int32_t ad5761r_remove (struct ad5761r_dev *dev)
 Free the resources allocated by ad5761r_init().
 
int32_t ad5761r_write (struct ad5761r_dev *dev, uint8_t reg_addr_cmd, uint16_t reg_data)
 
int32_t ad5761r_read (struct ad5761r_dev *dev, uint8_t reg_addr_cmd, uint16_t *reg_data)
 
int32_t ad5761r_register_readback (struct ad5761r_dev *dev, enum ad5761r_reg reg, uint16_t *reg_data)
 
int32_t ad5761r_config (struct ad5761r_dev *dev)
 
int32_t ad5761r_set_daisy_chain_en_dis (struct ad5761r_dev *dev, bool en_dis)
 
int32_t ad5761r_get_daisy_chain_en_dis (struct ad5761r_dev *dev, bool *en_dis)
 
int32_t ad5761r_set_output_range (struct ad5761r_dev *dev, enum ad5761r_range out_range)
 
int32_t ad5761r_get_output_range (struct ad5761r_dev *dev, enum ad5761r_range *out_range)
 
int32_t ad5761r_set_power_up_voltage (struct ad5761r_dev *dev, enum ad5761r_scale pv)
 
int32_t ad5761r_get_power_up_voltage (struct ad5761r_dev *dev, enum ad5761r_scale *pv)
 
int32_t ad5761r_set_clear_voltage (struct ad5761r_dev *dev, enum ad5761r_scale cv)
 
int32_t ad5761r_get_clear_voltage (struct ad5761r_dev *dev, enum ad5761r_scale *cv)
 
int32_t ad5761r_set_internal_reference_en_dis (struct ad5761r_dev *dev, bool en_dis)
 
int32_t ad5761r_get_internal_reference_en_dis (struct ad5761r_dev *dev, bool *en_dis)
 
int32_t ad5761r_set_exceed_temp_shutdown_en_dis (struct ad5761r_dev *dev, bool en_dis)
 
int32_t ad5761r_get_exceed_temp_shutdown_en_dis (struct ad5761r_dev *dev, bool *en_dis)
 
int32_t ad5761r_set_2c_bipolar_range_en_dis (struct ad5761r_dev *dev, bool en_dis)
 
int32_t ad5761r_get_2c_bipolar_range_en_dis (struct ad5761r_dev *dev, bool *en_dis)
 
int32_t ad5761r_set_overrange_en_dis (struct ad5761r_dev *dev, bool en_dis)
 
int32_t ad5761r_get_overrange_en_dis (struct ad5761r_dev *dev, bool *en_dis)
 
int32_t ad5761r_get_short_circuit_condition (struct ad5761r_dev *dev, bool *sc)
 
int32_t ad5761r_get_brownout_condition (struct ad5761r_dev *dev, bool *bo)
 
int32_t ad5761r_set_reset_pin (struct ad5761r_dev *dev, uint8_t value)
 
int32_t ad5761r_get_reset_pin (struct ad5761r_dev *dev, uint8_t *value)
 
int32_t ad5761r_set_clr_pin (struct ad5761r_dev *dev, uint8_t value)
 
int32_t ad5761r_get_clr_pin (struct ad5761r_dev *dev, uint8_t *value)
 
int32_t ad5761r_set_ldac_pin (struct ad5761r_dev *dev, uint8_t value)
 
int32_t ad5761r_get_ldac_pin (struct ad5761r_dev *dev, uint8_t *value)
 
int32_t ad5761r_write_input_register (struct ad5761r_dev *dev, uint16_t reg_data)
 
int32_t ad5761r_update_dac_register (struct ad5761r_dev *dev)
 
int32_t ad5761r_write_update_dac_register (struct ad5761r_dev *dev, uint16_t reg_data)
 
int32_t ad5761r_software_data_reset (struct ad5761r_dev *dev)
 
int32_t ad5761r_software_full_reset (struct ad5761r_dev *dev)
 

Detailed Description

Header file of AD5761R Driver.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2015(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ AD5721R_DATA

#define AD5721R_DATA ( x)
Value:
(((x) & 0xFFF) << 4)

◆ AD5761R_CTRL_B2C

#define AD5761R_CTRL_B2C   (1 << 7)

◆ AD5761R_CTRL_BO

#define AD5761R_CTRL_BO   (1 << 11)

◆ AD5761R_CTRL_CV

#define AD5761R_CTRL_CV ( x)
Value:
(((x) & 0x3) << 9)

◆ AD5761R_CTRL_ETS

#define AD5761R_CTRL_ETS   (1 << 6)

◆ AD5761R_CTRL_IRO

#define AD5761R_CTRL_IRO   (1 << 5)

◆ AD5761R_CTRL_OVR

#define AD5761R_CTRL_OVR   (1 << 8)

◆ AD5761R_CTRL_PV

#define AD5761R_CTRL_PV ( x)
Value:
(((x) & 0x3) << 3)

◆ AD5761R_CTRL_RA

#define AD5761R_CTRL_RA ( x)
Value:
(((x) & 0x7) << 0)

◆ AD5761R_CTRL_SC

#define AD5761R_CTRL_SC   (1 << 12)

◆ AD5761R_DATA

#define AD5761R_DATA ( x)
Value:
(((x) & 0xFFFF) << 0)

◆ AD5761R_DIS_DAISY_CHAIN_DDC

#define AD5761R_DIS_DAISY_CHAIN_DDC ( x)
Value:
(((x) & 0x1) << 0)

◆ AD5761R_INPUT_ADDR_CMD

#define AD5761R_INPUT_ADDR_CMD ( x)
Value:
(((x) & 0xF) << 16)

◆ AD5761R_INPUT_DATA

#define AD5761R_INPUT_DATA ( x)
Value:
(((x) & 0xFFFF) << 0)

◆ AD5761R_INPUT_ZERO_BIT

#define AD5761R_INPUT_ZERO_BIT   (1 << 20)

◆ CMD_DIS_DAISY_CHAIN

#define CMD_DIS_DAISY_CHAIN   0x9

◆ CMD_NOP

#define CMD_NOP   0x0

◆ CMD_NOP_ALT_1

#define CMD_NOP_ALT_1   0x5

◆ CMD_NOP_ALT_2

#define CMD_NOP_ALT_2   0x6

◆ CMD_NOP_ALT_3

#define CMD_NOP_ALT_3   0xD

◆ CMD_NOP_ALT_4

#define CMD_NOP_ALT_4   0xE

◆ CMD_RD_CTRL_REG

#define CMD_RD_CTRL_REG   0xC

◆ CMD_RD_DAC_REG

#define CMD_RD_DAC_REG   0xB

◆ CMD_RD_INPUT_REG

#define CMD_RD_INPUT_REG   0xA

◆ CMD_RESERVED

#define CMD_RESERVED   0x8

◆ CMD_SW_DATA_RESET

#define CMD_SW_DATA_RESET   0x7

◆ CMD_SW_FULL_RESET

#define CMD_SW_FULL_RESET   0xF

◆ CMD_UPDATE_DAC_REG

#define CMD_UPDATE_DAC_REG   0x2

◆ CMD_WR_CTRL_REG

#define CMD_WR_CTRL_REG   0x4

◆ CMD_WR_TO_INPUT_REG

#define CMD_WR_TO_INPUT_REG   0x1

◆ CMD_WR_UPDATE_DAC_REG

#define CMD_WR_UPDATE_DAC_REG   0x3

Enumeration Type Documentation

◆ ad5761r_range

Enumerator
AD5761R_RANGE_M_10V_TO_P_10V 
AD5761R_RANGE_0_V_TO_P_10V 
AD5761R_RANGE_M_5V_TO_P_5V 
AD5761R_RANGE_0V_TO_P_5V 
AD5761R_RANGE_M_2V5_TO_P_7V5 
AD5761R_RANGE_M_3V_TO_P_3V 
AD5761R_RANGE_0V_TO_P_16V 
AD5761R_RANGE_0V_TO_P_20V 

◆ ad5761r_reg

Enumerator
AD5761R_REG_INPUT 
AD5761R_REG_DAC 
AD5761R_REG_CTRL 

◆ ad5761r_scale

Enumerator
AD5761R_SCALE_ZERO 
AD5761R_SCALE_HALF 
AD5761R_SCALE_FULL 

◆ ad5761r_type

Enumerator
AD5761R 
AD5721R 

Function Documentation

◆ ad5761r_config()

int32_t ad5761r_config ( struct ad5761r_dev * dev)

Configure the part based on the settings stored in the device structure.

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

◆ ad5761r_get_2c_bipolar_range_en_dis()

int32_t ad5761r_get_2c_bipolar_range_en_dis ( struct ad5761r_dev * dev,
bool * en_dis )

Get the status of the twos complement bipolar output range.

Parameters
dev- The device structure.
en_dis- The status of the twos complement bipolar output range (enabled, disabled).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_get_brownout_condition()

int32_t ad5761r_get_brownout_condition ( struct ad5761r_dev * dev,
bool * bo )

Get the brownout condition. Note: The condition is reset at every control register write.

Parameters
dev- The device structure.
bo- The status of the brownout condition (detected, not detected).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_get_clear_voltage()

int32_t ad5761r_get_clear_voltage ( struct ad5761r_dev * dev,
enum ad5761r_scale * cv )

Get the clear voltage.

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

◆ ad5761r_get_clr_pin()

int32_t ad5761r_get_clr_pin ( struct ad5761r_dev * dev,
uint8_t * value )

Get the clr pin value.

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

◆ ad5761r_get_daisy_chain_en_dis()

int32_t ad5761r_get_daisy_chain_en_dis ( struct ad5761r_dev * dev,
bool * en_dis )

Get the status of the daisy-chain mode.

Parameters
dev- The device structure.
en_dis- The status of the daisy-chain mode (enabled, disabled).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_get_exceed_temp_shutdown_en_dis()

int32_t ad5761r_get_exceed_temp_shutdown_en_dis ( struct ad5761r_dev * dev,
bool * en_dis )

Get the status of the ETS (exceed temperature shutdown) function.

Parameters
dev- The device structure.
en_dis- The status of the ETS function (enabled, disabled).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_get_internal_reference_en_dis()

int32_t ad5761r_get_internal_reference_en_dis ( struct ad5761r_dev * dev,
bool * en_dis )

Get the status of the internal reference.

Parameters
dev- The device structure.
en_dis- The status of the internal reference (enabled, disabled).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_get_ldac_pin()

int32_t ad5761r_get_ldac_pin ( struct ad5761r_dev * dev,
uint8_t * value )

Get the ldac pin value.

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

◆ ad5761r_get_output_range()

int32_t ad5761r_get_output_range ( struct ad5761r_dev * dev,
enum ad5761r_range * out_range )

Get the output_range.

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

◆ ad5761r_get_overrange_en_dis()

int32_t ad5761r_get_overrange_en_dis ( struct ad5761r_dev * dev,
bool * en_dis )

Get the status of the 5% overrange.

Parameters
dev- The device structure.
en_dis- The status of the twos 5% overrange (enabled, disabled).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_get_power_up_voltage()

int32_t ad5761r_get_power_up_voltage ( struct ad5761r_dev * dev,
enum ad5761r_scale * pv )

Get the power up voltage.

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

◆ ad5761r_get_reset_pin()

int32_t ad5761r_get_reset_pin ( struct ad5761r_dev * dev,
uint8_t * value )

Get the reset pin value.

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

◆ ad5761r_get_short_circuit_condition()

int32_t ad5761r_get_short_circuit_condition ( struct ad5761r_dev * dev,
bool * sc )

Get the short-circuit condition. Note: The condition is reset at every control register write.

Parameters
dev- The device structure.
sc- The status of the short-circuit condition (detected, not detected).
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_init()

int32_t ad5761r_init ( struct ad5761r_dev ** device,
struct ad5761r_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.

◆ ad5761r_read()

int32_t ad5761r_read ( struct ad5761r_dev * dev,
uint8_t reg_addr_cmd,
uint16_t * reg_data )

SPI read from device.

Parameters
dev- The device structure.
reg_addr_cmd- The input shift register command. Accepted values: CMD_NOP CMD_WR_TO_INPUT_REG CMD_UPDATE_DAC_REG_FROM_INPUT_REG CMD_WR_UPDATE_DAC_REG CMD_WR_CTRL_REG CMD_SW_DATA_RESET CMD_DIS_DAISY_CHAIN CMD_RD_INPUT_REG CMD_RD_DAC_REG CMD_RD_CTRL_REG CMD_SW_FULL_RESET
reg_data- The received data.
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_register_readback()

int32_t ad5761r_register_readback ( struct ad5761r_dev * dev,
enum ad5761r_reg reg,
uint16_t * reg_data )

Readback the register data. Note: Readback operation is not enabled if daisy-chain mode is disabled.

Parameters
dev- The device structure.
reg- The register to be read. Accepted values: AD5761R_REG_INPUT AD5761R_REG_DAC AD5761R_REG_CTRL
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_remove()

int32_t ad5761r_remove ( struct ad5761r_dev * dev)

Free the resources allocated by ad5761r_init().

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

◆ ad5761r_set_2c_bipolar_range_en_dis()

int32_t ad5761r_set_2c_bipolar_range_en_dis ( struct ad5761r_dev * dev,
bool en_dis )

Enable/disable the twos complement bipolar output range.

Parameters
dev- The device structure.
en_dis- Set true in order to enable the twos complement bipolar output range. Accepted values: true false
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_clear_voltage()

int32_t ad5761r_set_clear_voltage ( struct ad5761r_dev * dev,
enum ad5761r_scale cv )

Set the clear voltage.

Parameters
dev- The device structure.
cv- The clear voltage. Accepted values: AD5761R_SCALE_ZERO AD5761R_SCALE_HALF AD5761R_SCALE_FULL
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_clr_pin()

int32_t ad5761r_set_clr_pin ( struct ad5761r_dev * dev,
uint8_t value )

Set the clr pin value.

Parameters
dev- The device structure.
value- The pin value. Accepted values: NO_OS_GPIO_LOW NO_OS_GPIO_HIGH
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_daisy_chain_en_dis()

int32_t ad5761r_set_daisy_chain_en_dis ( struct ad5761r_dev * dev,
bool en_dis )

Enable/disable daisy-chain mode.

Parameters
dev- The device structure.
en_dis- Set true in order to enable the daisy-chain mode. Accepted values: true false
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_exceed_temp_shutdown_en_dis()

int32_t ad5761r_set_exceed_temp_shutdown_en_dis ( struct ad5761r_dev * dev,
bool en_dis )

Enable/disable ETS (exceed temperature shutdown) function.

Parameters
dev- The device structure.
en_dis- Set true in order to enable the ETS function. Accepted values: true false
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_internal_reference_en_dis()

int32_t ad5761r_set_internal_reference_en_dis ( struct ad5761r_dev * dev,
bool en_dis )

Enable/disable internal reference.

Parameters
dev- The device structure.
en_dis- Set true in order to enable the internal reference. Accepted values: true false
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_ldac_pin()

int32_t ad5761r_set_ldac_pin ( struct ad5761r_dev * dev,
uint8_t value )

Set the ldac pin value.

Parameters
dev- The device structure.
value- The pin value. Accepted values: NO_OS_GPIO_LOW NO_OS_GPIO_HIGH
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_output_range()

int32_t ad5761r_set_output_range ( struct ad5761r_dev * dev,
enum ad5761r_range out_range )

Set the output_range.

Parameters
dev- The device structure.
out_range- The output range. Accepted values: AD5761R_RANGE_M_10V_TO_P_10V, AD5761R_RANGE_0_V_TO_P_10V AD5761R_RANGE_M_5V_TO_P_5V AD5761R_RANGE_0V_TO_P_5V AD5761R_RANGE_M_2V5_TO_P_7V5 AD5761R_RANGE_M_3V_TO_P_3V AD5761R_RANGE_0V_TO_P_16V AD5761R_RANGE_0V_TO_P_20V
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_overrange_en_dis()

int32_t ad5761r_set_overrange_en_dis ( struct ad5761r_dev * dev,
bool en_dis )

Enable/disable the 5% overrange.

Parameters
dev- The device structure.
en_dis- Set true in order to enable the 5% overrange. Accepted values: true false
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_power_up_voltage()

int32_t ad5761r_set_power_up_voltage ( struct ad5761r_dev * dev,
enum ad5761r_scale pv )

Set the power up voltage.

Parameters
dev- The device structure.
pv- The power up voltage. Accepted values: AD5761R_SCALE_ZERO AD5761R_SCALE_HALF AD5761R_SCALE_FULL
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_set_reset_pin()

int32_t ad5761r_set_reset_pin ( struct ad5761r_dev * dev,
uint8_t value )

Set the reset pin value.

Parameters
dev- The device structure.
value- The pin value. Accepted values: NO_OS_GPIO_LOW NO_OS_GPIO_HIGH
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_software_data_reset()

int32_t ad5761r_software_data_reset ( struct ad5761r_dev * dev)

Software data reset.

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

◆ ad5761r_software_full_reset()

int32_t ad5761r_software_full_reset ( struct ad5761r_dev * dev)

Software full reset.

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

◆ ad5761r_update_dac_register()

int32_t ad5761r_update_dac_register ( struct ad5761r_dev * dev)

Update DAC register.

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

◆ ad5761r_write()

int32_t ad5761r_write ( struct ad5761r_dev * dev,
uint8_t reg_addr_cmd,
uint16_t reg_data )

SPI write to device.

Parameters
dev- The device structure.
reg_addr_cmd- The input shift register command. Accepted values: CMD_NOP CMD_WR_TO_INPUT_REG CMD_UPDATE_DAC_REG_FROM_INPUT_REG CMD_WR_UPDATE_DAC_REG CMD_WR_CTRL_REG CMD_SW_DATA_RESET CMD_DIS_DAISY_CHAIN CMD_RD_INPUT_REG CMD_RD_DAC_REG CMD_RD_CTRL_REG CMD_SW_FULL_RESET
reg_data- The transmitted data.
Returns
0 in case of success, negative error code otherwise.

◆ ad5761r_write_input_register()

int32_t ad5761r_write_input_register ( struct ad5761r_dev * dev,
uint16_t dac_data )

Write to input register.

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

◆ ad5761r_write_update_dac_register()

int32_t ad5761r_write_update_dac_register ( struct ad5761r_dev * dev,
uint16_t dac_data )

Write to input register and update DAC register.

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