no-OS
|
Header file of AD5754R Driver. More...
#include <stdint.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
#include "no_os_error.h"
Go to the source code of this file.
Classes | |
struct | ad5754r_init_param |
ad5754r Device initialization parameters. More... | |
struct | ad5754r_dev |
ad5754r Device structure. More... | |
Functions | |
int | ad5754r_write (struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t reg_val) |
Write device register. More... | |
int | ad5754r_read (struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t *reg_val) |
Read device register. More... | |
int | ad5754r_update_bits (struct ad5754r_dev *dev, uint8_t instr_addr, uint16_t mask, uint16_t reg_val) |
Update specific register bits. More... | |
int | ad5754r_update_dac_ch_register (struct ad5754r_dev *dev, uint8_t chn, uint16_t value) |
Update DAC register value for specific channel. More... | |
int | ad5754r_update_dac_all_ch_registers (struct ad5754r_dev *dev, uint16_t value) |
Update DAC register value for all channels. More... | |
int | ad5754r_ldac_trigger (struct ad5754r_dev *dev) |
Trigger LDAC. More... | |
int | ad5754r_clear_async (struct ad5754r_dev *dev) |
Clear DAC output for all channels. More... | |
int | ad5754r_read_dac_ch_register (struct ad5754r_dev *dev, uint8_t chn, uint16_t *value) |
Read DAC register value for specific channel. More... | |
int | ad5754r_dac_code_to_mvolts (struct ad5754r_dev *dev, uint8_t chn, uint16_t code, uint16_t *value) |
Convert DAC code to millivolts for specific channel. More... | |
int | ad5754r_dac_mvolts_to_code (struct ad5754r_dev *dev, uint8_t chn, uint16_t mvolts, uint16_t *code) |
Convert DAC millivolts to code for specific channel. More... | |
int | ad5754r_set_ch_range (struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_dac_ch_range ch_range) |
Set output range for specific channel. More... | |
int | ad5754r_set_ch_pwrup (struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_pwr_dac_ch_pwrup ch_pwrup) |
Set power-up state for specific channel. More... | |
int | ad5754r_set_current_clamp_en (struct ad5754r_dev *dev, enum ad5754r_ctrl_current_clamp_en clamp_en) |
Apply current clamp setting for device. More... | |
int | ad5754r_set_tsd_en (struct ad5754r_dev *dev, enum ad5754r_ctrl_tsd_en tsd_en) |
Apply TSD setting for device. More... | |
int | ad5754r_set_clear_mode (struct ad5754r_dev *dev, enum ad5754r_ctrl_clear_sel clear_sel) |
Set clear mode setting for device. More... | |
int | ad5754r_set_sdo_disable (struct ad5754r_dev *dev, enum ad5754r_ctrl_sdo_dis sdo_dis) |
Set SDO Enable/Disable state for device. More... | |
int | ad5754r_set_int_ref_pwrup (struct ad5754r_dev *dev, enum ad5754r_pwr_int_ref_pwrup int_ref_pwrup) |
Set Internal Reference Enable/Disable state for device. More... | |
int | ad5754r_get_oc_ch_alert (struct ad5754r_dev *dev, uint8_t chn, enum ad5754r_pwr_oc_ch_alert *oc_ch_alert) |
Get Over-current status bit for specific channel. More... | |
int | ad5754r_get_tsd_alert (struct ad5754r_dev *dev, enum ad5754r_pwr_tsd_alert *tsd_alert) |
Get Thermal Shutdown status bit. More... | |
int | ad5754r_spi_verify (struct ad5754r_dev *dev) |
Write to and read back a register to verify SPI. More... | |
int | ad5754r_gpio_init (struct ad5754r_dev *dev, struct ad5754r_init_param *init_param) |
Do GPIO initialization and config for AD5754R. More... | |
int | ad5754r_reg_init (struct ad5754r_dev *dev, struct ad5754r_init_param *init_param) |
Initialize registers based on init parameters. More... | |
int | ad5754r_init (struct ad5754r_dev **device, struct ad5754r_init_param *init_param) |
Initialize the device. More... | |
int | ad5754r_remove_gpios (struct ad5754r_dev *dev) |
Remove GPIOs and free resources. More... | |
int | ad5754r_remove (struct ad5754r_dev *dev) |
Remove the device and release resources. More... | |
Variables | |
const unsigned int | ad5754r_gain_values_scaled [AD5754R_SPAN_M10V8_TO_10V8+1] |
Header file of AD5754R Driver.
Copyright 2023(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.
#define AD5754R_ADDR_DAC_CH | ( | x | ) | no_os_field_prep(AD5754R_ADDR_DAC_CH_MASK, x) |
#define AD5754R_ADDR_DAC_CH_MASK NO_OS_GENMASK(2, 0) |
#define AD5754R_ADDR_REG | ( | x | ) | no_os_field_prep(AD5754R_ADDR_REG_MASK, x) |
#define AD5754R_ADDR_REG_MASK NO_OS_GENMASK(5, 3) |
#define AD5754R_BYTE_H NO_OS_GENMASK(15, 8) |
#define AD5754R_BYTE_L NO_OS_GENMASK(7, 0) |
#define AD5754R_CTRL_CLAMP_EN | ( | X | ) | no_os_field_prep(NO_OS_BIT(2), x) |
#define AD5754R_CTRL_CLAMP_EN_MASK NO_OS_BIT(2) |
#define AD5754R_CTRL_CLEAR 0 |
#define AD5754R_CTRL_CLR_SEL | ( | x | ) | no_os_field_prep(NO_OS_BIT(1), x) |
#define AD5754R_CTRL_CLR_SEL_MASK NO_OS_BIT(1) |
#define AD5754R_CTRL_LOAD 0 |
#define AD5754R_CTRL_NOP 0 |
#define AD5754R_CTRL_SDO_DISABLE | ( | x | ) | (x) |
#define AD5754R_CTRL_SDO_DISABLE_MASK NO_OS_BIT(0) |
#define AD5754R_CTRL_TSD_EN | ( | x | ) | no_os_field_prep(NO_OS_BIT(3), x) |
#define AD5754R_CTRL_TSD_EN_MASK NO_OS_BIT(3) |
#define AD5754R_DAC_CH_A_ADDR 0 |
#define AD5754R_DAC_CH_ALL_ADDR 4 |
#define AD5754R_DAC_CH_B_ADDR 1 |
#define AD5754R_DAC_CH_C_ADDR 2 |
#define AD5754R_DAC_CH_D_ADDR 3 |
#define AD5754R_GAIN_SCALE 1000 |
#define AD5754R_INSTR_CLEAR 0x1C |
#define AD5754R_INSTR_LOAD 0x1D |
#define AD5754R_INSTR_NOP 0x18 |
#define AD5754R_MAX_RESOLUTION 16 |
#define AD5754R_NUM_CHANNELS 4 |
#define AD5754R_OUTPUT_RANGE_SEL_MASK NO_OS_GENMASK(2,0) |
#define AD5754R_PREP_INSTR_ADDR | ( | reg, | |
dac_ch | |||
) |
#define AD5754R_PWR_OC_ALERT_CH_MASK | ( | x | ) |
#define AD5754R_PWR_OC_ALERT_MASK NO_OS_GENMASK(10,7) |
#define AD5754R_PWR_TSD_ALERT_MASK NO_OS_BIT(5) |
#define AD5754R_PWR_UP_DAC_CH_MASK | ( | x | ) | NO_OS_BIT(x) |
#define AD5754R_PWR_UP_INT_REF_MASK NO_OS_BIT(4) |
#define AD5754R_READ NO_OS_BIT(7) |
#define AD5754R_REG_CONTROL 3 |
#define AD5754R_REG_DAC 0 |
#define AD5754R_REG_OUTPUT_RANGE_SEL 1 |
#define AD5754R_REG_PWR_CTRL 2 |
#define AD5754R_WRITE 0 |
enum ad5754r_ctrl_sdo_dis |
enum ad5754r_ctrl_tsd_en |
enum ad5754r_dac_ch_range |
enum ad5754r_dac_channels |
int ad5754r_clear_async | ( | struct ad5754r_dev * | dev | ) |
Clear DAC output for all channels.
Clear DAC output for all channels.
dev | - The device structure. |
int ad5754r_dac_code_to_mvolts | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
uint16_t | code, | ||
uint16_t * | value | ||
) |
Convert DAC code to millivolts for specific channel.
Convert DAC code to millivolts for specific channel.
dev | - The device structure. |
chn | - The index of channel being addressed. |
code | - DAC code |
value | - Millivolts output calculated using DAC code. |
int ad5754r_dac_mvolts_to_code | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
uint16_t | mvolts, | ||
uint16_t * | code | ||
) |
Convert DAC millivolts to code for specific channel.
Convert DAC millivolts to code for specific channel.
dev | - The device structure. |
chn | - The index of channel being addressed. |
mvolts | - Desired millivolts ouput for specific channel |
code | - DAC code for desired output voltage |
int ad5754r_get_oc_ch_alert | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
enum ad5754r_pwr_oc_ch_alert * | oc_ch_alert | ||
) |
Get Over-current status bit for specific channel.
Get Over-current status bit for specific channel,
dev | - The device structure. |
chn | - The index of channel being addressed. |
oc_ch_alert | - Store channel overcurrent alert status. |
int ad5754r_get_tsd_alert | ( | struct ad5754r_dev * | dev, |
enum ad5754r_pwr_tsd_alert * | tsd_alert | ||
) |
Get Thermal Shutdown status bit.
Get Thermal Shutdown status bit.
dev | - The device structure. |
tsd_alert | - Store TSD alert status. |
int ad5754r_gpio_init | ( | struct ad5754r_dev * | dev, |
struct ad5754r_init_param * | init_param | ||
) |
Do GPIO initialization and config for AD5754R.
Do GPIO initialization and config for AD5754R
dev | - The device structure. |
init_param | - Pointer to structure containing the device initial parameters. |
int ad5754r_init | ( | struct ad5754r_dev ** | device, |
struct ad5754r_init_param * | init_param | ||
) |
Initialize the device.
Initializes the communication with the device.
device | - The device structure. |
init_param | - Pointer to structure containing the device initial parameters. |
int ad5754r_ldac_trigger | ( | struct ad5754r_dev * | dev | ) |
Trigger LDAC.
dev | - The device structure. |
int ad5754r_read | ( | struct ad5754r_dev * | dev, |
uint8_t | instr_addr, | ||
uint16_t * | reg_val | ||
) |
Read device register.
Reads data from a register.
dev | - The device structure. |
instr_addr | - The instruction address comprising register and dac channel address. |
reg_val | - The data read from the register. |
int ad5754r_read_dac_ch_register | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
uint16_t * | value | ||
) |
Read DAC register value for specific channel.
Read DAC register value for specific channel.
dev | - The device structure. |
chn | - The index of channel being addressed. |
value | - The data read from dac channel register. |
int ad5754r_reg_init | ( | struct ad5754r_dev * | dev, |
struct ad5754r_init_param * | init_param | ||
) |
Initialize registers based on init parameters.
Initialize registers based on init parameters
dev | - The device structure. |
init_param | - Pointer to structure containing the device initial parameters. |
int ad5754r_remove | ( | struct ad5754r_dev * | dev | ) |
Remove the device and release resources.
Free the resources allocated by ad5754r_init().
dev | - The device structure. |
int ad5754r_remove_gpios | ( | struct ad5754r_dev * | dev | ) |
Remove GPIOs and free resources.
Remove GPIOs and free resources.
dev | - The device structure. |
int ad5754r_set_ch_pwrup | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
enum ad5754r_pwr_dac_ch_pwrup | ch_pwrup | ||
) |
Set power-up state for specific channel.
Set power-up state for specific channel.
dev | - The device structure. |
chn | - The index of channel being addressed. |
ch_pwrup | - Powerup setting for specified channel. |
int ad5754r_set_ch_range | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
enum ad5754r_dac_ch_range | ch_range | ||
) |
Set output range for specific channel.
Set output range for specific channel.
dev | - The device structure. |
chn | - The index of channel being addressed. |
ch_range | - Range option to be set for specified channel. |
int ad5754r_set_clear_mode | ( | struct ad5754r_dev * | dev, |
enum ad5754r_ctrl_clear_sel | clear_sel | ||
) |
Set clear mode setting for device.
Set clear mode setting for device.
dev | - The device structure. |
clear_sel | - Clear mode setting for device. |
int ad5754r_set_current_clamp_en | ( | struct ad5754r_dev * | dev, |
enum ad5754r_ctrl_current_clamp_en | clamp_en | ||
) |
Apply current clamp setting for device.
Apply current clamp setting for device.
dev | - The device structure. |
clamp_en | - Clamp setting for device. |
int ad5754r_set_int_ref_pwrup | ( | struct ad5754r_dev * | dev, |
enum ad5754r_pwr_int_ref_pwrup | int_ref_pwrup | ||
) |
Set Internal Reference Enable/Disable state for device.
Set Internal Reference Enable/Disable state for device.
dev | - The device structure. |
int_ref_pwrup | - Internal Reference Enable/Disable state for device. |
int ad5754r_set_sdo_disable | ( | struct ad5754r_dev * | dev, |
enum ad5754r_ctrl_sdo_dis | sdo_dis | ||
) |
Set SDO Enable/Disable state for device.
Set SDO Enable/Disable state for device.
dev | - The device structure. |
sdo_dis | - SDO Enable/Disable state for device. |
int ad5754r_set_tsd_en | ( | struct ad5754r_dev * | dev, |
enum ad5754r_ctrl_tsd_en | tsd_en | ||
) |
Apply TSD setting for device.
Apply tsd setting for device.
dev | - The device structure. |
tsd_en | - TSD setting for device. |
int ad5754r_spi_verify | ( | struct ad5754r_dev * | dev | ) |
Write to and read back a register to verify SPI.
Update and readback a register to verify SPI.
dev | - The device structure. |
int ad5754r_update_bits | ( | struct ad5754r_dev * | dev, |
uint8_t | instr_addr, | ||
uint16_t | mask, | ||
uint16_t | reg_val | ||
) |
Update specific register bits.
Update specific register bits
dev | - The device structure. |
instr_addr | - The instruction address comprising register and dac channel address. |
mask | - Specific bits mask. |
reg_val | - The data to be written. |
int ad5754r_update_dac_all_ch_registers | ( | struct ad5754r_dev * | dev, |
uint16_t | value | ||
) |
Update DAC register value for all channels.
Update DAC register value for all channels.
dev | - The device structure. |
value | - The data to be written to the dac channel registers. |
int ad5754r_update_dac_ch_register | ( | struct ad5754r_dev * | dev, |
uint8_t | chn, | ||
uint16_t | value | ||
) |
Update DAC register value for specific channel.
Update DAC register value for specific channel.
dev | - The device structure. |
chn | - The index of channel being addressed. |
value | - The data to be written to the dac channel. |
int ad5754r_write | ( | struct ad5754r_dev * | dev, |
uint8_t | instr_addr, | ||
uint16_t | reg_val | ||
) |
Write device register.
Writes data into a register.
dev- | The device structure. |
instr_addr | - The instruction address comprising register and dac channel address. |
reg_val | - The data to be written. |
const unsigned int ad5754r_gain_values_scaled[AD5754R_SPAN_M10V8_TO_10V8+1] |