Header file of AD5791 Driver.
More...
#include <stdint.h>
#include "no_os_delay.h"
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
#include "no_os_error.h"
|
| int32_t | ad5791_init (struct ad5791_dev **device, struct ad5791_init_param init_param) |
| | Initializes the communication with the device.
|
| |
| int32_t | ad5791_remove (struct ad5791_dev *dev) |
| | Free the resources allocated by ad5791_init().
|
| |
| int32_t | ad5791_set_register_value (struct ad5791_dev *dev, uint8_t register_address, uint32_t register_value) |
| | Writes data into a register.
|
| |
| int32_t | ad5791_get_register_value (struct ad5791_dev *dev, uint8_t register_address, uint32_t *value) |
| | Reads the value of a register.
|
| |
| int32_t | ad5791_dac_ouput_state (struct ad5791_dev *dev, uint8_t state) |
| | Sets the DAC output in one of the three states.
|
| |
| int32_t | ad5791_set_dac_value (struct ad5791_dev *dev, uint32_t value) |
| | Writes to the DAC register.
|
| |
| int32_t | ad5791_soft_instruction (struct ad5791_dev *dev, uint8_t instruction_bit) |
| | Asserts RESET, CLR or LDAC in a software manner.
|
| |
| 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.
|
| |
| 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.
|
| |
| 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.
|
| |
| int | ad5791_ldac_trigger (struct ad5791_dev *dev) |
| | Trigger LDAC.
|
| |
| int | ad5791_clear_async (struct ad5791_dev *dev) |
| | Clear DAC channel output with the clearcode.
|
| |
Header file of AD5791 Driver.
- Author
- DNechita (Dan.N.nosp@m.echi.nosp@m.ta@an.nosp@m.alog.nosp@m..com)
Copyright 2013(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
◆ AD5791_ADDR_REG
| #define AD5791_ADDR_REG |
( |
| x | ) |
|
Value:(((uint32_t)(x) & 0x7) << 20)
◆ AD5791_CLR_HIGH
Value:
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition no_os_gpio.c:170
@ NO_OS_GPIO_HIGH
Definition no_os_gpio.h:82
◆ AD5791_CLR_LOW
Value:
@ NO_OS_GPIO_LOW
Definition no_os_gpio.h:80
◆ AD5791_CLR_OUT
Value:
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition no_os_gpio.c:120
◆ AD5791_CMD_WR_SOFT_CTRL
| #define AD5791_CMD_WR_SOFT_CTRL 4 |
◆ AD5791_CTRL_BIN2SC
| #define AD5791_CTRL_BIN2SC |
( |
| x | ) |
|
◆ AD5791_CTRL_BIN2SC_MASK
◆ AD5791_CTRL_DACTRI
◆ AD5791_CTRL_LINCOMP
| #define AD5791_CTRL_LINCOMP |
( |
| x | ) |
|
◆ AD5791_CTRL_LINCOMP_MASK
◆ AD5791_CTRL_OPGND
◆ AD5791_CTRL_RBUF
| #define AD5791_CTRL_RBUF |
( |
| x | ) |
|
◆ AD5791_CTRL_RBUF_MASK
◆ AD5791_CTRL_SDODIS
| #define AD5791_CTRL_SDODIS |
( |
| x | ) |
|
◆ AD5791_CTRL_SDODIS_MASK
◆ AD5791_LDAC_HIGH
◆ AD5791_LDAC_LOW
◆ AD5791_LDAC_OUT
◆ AD5791_NOP
◆ AD5791_OUT_CLAMPED_6K
| #define AD5791_OUT_CLAMPED_6K 0x1 |
◆ AD5791_OUT_NORMAL
| #define AD5791_OUT_NORMAL 0x0 |
◆ AD5791_OUT_TRISTATE
| #define AD5791_OUT_TRISTATE 0x2 |
◆ AD5791_READ
| #define AD5791_READ (1ul << 23) |
◆ AD5791_REG_CLR_CODE
| #define AD5791_REG_CLR_CODE 3 |
◆ AD5791_REG_CTRL
| #define AD5791_REG_CTRL 2 |
◆ AD5791_REG_DAC
◆ AD5791_RESET_HIGH
| #define AD5791_RESET_HIGH |
◆ AD5791_RESET_LOW
◆ AD5791_RESET_OUT
◆ AD5791_SOFT_CTRL_CLR
| #define AD5791_SOFT_CTRL_CLR (1 << 1) |
◆ AD5791_SOFT_CTRL_LDAC
| #define AD5791_SOFT_CTRL_LDAC (1 << 0) |
◆ AD5791_SOFT_CTRL_RESET
| #define AD5791_SOFT_CTRL_RESET (1 << 2) |
◆ AD5791_WRITE
| #define AD5791_WRITE (0ul << 23) |
◆ MAX_RESOLUTION
| #define MAX_RESOLUTION 20 |
◆ ad5791_lin_comp_select
| Enumerator |
|---|
| AD5781_SPAN_UPTO_10V | |
| AD5781_SPAN_10V_TO_20V | |
| AD5791_SPAN_10V_TO_12V | |
| AD5791_SPAN_12V_TO_16V | |
| AD5791_SPAN_16V_TO_19V | |
| AD5791_SPAN_19V_TO_20V | |
◆ ad5791_type
| Enumerator |
|---|
| ID_AD5760 | |
| ID_AD5780 | |
| ID_AD5781 | |
| ID_AD5790 | |
| ID_AD5791 | |
◆ ad5791_clear_async()
Clear DAC channel output with the clearcode.
Clear DAC channel output with the clearcode.
- Parameters
-
| dev | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad5791_dac_ouput_state()
| int32_t ad5791_dac_ouput_state |
( |
struct ad5791_dev * | dev, |
|
|
uint8_t | state ) |
Sets the DAC output in one of the three states.
Sets the DAC output in one of the three states.
- Parameters
-
| dev | - The device structure. |
| state | - The output state. Example: AD5791_OUT_NORMAL - normal operation mode AD5791_OUT_CLAMPED_6K - output is clamped via ~6KOhm to AGND AD5791_OUT_TRISTATE - output is in tristate |
- Returns
- Negative error code or 0 in case of success.
◆ ad5791_get_register_value()
| int32_t ad5791_get_register_value |
( |
struct ad5791_dev * | dev, |
|
|
uint8_t | register_address, |
|
|
uint32_t * | value ) |
Reads the value of a register.
Reads the value of a register.
- Parameters
-
| dev | - The device structure. |
| register_address | - Address of the register. Example: AD5791_REG_DAC - DAC register AD5791_REG_CTRL - Control register AD5791_REG_CLR_CODE - Clearcode register AD5791_CMD_WR_SOFT_CTRL - Software control register |
| value | - Pointer to the register data. |
- Returns
- dataRead - The register's value or negative error code.
◆ ad5791_init()
Initializes the communication with the device.
Initializes the communication with the device.
- Parameters
-
| device | - The device structure. |
| init_param | - The structure that contains the device initial parameters. |
- Returns
- status - Result of the initialization procedure. Example: 0 - if initialization was successful; -1 - if initialization was unsuccessful.
◆ ad5791_ldac_trigger()
| int ad5791_ldac_trigger |
( |
struct ad5791_dev * | dev | ) |
|
Trigger LDAC.
Trigger LDAC.
- Parameters
-
| dev | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad5791_remove()
Free the resources allocated by ad5791_init().
Free the resources allocated by ad5791_init().
- Parameters
-
| dev | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad5791_set_dac_value()
| int32_t ad5791_set_dac_value |
( |
struct ad5791_dev * | dev, |
|
|
uint32_t | value ) |
Writes to the DAC register.
Writes to the DAC register.
- Parameters
-
| dev | - The device structure. |
| value | - The value to be written to DAC. |
- Returns
- Negative error code or 0 in case of success.
◆ ad5791_set_lin_comp()
Set Linearity error compensation based on the reference voltage span.
Set Linearity error compensation based on the reference voltage span.
- Parameters
-
| dev | - The device structure. |
| v_span | - voltage span to set the corresponding lin_comp value. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad5791_set_register_value()
| int32_t ad5791_set_register_value |
( |
struct ad5791_dev * | dev, |
|
|
uint8_t | register_address, |
|
|
uint32_t | register_value ) |
Writes data into a register.
Writes data into a register.
- Parameters
-
| dev | - The device structure. |
| register_address | - Address of the register. Example: AD5791_REG_DAC - DAC register AD5791_REG_CTRL - Control register AD5791_REG_CLR_CODE - Clearcode register AD5791_CMD_WR_SOFT_CTRL - Software control register |
| register_value | - Value of the register. |
- Returns
- Returns 0 in case of success or negative error code.
◆ ad5791_setup()
| 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.
Configures the output amplifier, DAC coding, SDO state and the linearity error compensation.
- Parameters
-
| dev | - The device structure. |
| setup_word | - Is a 24-bit value that sets or clears the Control Register bits : RBUF bit(AD5791_CTRL_RBUF(x)), BIN/2sC bit(AD5791_CTRL_BIN2SC(x)), SDODIS bit(AD5791_CTRL_SDODIS(x)) and LINCOMP bits(AD5791_CTRL_LINCOMP(x)). Example: AD5791_CTRL_BIN2SC(1) | AD5791_CTRL_RBUF(1) - sets the DAC register to use offset binary coding and powers down the internal output amplifier. |
- Returns
- Negative error code or 0 in case of success.
◆ ad5791_soft_instruction()
| int32_t ad5791_soft_instruction |
( |
struct ad5791_dev * | dev, |
|
|
uint8_t | instruction_bit ) |
Asserts RESET, CLR or LDAC in a software manner.
Asserts RESET, CLR or LDAC in a software manner.
- Parameters
-
| dev | - The device structure. |
| instruction_bit | - A Software Control Register bit. Example: AD5791_SOFT_CTRL_LDAC - Load DAC AD5791_SOFT_CTRL_CLR - Clear AD5791_SOFT_CTRL_RESET - Reset |
- Returns
- Negative error code or 0 in case of success.
◆ ad5791_spi_write_mask()
| 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.
SPI write to device using a mask.
- Parameters
-
| dev | - The device structure. |
| register_address | - Address of the register. Example: AD5791_REG_DAC - DAC register AD5791_REG_CTRL - Control register AD5791_REG_CLR_CODE - Clearcode register AD5791_CMD_WR_SOFT_CTRL - Software control register |
| mask | - The mask. |
| value | - The register data. |
- Returns
- 0 in case of success, negative error code otherwise.