no-OS
Functions
ad713x.c File Reference

Implementation of ad713x Driver. More...

#include <stdlib.h>
#include "ad713x.h"
#include "no-os/delay.h"
#include "no-os/error.h"
Include dependency graph for ad713x.c:

Functions

int32_t ad713x_spi_reg_read (struct ad713x_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
 Read from device. More...
 
int32_t ad713x_spi_reg_write (struct ad713x_dev *dev, uint8_t reg_addr, uint8_t reg_data)
 Write to device. More...
 
int32_t ad713x_spi_write_mask (struct ad713x_dev *dev, uint8_t reg_addr, uint32_t mask, uint8_t data)
 SPI write to device using a mask. More...
 
int32_t ad713x_set_power_mode (struct ad713x_dev *dev, enum ad713x_power_mode mode)
 Device power mode control. More...
 
int32_t ad713x_set_out_data_frame (struct ad713x_dev *dev, enum ad713x_adc_data_len adc_data_len, enum ad713x_crc_header crc_header)
 ADC conversion data output frame control. More...
 
int32_t ad713x_dout_format_config (struct ad713x_dev *dev, enum ad713x_doutx_format format)
 DOUTx output format configuration. More...
 
int32_t ad713x_mag_phase_clk_delay (struct ad713x_dev *dev, bool clk_delay_en)
 Magnitude and phase matching calibration clock delay enable for all channels at 2 clock delay. This function is kept for backwards compatibility with the current application source, but it is deprecated. Use ad713x_mag_phase_clk_delay_chan(). More...
 
int32_t ad713x_mag_phase_clk_delay_chan (struct ad713x_dev *dev, enum ad713x_channels chan, enum ad717x_mpc_clkdel mode)
 Change magnitude and phase calibration clock delay mode for a specific channel. More...
 
int32_t ad713x_dig_filter_sel_ch (struct ad713x_dev *dev, enum ad713x_dig_filter_sel filter, enum ad713x_channels ch)
 Digital filter type selection for each channel. More...
 
int32_t ad713x_clkout_output_en (struct ad713x_dev *dev, bool enable)
 Enable/Disable CLKOUT output. More...
 
int32_t ad713x_ref_gain_correction_en (struct ad713x_dev *dev, bool enable)
 Enable/Disable reference gain correction. More...
 
int32_t ad713x_wideband_bw_sel (struct ad713x_dev *dev, enum ad713x_channels ch, uint8_t wb_opt)
 Select the wideband filter bandwidth for a channel. The option is relative to ODR, so it's a fraction of it. More...
 
int32_t ad713x_init (struct ad713x_dev **device, struct ad713x_init_param *init_param)
 Initialize the device. More...
 
int32_t ad713x_remove (struct ad713x_dev *dev)
 Free the resources allocated by ad713x_init(). More...
 

Detailed Description

Implementation of ad713x Driver.

Author
SPopa (stefa.nosp@m.n.po.nosp@m.pa@an.nosp@m.alog.nosp@m..com)
Andrei Drimbarean (andre.nosp@m.i.dr.nosp@m.imbar.nosp@m.ean@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 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

◆ ad713x_clkout_output_en()

int32_t ad713x_clkout_output_en ( struct ad713x_dev dev,
bool  enable 
)

Enable/Disable CLKOUT output.

Parameters
[in]dev- The device structure.
[in]enable- true to enable the clkout output; false to disable the clkout output.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_dig_filter_sel_ch()

int32_t ad713x_dig_filter_sel_ch ( struct ad713x_dev dev,
enum ad713x_dig_filter_sel  filter,
enum ad713x_channels  ch 
)

Digital filter type selection for each channel.

Parameters
dev- The device structure.
filter- Type of filter: Wideband, Sinc6, Sinc3, Sinc3 filter with simultaneous 50Hz and 60Hz rejection. Accepted values: FIR SINC6 SINC3 SINC3_50_60_REJ
ch- Channel to apply the filter to Accepted values: CH0 CH1 CH2 CH3
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_dout_format_config()

int32_t ad713x_dout_format_config ( struct ad713x_dev dev,
enum ad713x_doutx_format  format 
)

DOUTx output format configuration.

Parameters
dev- The device structure.
format- Single channel daisy chain mode. Dual channel daisy chain mode. Quad channel parallel output mode. Channel data averaging mode. Accepted values: SINGLE_CH_DC DUAL_CH_DC QUAD_CH_PO CH_AVG_MODE
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_init()

int32_t ad713x_init ( struct ad713x_dev **  device,
struct ad713x_init_param init_param 
)

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ ad713x_mag_phase_clk_delay()

int32_t ad713x_mag_phase_clk_delay ( struct ad713x_dev dev,
bool  clk_delay_en 
)

Magnitude and phase matching calibration clock delay enable for all channels at 2 clock delay. This function is kept for backwards compatibility with the current application source, but it is deprecated. Use ad713x_mag_phase_clk_delay_chan().

Parameters
dev- The device structure.
clk_delay_en- Enable or disable Mag/Phase clock delay. Accepted values: true false
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_mag_phase_clk_delay_chan()

int32_t ad713x_mag_phase_clk_delay_chan ( struct ad713x_dev dev,
enum ad713x_channels  chan,
enum ad717x_mpc_clkdel  mode 
)

Change magnitude and phase calibration clock delay mode for a specific channel.

Parameters
dev- The device structure.
chan- ID of the channel to be changed. Accepted values: CH0, CH1, CH2, CH3
mode- Delay in clock periods. Accepted values: DELAY_NONE, DELAY_1_CLOCKS, DELAY_2_CLOCKS
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_ref_gain_correction_en()

int32_t ad713x_ref_gain_correction_en ( struct ad713x_dev dev,
bool  enable 
)

Enable/Disable reference gain correction.

Parameters
[in]dev- The device structure.
[in]enable- true to enable the reference gain correction; false to disable the reference gain correction.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_remove()

int32_t ad713x_remove ( struct ad713x_dev dev)

Free the resources allocated by ad713x_init().

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

◆ ad713x_set_out_data_frame()

int32_t ad713x_set_out_data_frame ( struct ad713x_dev dev,
enum ad713x_adc_data_len  adc_data_len,
enum ad713x_crc_header  crc_header 
)

ADC conversion data output frame control.

Parameters
dev- The device structure.
adc_data_len- Data conversion length Accepted values: ADC_16_BIT_DATA ADC_24_BIT_DATA ADC_32_BIT_DATA
crc_header- CRC header Accepted values: NO_CRC CRC_6 CRC_8
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_set_power_mode()

int32_t ad713x_set_power_mode ( struct ad713x_dev dev,
enum ad713x_power_mode  mode 
)

Device power mode control.

Parameters
dev- The device structure.
mode- Type of power mode Accepted values: LOW_POWER HIGH_POWER
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ ad713x_spi_reg_read()

int32_t ad713x_spi_reg_read ( struct ad713x_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
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ ad713x_spi_reg_write()

int32_t ad713x_spi_reg_write ( struct ad713x_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
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ ad713x_spi_write_mask()

int32_t ad713x_spi_write_mask ( struct ad713x_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
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ ad713x_wideband_bw_sel()

int32_t ad713x_wideband_bw_sel ( struct ad713x_dev dev,
enum ad713x_channels  ch,
uint8_t  wb_opt 
)

Select the wideband filter bandwidth for a channel. The option is relative to ODR, so it's a fraction of it.

Parameters
[in]dev- The device structure.
[in]ch- Number of the channel to which to set the wideband filter option.
[in]wb_opt- Option to set the wideband filter: Values are: 0 - bandwidth of 0.443 * ODR; 1 - bandwidth of 0.10825 * ODR.
Returns
SUCCESS in case of success, FAILURE otherwise.