91#define AD5791_RESET_OUT no_os_gpio_direction_output(dev->gpio_reset, \
91#define AD5791_RESET_OUT no_os_gpio_direction_output(dev->gpio_reset, \ …
93#define AD5791_RESET_LOW no_os_gpio_set_value(dev->gpio_reset, \
93#define AD5791_RESET_LOW no_os_gpio_set_value(dev->gpio_reset, \ …
95#define AD5791_RESET_HIGH no_os_gpio_set_value(dev->gpio_reset, \
95#define AD5791_RESET_HIGH no_os_gpio_set_value(dev->gpio_reset, \ …
98#define AD5791_CLR_OUT no_os_gpio_direction_output(dev->gpio_clr, \
98#define AD5791_CLR_OUT no_os_gpio_direction_output(dev->gpio_clr, \ …
100#define AD5791_CLR_LOW no_os_gpio_set_value(dev->gpio_clr, \
100#define AD5791_CLR_LOW no_os_gpio_set_value(dev->gpio_clr, \ …
102#define AD5791_CLR_HIGH no_os_gpio_set_value(dev->gpio_clr, \
102#define AD5791_CLR_HIGH no_os_gpio_set_value(dev->gpio_clr, \ …
105#define AD5791_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ldac, \
105#define AD5791_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ldac, \ …
107#define AD5791_LDAC_LOW no_os_gpio_set_value(dev->gpio_ldac, \
107#define AD5791_LDAC_LOW no_os_gpio_set_value(dev->gpio_ldac, \ …
109#define AD5791_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ldac, \
109#define AD5791_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ldac, \ …
113#define MAX_RESOLUTION 20
117#define AD5791_REG_DAC 1
118#define AD5791_REG_CTRL 2
119#define AD5791_REG_CLR_CODE 3
120#define AD5791_CMD_WR_SOFT_CTRL 4
123#define AD5791_READ (1ul << 23)
124#define AD5791_WRITE (0ul << 23)
125#define AD5791_ADDR_REG(x) (((uint32_t)(x) & 0x7) << 20)
128#define AD5791_CTRL_LINCOMP_MASK NO_OS_GENMASK(9,6)
129#define AD5791_CTRL_LINCOMP(x) (((x) & 0xF) << 6)
130#define AD5791_CTRL_SDODIS_MASK NO_OS_BIT(5)
131#define AD5791_CTRL_SDODIS(x) ((x & 0x01) << 5)
132#define AD5791_CTRL_BIN2SC_MASK NO_OS_BIT(4)
133#define AD5791_CTRL_BIN2SC(x) ((x & 0x01) << 4)
134#define AD5791_CTRL_DACTRI NO_OS_BIT(3)
135#define AD5791_CTRL_OPGND NO_OS_BIT(2)
136#define AD5791_CTRL_RBUF_MASK NO_OS_BIT(1)
137#define AD5791_CTRL_RBUF(x) ((x & 0x01) << 1)
140#define AD5791_SOFT_CTRL_RESET (1 << 2)
141#define AD5791_SOFT_CTRL_CLR (1 << 1)
142#define AD5791_SOFT_CTRL_LDAC (1 << 0)
145#define AD5791_OUT_NORMAL 0x0
146#define AD5791_OUT_CLAMPED_6K 0x1
147#define AD5791_OUT_TRISTATE 0x2
158 uint8_t register_address,
159 uint32_t register_value);
163 uint8_t register_address,
176 uint8_t instruction_bit);
181 uint32_t setup_word);
185 uint8_t register_address,
int32_t ad5791_dac_ouput_state(struct ad5791_dev *dev, uint8_t state)
Sets the DAC output in one of the three states.
Definition ad5791.c:216
ad5791_lin_comp_select
Definition ad5791.h:54
@ AD5791_SPAN_10V_TO_12V
Definition ad5791.h:57
@ AD5781_SPAN_UPTO_10V
Definition ad5791.h:55
@ AD5791_SPAN_19V_TO_20V
Definition ad5791.h:60
@ AD5781_SPAN_10V_TO_20V
Definition ad5791.h:56
@ AD5791_SPAN_16V_TO_19V
Definition ad5791.h:59
@ AD5791_SPAN_12V_TO_16V
Definition ad5791.h:58
ad5791_type
Definition ad5791.h:45
@ ID_AD5790
Definition ad5791.h:49
@ ID_AD5781
Definition ad5791.h:48
@ ID_AD5780
Definition ad5791.h:47
@ ID_AD5760
Definition ad5791.h:46
@ ID_AD5791
Definition ad5791.h:50
int ad5791_spi_write_mask(struct ad5791_dev *dev, uint8_t register_address, uint32_t mask, uint32_t value)
SPI write to device using a mask.
Definition ad5791.c:357
int32_t ad5791_remove(struct ad5791_dev *dev)
Free the resources allocated by ad5791_init().
Definition ad5791.c:107
int ad5791_clear_async(struct ad5791_dev *dev)
Clear DAC channel output with the clearcode.
Definition ad5791.c:448
int32_t ad5791_set_register_value(struct ad5791_dev *dev, uint8_t register_address, uint32_t register_value)
Writes data into a register.
Definition ad5791.c:136
int32_t ad5791_setup(struct ad5791_dev *dev, uint32_t setup_word)
Configures the output amplifier, DAC coding, SDO state and the linearity error compensation.
Definition ad5791.c:308
int32_t ad5791_init(struct ad5791_dev **device, struct ad5791_init_param init_param)
Initializes the communication with the device.
Definition ad5791.c:68
int32_t ad5791_get_register_value(struct ad5791_dev *dev, uint8_t register_address, uint32_t *value)
Reads the value of a register.
Definition ad5791.c:174
int ad5791_set_lin_comp(struct ad5791_dev *dev, enum ad5791_lin_comp_select v_span)
Set Linearity error compensation based on the reference voltage span.
Definition ad5791.c:385
int32_t ad5791_set_dac_value(struct ad5791_dev *dev, uint32_t value)
Writes to the DAC register.
Definition ad5791.c:249
int ad5791_ldac_trigger(struct ad5791_dev *dev)
Trigger LDAC.
Definition ad5791.c:420
int32_t ad5791_soft_instruction(struct ad5791_dev *dev, uint8_t instruction_bit)
Asserts RESET, CLR or LDAC in a software manner.
Definition ad5791.c:276
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of Delay functions.
Header file of GPIO Interface.
Header file of SPI Interface.
Header file of utility functions.
uint32_t resolution
Definition ad5791.h:64
struct no_os_spi_desc * spi_desc
Definition ad5791.h:69
struct no_os_gpio_desc * gpio_ldac
Definition ad5791.h:73
bool rbuf_gain2
Definition ad5791.h:76
struct no_os_gpio_desc * gpio_reset
Definition ad5791.h:71
enum ad5791_type act_device
Definition ad5791.h:75
struct no_os_gpio_desc * gpio_clr
Definition ad5791.h:72
struct no_os_gpio_init_param gpio_ldac
Definition ad5791.h:85
struct no_os_spi_init_param spi_init
Definition ad5791.h:81
struct no_os_gpio_init_param gpio_clr
Definition ad5791.h:84
bool rbuf_gain2
Definition ad5791.h:88
struct no_os_gpio_init_param gpio_reset
Definition ad5791.h:83
enum ad5791_type act_device
Definition ad5791.h:87
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128