![]() |
no-OS
|
Implementation of ad5710r Driver. More...
#include "ad5710r.h"#include <stdlib.h>#include <string.h>#include "no_os_delay.h"#include "no_os_error.h"#include "no_os_print_log.h"#include "no_os_gpio.h"#include "no_os_spi.h"#include "no_os_util.h"Macros | |
| #define | AD5710R_DATA_INDEX(x) |
| #define | AD5710R_INSTR_LEN(x) |
| #define | AD5710R_ADDR_INDEX(x) |
| #define | AD5710R_BUFF_LEN(x) |
| #define | AD5710R_CRC_BUFF_LEN(x) |
| #define | AD5710R_CRC_INDEX(x) |
Functions | |
| int | ad5710r_update_interface_cfg (struct ad5710r_desc *desc, struct ad5710r_transfer_config *cfg) |
| Updates the interface configuration. | |
| int | ad5710r_reg_write (struct ad5710r_desc *desc, uint32_t reg_addr, uint16_t reg_val) |
| Write into device register. | |
| int | ad5710r_multiple_reg_write (struct ad5710r_desc *desc, uint32_t start_addr, uint8_t count, uint8_t *buff) |
| Write multiple register's values. | |
| int | ad5710r_reg_read (struct ad5710r_desc *desc, uint32_t reg_addr, uint16_t *reg_val) |
| Read from device register. | |
| int | ad5710r_multiple_reg_read (struct ad5710r_desc *desc, uint32_t addr, uint8_t count, uint8_t *buff) |
| Read multiple register's values. | |
| int | ad5710r_spi_write_mask (struct ad5710r_desc *desc, uint32_t addr, uint32_t mask, uint16_t val) |
| SPI write to device using a mask. | |
| int | ad5710r_set_reference (struct ad5710r_desc *desc, enum ad5710r_ch_vref_select reference_selector) |
| Set reference configuration. | |
| int | ad5710r_set_operating_mode (struct ad5710r_desc *desc, uint8_t chn_num, enum ad5710r_operating_mode chn_op_mode) |
| Set operating mode for each channel. | |
| int | ad5710r_set_output_range (struct ad5710r_desc *desc, enum ad5710r_ch_output_range range_sel) |
| Set output range for all channels. | |
| int | ad5710r_set_crc_enable (struct ad5710r_desc *desc, bool en_di) |
| Configures the CRC selection bit. | |
| int | ad5710r_set_mux_out_select (struct ad5710r_desc *desc, enum ad5710r_mux_out_select mux_output_sel) |
| Set the multiplexer output select register. | |
| int | ad5710r_set_hw_ldac (struct ad5710r_desc *desc, uint8_t mask_hw_ldac) |
| Set the hardware ldac configuration. | |
| int | ad5710r_set_sw_ldac (struct ad5710r_desc *desc, uint8_t mask_sw_ldac) |
| Set the software ldac configuration. | |
| int | ad5710r_set_dac_value (struct ad5710r_desc *desc, uint16_t dac_value, uint8_t dac_channel, enum ad5710r_write_mode write_mode) |
| Set dac value based on the user selected DAC update mode. | |
| int | ad5710r_set_multidac_value (struct ad5710r_desc *desc, uint16_t dac_value, uint8_t dac_chn_mask, enum ad5710r_write_mode write_mode) |
| Sets dac value for multiple channels. | |
| int | ad5710r_sw_ldac_trigger (struct ad5710r_desc *desc) |
| Trigger the LDAC using software. | |
| int | ad5710r_hw_ldac_trigger (struct ad5710r_desc *desc) |
| Trigger the LDAC using hardware. | |
| int | ad5710r_reset (struct ad5710r_desc *desc) |
| Perform a hard/soft reset. | |
| int | ad5710r_channel_output_select (struct ad5710r_desc *desc, uint8_t chn_num, enum ad5710r_ch_mode_select ch_mode) |
| Selects the output mode for a specific channel of the AD5710R DAC. | |
| int | ad5710r_device_config (struct ad5710r_desc *desc, struct ad5710r_init_param *dev_param) |
| Configures the device. | |
| int | ad5710r_init (struct ad5710r_desc **desc, struct ad5710r_init_param *init_param) |
| Initialize the device structure. | |
| int | ad5710r_remove (struct ad5710r_desc *desc) |
| Free the device descriptor. | |
Implementation of ad5710r Driver.
Copyright 2025(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define AD5710R_ADDR_INDEX | ( | x | ) |
| #define AD5710R_BUFF_LEN | ( | x | ) |
| #define AD5710R_CRC_BUFF_LEN | ( | x | ) |
| #define AD5710R_CRC_INDEX | ( | x | ) |
| #define AD5710R_DATA_INDEX | ( | x | ) |
| #define AD5710R_INSTR_LEN | ( | x | ) |
| int ad5710r_channel_output_select | ( | struct ad5710r_desc * | desc, |
| uint8_t | chn_num, | ||
| enum ad5710r_ch_mode_select | ch_mode ) |
Selects the output mode for a specific channel of the AD5710R DAC.
| desc | - The device structure. |
| chn_num | - Channel number to configure. |
| ch_mode | - Output mode to select for the channel (voltage or current). |
| int ad5710r_device_config | ( | struct ad5710r_desc * | desc, |
| struct ad5710r_init_param * | dev_param ) |
Configures the device.
| desc | - The device structure to be initialized. |
| dev_param | - Configuration parameters for the device. |
| int ad5710r_hw_ldac_trigger | ( | struct ad5710r_desc * | desc | ) |
Trigger the LDAC using hardware.
| desc | - The device structure. |
| int ad5710r_init | ( | struct ad5710r_desc ** | desc, |
| struct ad5710r_init_param * | init_param ) |
Initialize the device structure.
| desc | - The device structure to be initialized. |
| init_param | - Initialization parameter for the device descriptor. |
| int ad5710r_multiple_reg_read | ( | struct ad5710r_desc * | desc, |
| uint32_t | addr, | ||
| uint8_t | count, | ||
| uint8_t * | buff ) |
Read multiple register's values.
| desc | - The device structure. |
| addr | - Starting register address to read from. |
| count | - Number of bytes to read. |
| buff | - Buffer to store data. |
| int ad5710r_multiple_reg_write | ( | struct ad5710r_desc * | desc, |
| uint32_t | start_addr, | ||
| uint8_t | count, | ||
| uint8_t * | buff ) |
Write multiple register's values.
| desc | - The device structure. |
| start_addr | - Starting register address to write into. |
| count | - Number of bytes to write. |
| buff | - Buffer to write data from. |
| int ad5710r_reg_read | ( | struct ad5710r_desc * | desc, |
| uint32_t | reg_addr, | ||
| uint16_t * | reg_val ) |
Read from device register.
| desc | - The device structure. |
| reg_addr | - The register's address. |
| reg_val | - The register's read value. |
| int ad5710r_reg_write | ( | struct ad5710r_desc * | desc, |
| uint32_t | reg_addr, | ||
| uint16_t | reg_val ) |
Write into device register.
| desc | - The device structure. |
| reg_addr | - The register's address. |
| reg_val | - The register's value. |
| int ad5710r_remove | ( | struct ad5710r_desc * | desc | ) |
Free the device descriptor.
| desc | - The device structure. |
| int ad5710r_reset | ( | struct ad5710r_desc * | desc | ) |
Perform a hard/soft reset.
| desc | - The device structure. |
| int ad5710r_set_crc_enable | ( | struct ad5710r_desc * | desc, |
| bool | en_di ) |
Configures the CRC selection bit.
| desc | - The device structure. |
| en_di | - boolean selection for crc bit. |
| int ad5710r_set_dac_value | ( | struct ad5710r_desc * | desc, |
| uint16_t | dac_value, | ||
| uint8_t | dac_channel, | ||
| enum ad5710r_write_mode | write_mode ) |
Set dac value based on the user selected DAC update mode.
| desc | - The device structure. |
| dac_value | - value that will be set in the register. |
| dac_channel | - selected channel. |
| write_mode | - selected write mode. |
| int ad5710r_set_hw_ldac | ( | struct ad5710r_desc * | desc, |
| uint8_t | mask_hw_ldac ) |
Set the hardware ldac configuration.
| desc | - The device structure. |
| mask_hw_ldac | - The array contains HW LDAC channel masks. |
| int ad5710r_set_multidac_value | ( | struct ad5710r_desc * | desc, |
| uint16_t | dac_value, | ||
| uint8_t | dac_chn_mask, | ||
| enum ad5710r_write_mode | write_mode ) |
Sets dac value for multiple channels.
| desc | - The device structure. |
| dac_value | - value that will be set in the register. |
| dac_chn_mask | - mask for selected channels. |
| write_mode | - selected write mode. |
| int ad5710r_set_mux_out_select | ( | struct ad5710r_desc * | desc, |
| enum ad5710r_mux_out_select | mux_output_sel ) |
Set the multiplexer output select register.
| desc | - The device structure. |
| mux_output_sel | - signal to be monitored on the mux_out pin. |
| int ad5710r_set_operating_mode | ( | struct ad5710r_desc * | desc, |
| uint8_t | chn_num, | ||
| enum ad5710r_operating_mode | chn_op_mode ) |
Set operating mode for each channel.
| desc | - The device structure. |
| chn_num | - Channel number to be configured. |
| chn_op_mode | - Operation mode to be set. |
| int ad5710r_set_output_range | ( | struct ad5710r_desc * | desc, |
| enum ad5710r_ch_output_range | range_sel ) |
Set output range for all channels.
| desc | - The device structure. |
| range_sel | - Output range to be selected. |
| int ad5710r_set_reference | ( | struct ad5710r_desc * | desc, |
| enum ad5710r_ch_vref_select | reference_selector ) |
Set reference configuration.
| desc | - The device structure. |
| reference_selector | - The reference to be selected. |
| int ad5710r_set_sw_ldac | ( | struct ad5710r_desc * | desc, |
| uint8_t | mask_sw_ldac ) |
Set the software ldac configuration.
| desc | - The device structure. |
| mask_sw_ldac | - The array contains SW LDAC channel masks. |
| int ad5710r_spi_write_mask | ( | struct ad5710r_desc * | desc, |
| uint32_t | addr, | ||
| uint32_t | mask, | ||
| uint16_t | val ) |
SPI write to device using a mask.
| desc | - The device structure. |
| addr | - The register's address. |
| mask | - The mask for a specific register field. |
| val | - The register's value. |
| int ad5710r_sw_ldac_trigger | ( | struct ad5710r_desc * | desc | ) |
Trigger the LDAC using software.
| desc | - The device structure. |
| int ad5710r_update_interface_cfg | ( | struct ad5710r_desc * | desc, |
| struct ad5710r_transfer_config * | cfg ) |
Updates the interface configuration.
| desc | - The device structure. |
| cfg | - Updated interface configuration structure. |