no-OS
|
Implementation of AD5761R Driver. More...
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "ad5761r.h"
#include "no_os_alloc.h"
Implementation of AD5761R Driver.
Copyright 2015(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.
int32_t ad5761r_config | ( | struct ad5761r_dev * | dev | ) |
Configure the part based on the settings stored in the device structure.
dev | - The device structure. |
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.
dev | - The device structure. |
en_dis | - The status of the twos complement bipolar output range (enabled, disabled). |
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.
dev | - The device structure. |
bo | - The status of the brownout condition (detected, not detected). |
int32_t ad5761r_get_clear_voltage | ( | struct ad5761r_dev * | dev, |
enum ad5761r_scale * | cv | ||
) |
Get the clear voltage.
dev | - The device structure. |
cv | - The clear voltage. |
int32_t ad5761r_get_clr_pin | ( | struct ad5761r_dev * | dev, |
uint8_t * | value | ||
) |
Get the clr pin value.
dev | - The device structure. |
value | - The pin value. |
int32_t ad5761r_get_daisy_chain_en_dis | ( | struct ad5761r_dev * | dev, |
bool * | en_dis | ||
) |
Get the status of the daisy-chain mode.
dev | - The device structure. |
en_dis | - The status of the daisy-chain mode (enabled, disabled). |
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.
dev | - The device structure. |
en_dis | - The status of the ETS function (enabled, disabled). |
int32_t ad5761r_get_internal_reference_en_dis | ( | struct ad5761r_dev * | dev, |
bool * | en_dis | ||
) |
Get the status of the internal reference.
dev | - The device structure. |
en_dis | - The status of the internal reference (enabled, disabled). |
int32_t ad5761r_get_ldac_pin | ( | struct ad5761r_dev * | dev, |
uint8_t * | value | ||
) |
Get the ldac pin value.
dev | - The device structure. |
value | - The pin value. |
int32_t ad5761r_get_output_range | ( | struct ad5761r_dev * | dev, |
enum ad5761r_range * | out_range | ||
) |
Get the output_range.
dev | - The device structure. |
out_range | - The output range values. |
int32_t ad5761r_get_overrange_en_dis | ( | struct ad5761r_dev * | dev, |
bool * | en_dis | ||
) |
Get the status of the 5% overrange.
dev | - The device structure. |
en_dis | - The status of the twos 5% overrange (enabled, disabled). |
int32_t ad5761r_get_power_up_voltage | ( | struct ad5761r_dev * | dev, |
enum ad5761r_scale * | pv | ||
) |
Get the power up voltage.
dev | - The device structure. |
pv | - The power up voltage. |
int32_t ad5761r_get_reset_pin | ( | struct ad5761r_dev * | dev, |
uint8_t * | value | ||
) |
Get the reset pin value.
dev | - The device structure. |
value | - The pin value. |
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.
dev | - The device structure. |
sc | - The status of the short-circuit condition (detected, not detected). |
int32_t ad5761r_init | ( | struct ad5761r_dev ** | device, |
struct ad5761r_init_param | init_param | ||
) |
Initialize the device.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int32_t ad5761r_read | ( | struct ad5761r_dev * | dev, |
uint8_t | reg_addr_cmd, | ||
uint16_t * | reg_data | ||
) |
SPI read from device.
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. |
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.
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. |
int32_t ad5761r_remove | ( | struct ad5761r_dev * | dev | ) |
Free the resources allocated by ad5761r_init().
dev | - The device structure. |
int32_t ad5761r_set_2c_bipolar_range_en_dis | ( | struct ad5761r_dev * | dev, |
bool | en_dis | ||
) |
Enable/disable the twos complement bipolar output range.
dev | - The device structure. |
en_dis | - Set true in order to enable the twos complement bipolar output range. Accepted values: true false |
int32_t ad5761r_set_clear_voltage | ( | struct ad5761r_dev * | dev, |
enum ad5761r_scale | cv | ||
) |
Set the clear voltage.
dev | - The device structure. |
cv | - The clear voltage. Accepted values: AD5761R_SCALE_ZERO AD5761R_SCALE_HALF AD5761R_SCALE_FULL |
int32_t ad5761r_set_clr_pin | ( | struct ad5761r_dev * | dev, |
uint8_t | value | ||
) |
Set the clr pin value.
dev | - The device structure. |
value | - The pin value. Accepted values: NO_OS_GPIO_LOW NO_OS_GPIO_HIGH |
int32_t ad5761r_set_daisy_chain_en_dis | ( | struct ad5761r_dev * | dev, |
bool | en_dis | ||
) |
Enable/disable daisy-chain mode.
dev | - The device structure. |
en_dis | - Set true in order to enable the daisy-chain mode. Accepted values: true false |
int32_t ad5761r_set_exceed_temp_shutdown_en_dis | ( | struct ad5761r_dev * | dev, |
bool | en_dis | ||
) |
Enable/disable ETS (exceed temperature shutdown) function.
dev | - The device structure. |
en_dis | - Set true in order to enable the ETS function. Accepted values: true false |
int32_t ad5761r_set_internal_reference_en_dis | ( | struct ad5761r_dev * | dev, |
bool | en_dis | ||
) |
Enable/disable internal reference.
dev | - The device structure. |
en_dis | - Set true in order to enable the internal reference. Accepted values: true false |
int32_t ad5761r_set_ldac_pin | ( | struct ad5761r_dev * | dev, |
uint8_t | value | ||
) |
Set the ldac pin value.
dev | - The device structure. |
value | - The pin value. Accepted values: NO_OS_GPIO_LOW NO_OS_GPIO_HIGH |
int32_t ad5761r_set_output_range | ( | struct ad5761r_dev * | dev, |
enum ad5761r_range | out_range | ||
) |
Set the output_range.
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 |
int32_t ad5761r_set_overrange_en_dis | ( | struct ad5761r_dev * | dev, |
bool | en_dis | ||
) |
Enable/disable the 5% overrange.
dev | - The device structure. |
en_dis | - Set true in order to enable the 5% overrange. Accepted values: true false |
int32_t ad5761r_set_power_up_voltage | ( | struct ad5761r_dev * | dev, |
enum ad5761r_scale | pv | ||
) |
Set the power up voltage.
dev | - The device structure. |
pv | - The power up voltage. Accepted values: AD5761R_SCALE_ZERO AD5761R_SCALE_HALF AD5761R_SCALE_FULL |
int32_t ad5761r_set_reset_pin | ( | struct ad5761r_dev * | dev, |
uint8_t | value | ||
) |
Set the reset pin value.
dev | - The device structure. |
value | - The pin value. Accepted values: NO_OS_GPIO_LOW NO_OS_GPIO_HIGH |
int32_t ad5761r_software_data_reset | ( | struct ad5761r_dev * | dev | ) |
Software data reset.
dev | - The device structure. |
int32_t ad5761r_software_full_reset | ( | struct ad5761r_dev * | dev | ) |
Software full reset.
dev | - The device structure. |
int32_t ad5761r_update_dac_register | ( | struct ad5761r_dev * | dev | ) |
Update DAC register.
dev | - The device structure. |
int32_t ad5761r_write | ( | struct ad5761r_dev * | dev, |
uint8_t | reg_addr_cmd, | ||
uint16_t | reg_data | ||
) |
SPI write to device.
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. |
int32_t ad5761r_write_input_register | ( | struct ad5761r_dev * | dev, |
uint16_t | dac_data | ||
) |
Write to input register.
dev | - The device structure. |
dac_data | - The DAC data. |
int32_t ad5761r_write_update_dac_register | ( | struct ad5761r_dev * | dev, |
uint16_t | dac_data | ||
) |
Write to input register and update DAC register.
dev | - The device structure. |
dac_data | - The register data. |