no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad3530r.c File Reference
#include "ad3530r.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"
Include dependency graph for ad3530r.c:

Macros

#define AD3530R_DATA_INDEX(x)
 
#define AD3530R_INSTR_LEN(x)
 
#define AD3530R_ADDR_INDEX(x)
 
#define AD3530R_BUFF_LEN(x)
 
#define AD3530R_CRC_BUFF_LEN(x)
 
#define AD3530R_CRC_INDEX(x)
 

Functions

uint32_t get_reg_addr (uint32_t addr, enum ad3530r_id chip_id, enum ad3530r_ch_sel ch_sel)
 Get adjusted register address based on the chip id selected.
 
int ad3530r_update_interface_cfg (struct ad3530r_desc *desc, struct ad3530r_transfer_config *cfg)
 Updates the interface configuration.
 
int ad3530r_reg_write (struct ad3530r_desc *desc, uint32_t reg_addr, uint16_t reg_val)
 Write into device register.
 
int ad3530r_multiple_reg_write (struct ad3530r_desc *desc, uint32_t start_addr, uint8_t count, uint8_t *buff)
 Write multiple register's values.
 
int ad3530r_reg_read (struct ad3530r_desc *desc, uint32_t reg_addr, uint16_t *reg_val)
 Read from device register.
 
int ad3530r_multiple_reg_read (struct ad3530r_desc *desc, uint32_t addr, uint8_t count, uint8_t *buff)
 Read multiple register's values.
 
int ad3530r_spi_write_mask (struct ad3530r_desc *desc, uint32_t addr, uint32_t mask, uint16_t val)
 SPI write to device using a mask.
 
int ad3530r_set_reference (struct ad3530r_desc *desc, enum ad3530r_ch_vref_select reference_selector)
 
int ad3530r_set_operating_mode (struct ad3530r_desc *desc, uint8_t chn_num, enum ad3530r_operating_mode chn_op_mode)
 
int ad3530r_set_output_range (struct ad3530r_desc *desc, enum ad3530r_ch_output_range range_sel)
 
int ad3530r_set_crc_enable (struct ad3530r_desc *desc, bool en_di)
 
int ad3530r_set_mux_out_select (struct ad3530r_desc *desc, enum ad3530r_mux_out_select mux_output_sel)
 
int ad3530r_set_hw_ldac (struct ad3530r_desc *desc, uint16_t mask_hw_ldac)
 
int ad3530r_set_sw_ldac (struct ad3530r_desc *desc, uint16_t mask_sw_ldac)
 
int ad3530r_set_dac_value (struct ad3530r_desc *desc, uint16_t dac_value, uint8_t dac_channel, enum ad3530r_write_mode write_mode)
 
int ad3530r_set_multidac_value (struct ad3530r_desc *desc, uint16_t dac_value, uint16_t dac_chn_mask, enum ad3530r_write_mode write_mode)
 
int ad3530r_sw_ldac_trigger (struct ad3530r_desc *desc)
 Trigger the LDAC using software.
 
int ad3530r_hw_ldac_trigger (struct ad3530r_desc *desc)
 Trigger the LDAC using hardware.
 
int ad3530r_reset (struct ad3530r_desc *desc)
 Perform a hard/soft reset.
 
int ad3530r_device_config (struct ad3530r_desc *desc, struct ad3530r_init_param *dev_param)
 Configures the device.
 
int ad3530r_init (struct ad3530r_desc **desc, struct ad3530r_init_param *init_param)
 Initialize the device structure.
 
int ad3530r_remove (struct ad3530r_desc *desc)
 Free the device descriptor.
 

Detailed Description

Author
Sai Kiran Gudla (Saiki.nosp@m.ran..nosp@m.Gudla.nosp@m.@ana.nosp@m.log.c.nosp@m.om)

Copyright (c) 2025 Analog Devices, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Macro Definition Documentation

◆ AD3530R_ADDR_INDEX

#define AD3530R_ADDR_INDEX ( x)
Value:
(x) ? 0 : 1

◆ AD3530R_BUFF_LEN

#define AD3530R_BUFF_LEN ( x)
Value:
(x) ? 2 : 3

◆ AD3530R_CRC_BUFF_LEN

#define AD3530R_CRC_BUFF_LEN ( x)
Value:
(x) ? 3 : 4

◆ AD3530R_CRC_INDEX

#define AD3530R_CRC_INDEX ( x)
Value:
#define AD3530R_ADDR_INDEX(x)
Definition ad3530r.c:44

◆ AD3530R_DATA_INDEX

#define AD3530R_DATA_INDEX ( x)
Value:
(x) ? 1 : 2

◆ AD3530R_INSTR_LEN

#define AD3530R_INSTR_LEN ( x)
Value:
#define AD3530R_DATA_INDEX(x)
Definition ad3530r.c:42

Function Documentation

◆ ad3530r_device_config()

int ad3530r_device_config ( struct ad3530r_desc * desc,
struct ad3530r_init_param * dev_param )

Configures the device.

Parameters
desc- The device structure to be initialized.
dev_param- Configuration parameters for the device.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_hw_ldac_trigger()

int ad3530r_hw_ldac_trigger ( struct ad3530r_desc * desc)

Trigger the LDAC using hardware.

Parameters
desc- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_init()

int ad3530r_init ( struct ad3530r_desc ** desc,
struct ad3530r_init_param * init_param )

Initialize the device structure.

Parameters
desc- The device structure to be initialized.
init_param- Initialization parameter for the device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ ad3530r_multiple_reg_read()

int ad3530r_multiple_reg_read ( struct ad3530r_desc * desc,
uint32_t addr,
uint8_t count,
uint8_t * buff )

Read multiple register's values.

Parameters
desc- The device structure.
addr- Starting register address to read from.
count- Number of bytes to read.
buff- Buffer to store data.
Returns
0 in case of success, negative error otherwise.

◆ ad3530r_multiple_reg_write()

int ad3530r_multiple_reg_write ( struct ad3530r_desc * desc,
uint32_t start_addr,
uint8_t count,
uint8_t * buff )

Write multiple register's values.

Parameters
desc- The device structure.
start_addr- Starting register address to write into.
count- Number of bytes to write.
buff- Buffer to write data from.
Returns
0 in case of success, negative error otherwise.

◆ ad3530r_reg_read()

int ad3530r_reg_read ( struct ad3530r_desc * desc,
uint32_t reg_addr,
uint16_t * reg_val )

Read from device register.

Parameters
desc- The device structure.
reg_addr- The register's address.
reg_val- The register's read value.
Returns
0 in case of success, negative error otherwise.
Here is the caller graph for this function:

◆ ad3530r_reg_write()

int ad3530r_reg_write ( struct ad3530r_desc * desc,
uint32_t reg_addr,
uint16_t reg_val )

Write into device register.

Parameters
desc- The device structure.
reg_addr- The register's address.
reg_val- The register's value.
Returns
0 in case of success, negative error otherwise.
Here is the caller graph for this function:

◆ ad3530r_remove()

int ad3530r_remove ( struct ad3530r_desc * desc)

Free the device descriptor.

Parameters
desc- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad3530r_reset()

int ad3530r_reset ( struct ad3530r_desc * desc)

Perform a hard/soft reset.

Parameters
desc- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_crc_enable()

int ad3530r_set_crc_enable ( struct ad3530r_desc * desc,
bool en_di )

Configures the CRC selection bit .

Parameters
desc- The device structure.
en_di- boolean selection for crc bit.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_dac_value()

int ad3530r_set_dac_value ( struct ad3530r_desc * desc,
uint16_t dac_value,
uint8_t dac_channel,
enum ad3530r_write_mode write_mode )

Set dac value based on the user selected DAC update mode.

Parameters
desc- The device structure.
dac_value- value that will be set in the register.
dac_channel- selected channel.
write_mode- selected write mode.
Returns
0 in case of success, negative error code otherwise.

◆ ad3530r_set_hw_ldac()

int ad3530r_set_hw_ldac ( struct ad3530r_desc * desc,
uint16_t mask_hw_ldac )

Set the hardware ldac configuration.

Parameters
desc- The device structure.
mask_hw_ldac- The array contains HW LDAC channel masks.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_multidac_value()

int ad3530r_set_multidac_value ( struct ad3530r_desc * desc,
uint16_t dac_value,
uint16_t dac_chn_mask,
enum ad3530r_write_mode write_mode )

Sets dac value for multiple channels.

Parameters
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.
Returns
0 in case of success, negative error code otherwise.

◆ ad3530r_set_mux_out_select()

int ad3530r_set_mux_out_select ( struct ad3530r_desc * desc,
enum ad3530r_mux_out_select mux_output_sel )

Set the multiplexer output select register.

Parameters
desc- The device structure.
mux_output_sel- signal to be monitored on the mux_out pin.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_operating_mode()

int ad3530r_set_operating_mode ( struct ad3530r_desc * desc,
uint8_t chn_num,
enum ad3530r_operating_mode chn_op_mode )

Set operating mode for each channel.

Parameters
desc- The device structure.
chn_num- Channel number to be configured.
chn_op_mode- Operation mode to be set.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_output_range()

int ad3530r_set_output_range ( struct ad3530r_desc * desc,
enum ad3530r_ch_output_range range_sel )

Set output range for all channels.

Parameters
desc- The device structure.
range_sel- Output range to be selected.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_reference()

int ad3530r_set_reference ( struct ad3530r_desc * desc,
enum ad3530r_ch_vref_select reference_selector )

Set reference configuration.

Parameters
desc- The device structure.
reference_selector- The reference to be selected.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_set_sw_ldac()

int ad3530r_set_sw_ldac ( struct ad3530r_desc * desc,
uint16_t mask_sw_ldac )

Set the software ldac configuration.

Parameters
desc- The device structure.
mask_sw_ldac- The array contains SW LDAC channel masks.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_spi_write_mask()

int ad3530r_spi_write_mask ( struct ad3530r_desc * desc,
uint32_t addr,
uint32_t mask,
uint16_t val )

SPI write to device using a mask.

Parameters
desc- The device structure.
addr- The register's address.
mask- The mask for a specific register field.
val- The register's value.
Returns
0 in case of success, negative error otherwise.
Here is the caller graph for this function:

◆ ad3530r_sw_ldac_trigger()

int ad3530r_sw_ldac_trigger ( struct ad3530r_desc * desc)

Trigger the LDAC using software.

Parameters
desc- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3530r_update_interface_cfg()

int ad3530r_update_interface_cfg ( struct ad3530r_desc * desc,
struct ad3530r_transfer_config * cfg )

Updates the interface configuration.

Parameters
desc- The device structure.
cfg- Updated interface configuration structure.
Returns
0 in case of success, negative error otherwise.
Here is the caller graph for this function:

◆ get_reg_addr()

uint32_t get_reg_addr ( uint32_t addr,
enum ad3530r_id chip_id,
enum ad3530r_ch_sel ch_sel )

Get adjusted register address based on the chip id selected.

Parameters
addr- The Base register address.
chip_id- Device id.
ch_sel- Channel set selection. Available options: CH_0_TO_7, CH_8_TO_15
Returns
actual register address in case of success, negative error otherwise.
Here is the caller graph for this function: