no-OS
Functions
ad5770r.c File Reference

Implementation of ad5770r Driver. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "no_os_error.h"
#include "ad5770r.h"
Include dependency graph for ad5770r.c:

Functions

int32_t ad5770r_spi_reg_read (struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
 
int32_t ad5770r_spi_reg_read_multiple (struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
 
int32_t ad5770r_spi_reg_write (struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t reg_data)
 
int32_t ad5770r_spi_reg_write_multiple (struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
 
int32_t ad5770r_spi_write_mask (struct ad5770r_dev *dev, uint8_t reg_addr, uint32_t mask, uint8_t data)
 
int32_t ad5770r_set_device_spi (struct ad5770r_dev *dev, const struct ad5770r_device_spi_settings *spi_settings)
 
int32_t ad5770r_channel_config (struct ad5770r_dev *dev, const struct ad5770r_channel_switches *channel_config)
 
int32_t ad5770r_set_output_mode (struct ad5770r_dev *dev, const struct ad5770r_output_range *output_mode, enum ad5770r_channels channel)
 
int32_t ad5770r_set_reference (struct ad5770r_dev *dev, bool external_reference, enum ad5770r_reference_voltage reference_selector)
 
int32_t ad5770r_set_alarm (struct ad5770r_dev *dev, const struct ad5770r_alarm_cfg *const alarm_config)
 
int32_t ad5770r_set_output_filter (struct ad5770r_dev *dev, enum ad5770r_output_filter_resistor output_filter, enum ad5770r_channels channel)
 
int32_t ad5770r_set_hw_ldac (struct ad5770r_dev *dev, const struct ad5770r_channel_switches *mask_hw_ldac)
 
int32_t ad5770r_set_dac_value (struct ad5770r_dev *dev, uint16_t dac_value, enum ad5770r_channels channel)
 
int32_t ad5770r_set_dac_input (struct ad5770r_dev *dev, uint16_t dac_input, enum ad5770r_channels channel)
 
int32_t ad5770r_set_page_mask (struct ad5770r_dev *dev, const struct ad5770r_dac_page_mask *page_mask)
 
int32_t ad5770r_set_mask_channel (struct ad5770r_dev *dev, const struct ad5770r_channel_switches *mask_channel_sel)
 
int32_t ad5770r_set_sw_ldac (struct ad5770r_dev *dev, const struct ad5770r_channel_switches *sw_ldac)
 
int32_t ad5770r_get_status (struct ad5770r_dev *dev, uint8_t *status)
 
int32_t ad5770r_get_interface_status (struct ad5770r_dev *dev, uint8_t *status)
 
int32_t ad5770r_set_monitor_setup (struct ad5770r_dev *dev, const struct ad5770r_monitor_setup *mon_setup)
 
int32_t ad5770r_init (struct ad5770r_dev **device, const struct ad5770r_init_param *init_param)
 
int32_t ad5770r_remove (struct ad5770r_dev *dev)
 

Detailed Description

Implementation of ad5770r Driver.

Author
Mircea Caprioru (mirce.nosp@m.a.ca.nosp@m.prior.nosp@m.u@an.nosp@m.alog..nosp@m.com)

Copyright 2018, 2020(c) Analog Devices, Inc.

All rights reserved.

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 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.

Function Documentation

◆ ad5770r_channel_config()

int32_t ad5770r_channel_config ( struct ad5770r_dev dev,
const struct ad5770r_channel_switches channel_config 
)

Set the channel configuration.

Parameters
dev- The device structure.
channel_config- The structure that contains the channel configuration.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_get_interface_status()

int32_t ad5770r_get_interface_status ( struct ad5770r_dev dev,
uint8_t *  status 
)

Get interface status value.

Parameters
dev- The device structure.
status- The INTERFACE STATUS A register value.
Returns
0 in case of success, negative error code otherwise.

◆ ad5770r_get_status()

int32_t ad5770r_get_status ( struct ad5770r_dev dev,
uint8_t *  status 
)

Get status value.

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

◆ ad5770r_init()

int32_t ad5770r_init ( struct ad5770r_dev **  device,
const struct ad5770r_init_param init_param 
)

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.

◆ ad5770r_remove()

int32_t ad5770r_remove ( struct ad5770r_dev dev)

Delete and remove the device.

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

◆ ad5770r_set_alarm()

int32_t ad5770r_set_alarm ( struct ad5770r_dev dev,
const struct ad5770r_alarm_cfg *const  alarm_config 
)

Set reference configuration.

Parameters
dev- The device structure.
alarm_config- Pointer to the array that contains the alarms that will be enabled.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_dac_input()

int32_t ad5770r_set_dac_input ( struct ad5770r_dev dev,
uint16_t  dac_input,
enum ad5770r_channels  channel 
)

Set dac value.

Parameters
dev- The device structure.
dac_input- value that will be set in the register.
channel- the selected channel.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_dac_value()

int32_t ad5770r_set_dac_value ( struct ad5770r_dev dev,
uint16_t  dac_value,
enum ad5770r_channels  channel 
)

Set dac value.

Parameters
dev- The device structure.
dac_value- value that will be set in the register.
channel- the selected channel.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_device_spi()

int32_t ad5770r_set_device_spi ( struct ad5770r_dev dev,
const struct ad5770r_device_spi_settings spi_settings 
)

Set device spi settings.

Parameters
dev- The device structure.
spi_settings- The structure that contains the device spi parameters.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_hw_ldac()

int32_t ad5770r_set_hw_ldac ( struct ad5770r_dev dev,
const struct ad5770r_channel_switches mask_hw_ldac 
)

Set the hardware ldac configuration.

Parameters
dev- 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:

◆ ad5770r_set_mask_channel()

int32_t ad5770r_set_mask_channel ( struct ad5770r_dev dev,
const struct ad5770r_channel_switches mask_channel_sel 
)

Set channel select.

Parameters
dev- The device structure.
mask_channel_sel- The array contains channel selection options.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_monitor_setup()

int32_t ad5770r_set_monitor_setup ( struct ad5770r_dev dev,
const struct ad5770r_monitor_setup mon_setup 
)

Set the channel monitor configuration.

Parameters
dev- The device structure.
mon_setup- The structure that contains the monitor setup values.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_output_filter()

int32_t ad5770r_set_output_filter ( struct ad5770r_dev dev,
enum ad5770r_output_filter_resistor  output_filter,
enum ad5770r_channels  channel 
)

Set the channel output filter resistor.

Parameters
dev- The device structure.
output_filter- The structure that contains the channel output filter resistor values.
channel- The channel number.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_output_mode()

int32_t ad5770r_set_output_mode ( struct ad5770r_dev dev,
const struct ad5770r_output_range output_mode,
enum ad5770r_channels  channel 
)

Set the channel configuration.

Parameters
dev- The device structure.
output_mode- The structure that contains the channel output parameters.
channel- The channel number.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_page_mask()

int32_t ad5770r_set_page_mask ( struct ad5770r_dev dev,
const struct ad5770r_dac_page_mask page_mask 
)

Set page mask for dac value and input.

Parameters
dev- The device structure.
page_mask- The structure contains the page mask values.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_set_reference()

int32_t ad5770r_set_reference ( struct ad5770r_dev dev,
bool  external_reference,
enum ad5770r_reference_voltage  reference_selector 
)

Set reference configuration.

Parameters
dev- The device structure.
external_reference- Enable external reference.
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:

◆ ad5770r_set_sw_ldac()

int32_t ad5770r_set_sw_ldac ( struct ad5770r_dev dev,
const struct ad5770r_channel_switches sw_ldac 
)

Set software LDAC.

Parameters
dev- The device structure.
sw_ldac- The array contains channel selection options.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_spi_reg_read()

int32_t ad5770r_spi_reg_read ( struct ad5770r_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_data 
)

Read from device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_spi_reg_read_multiple()

int32_t ad5770r_spi_reg_read_multiple ( struct ad5770r_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_data,
uint16_t  count 
)

Multibyte read from device. A register read begins with the address and autoincrements for each aditional byte in the transfer.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
count- Number of bytes to read.
Returns
0 in case of success, negative error code otherwise.

◆ ad5770r_spi_reg_write()

int32_t ad5770r_spi_reg_write ( struct ad5770r_dev dev,
uint8_t  reg_addr,
uint8_t  reg_data 
)

Write to device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_spi_reg_write_multiple()

int32_t ad5770r_spi_reg_write_multiple ( struct ad5770r_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_data,
uint16_t  count 
)

Multibyte write from device. A register write begins with the address and autoincrements for each additional byte in the transfer.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
count- Number of bytes to read.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5770r_spi_write_mask()

int32_t ad5770r_spi_write_mask ( struct ad5770r_dev dev,
uint8_t  reg_addr,
uint32_t  mask,
uint8_t  data 
)

SPI write to device using a mask.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: