Implementation of AD5761R Driver.
More...
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "ad5761r.h"
#include "no_os_alloc.h"
|
| 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 dac_data) |
| |
| int32_t | ad5761r_update_dac_register (struct ad5761r_dev *dev) |
| |
| int32_t | ad5761r_write_update_dac_register (struct ad5761r_dev *dev, uint16_t dac_data) |
| |
| int32_t | ad5761r_software_data_reset (struct ad5761r_dev *dev) |
| |
| int32_t | ad5761r_software_full_reset (struct ad5761r_dev *dev) |
| |
| 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().
|
| |
Implementation 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
◆ ad5761r_config()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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.