Implementation of AD5791 Driver. More...
Functions | |
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. | |
Implementation of AD5791 Driver.
Copyright 2013(c) Analog Devices, Inc.
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, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 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.
int ad5791_clear_async | ( | struct ad5791_dev * | dev | ) |
Clear DAC channel output with the clearcode.
dev | - The device structure. |
int32_t ad5791_dac_ouput_state | ( | struct ad5791_dev * | dev, |
uint8_t | state ) |
Sets the DAC output in one of the three states.
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 |
int32_t ad5791_get_register_value | ( | struct ad5791_dev * | dev, |
uint8_t | register_address, | ||
uint32_t * | value ) |
Reads the value of a register.
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. |
int32_t ad5791_init | ( | struct ad5791_dev ** | device, |
struct ad5791_init_param | init_param ) |
Initializes the communication with the device.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int ad5791_ldac_trigger | ( | struct ad5791_dev * | dev | ) |
Trigger LDAC.
dev | - The device structure. |
int32_t ad5791_remove | ( | struct ad5791_dev * | dev | ) |
Free the resources allocated by ad5791_init().
dev | - The device structure. |
int32_t ad5791_set_dac_value | ( | struct ad5791_dev * | dev, |
uint32_t | value ) |
Writes to the DAC register.
dev | - The device structure. |
value | - The value to be written to DAC. |
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.
dev | - The device structure. |
v_span | - voltage span to set the corresponding lin_comp value. |
int32_t ad5791_set_register_value | ( | struct ad5791_dev * | dev, |
uint8_t | register_address, | ||
uint32_t | register_value ) |
Writes data into a register.
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. |
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.
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. |
int32_t ad5791_soft_instruction | ( | struct ad5791_dev * | dev, |
uint8_t | instruction_bit ) |
Asserts RESET, CLR or LDAC in a software manner.
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 |
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.
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. |