no-OS
Functions
ad5758.c File Reference

Implementation of ad5758 Driver. More...

#include "ad5758.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_gpio.h"
#include "inttypes.h"
#include "no_os_print_log.h"
#include "no_os_spi.h"
#include "no_os_alloc.h"
#include "stdbool.h"
#include "stdio.h"
#include "stdlib.h"
Include dependency graph for ad5758.c:

Functions

int32_t ad5758_spi_reg_read (struct ad5758_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 
int32_t ad5758_spi_reg_write (struct ad5758_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 
int32_t ad5758_set_crc (struct ad5758_dev *dev, uint8_t crc_en)
 
int32_t ad5758_wait_for_refresh_cycle (struct ad5758_dev *dev)
 
int32_t ad5758_soft_reset (struct ad5758_dev *dev)
 
int32_t ad5758_calib_mem_refresh (struct ad5758_dev *dev)
 
int32_t ad5758_set_dc_dc_conv_mode (struct ad5758_dev *dev, enum ad5758_dc_dc_mode mode)
 
int32_t ad5758_set_dc_dc_ilimit (struct ad5758_dev *dev, enum ad5758_dc_dc_ilimt ilimit)
 
int32_t ad5758_internal_buffers_en (struct ad5758_dev *dev, uint8_t enable)
 
int32_t ad5758_set_out_range (struct ad5758_dev *dev, enum ad5758_output_range range)
 
int32_t ad5758_slew_rate_config (struct ad5758_dev *dev, enum ad5758_slew_rate_clk clk, uint8_t enable)
 
int32_t ad5758_dac_input_write (struct ad5758_dev *dev, uint16_t code)
 
int32_t ad5758_dac_output_en (struct ad5758_dev *dev, uint8_t enable)
 
int32_t ad5758_clear_dig_diag_flag (struct ad5758_dev *dev, enum ad5758_dig_diag_flags flag)
 
int32_t ad5758_set_clkout_config (struct ad5758_dev *dev, enum ad5758_clkout_config config, enum ad5758_clkout_freq freq)
 
int32_t ad5758_select_adc_ip (struct ad5758_dev *dev, enum ad5758_adc_ip adc_ip_sel)
 
int32_t ad5758_select_adc_depth (struct ad5758_dev *dev, uint8_t num_of_channels)
 
int32_t ad5758_set_adc_channel_input (struct ad5758_dev *dev, uint8_t channel, enum ad5758_adc_ip adc_ip_sel)
 
int32_t ad5758_set_adc_mode (struct ad5758_dev *dev, enum ad5758_adc_mode adc_mode, uint8_t enable)
 
int32_t ad5758_init (struct ad5758_dev **device, struct ad5758_init_param *init_param)
 

Detailed Description

Implementation of ad5758 Driver.

Author
SPopa (stefa.nosp@m.n.po.nosp@m.pa@an.nosp@m.alog.nosp@m..com)

Copyright 2018(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

◆ ad5758_calib_mem_refresh()

int32_t ad5758_calib_mem_refresh ( struct ad5758_dev dev)

Initiate a calibration memory refresh to the shadow registers

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

◆ ad5758_clear_dig_diag_flag()

int32_t ad5758_clear_dig_diag_flag ( struct ad5758_dev dev,
enum ad5758_dig_diag_flags  flag 
)

Clear the error flags for the on-chip digital diagnostic features

Parameters
dev- The device structure.
flag- which flag to clear Accepted values: DIAG_SPI_CRC_ERR DIAG_SLIPBIT_ERR DIAG_SCLK_COUNT_ERR DIAG_INVALID_SPI_ACCESS_ERR DIAG_CAL_MEM_CRC_ERR DIAG_INVERSE_DAC_CHECK_ERR DIAG_DAC_LATCH_MON_ERR DIAG_THREE_WI_RC_ERR DIAG_WDT_ERR DIAG_ERR_3WI DIAG_RESET_OCCURRED
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_dac_input_write()

int32_t ad5758_dac_input_write ( struct ad5758_dev dev,
uint16_t  code 
)

Write DAC data to the input register

Parameters
dev- The device structure.
code- DAC input data of 16 bits Accepted values: 0x00 to 0xFFFF
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_dac_output_en()

int32_t ad5758_dac_output_en ( struct ad5758_dev dev,
uint8_t  enable 
)

Enable/disable VIOUT.

Parameters
dev- The device structure.
enable- enable or disable VIOUT output Accepted values: 0: disable 1: enable
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_init()

int32_t ad5758_init ( struct ad5758_dev **  device,
struct ad5758_init_param init_param 
)

Set up the device from power-on or reset condition with the correct programming sequence to enable the output

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.
Here is the caller graph for this function:

◆ ad5758_internal_buffers_en()

int32_t ad5758_internal_buffers_en ( struct ad5758_dev dev,
uint8_t  enable 
)

Enable/disable Enable Internal Buffers.

Parameters
dev- The device structure.
enable- enable or disable Accepted values: 0: disable 1: enable
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_select_adc_depth()

int32_t ad5758_select_adc_depth ( struct ad5758_dev dev,
uint8_t  num_of_channels 
)

Set depth of the sequencer.

Parameters
dev- The device structure.
num_of_channels- depth of the sequencer 1 to 8 channels Accepted values: 1 channel, 2 channels ... 8 channels
Returns
0 in case of success, negative error code otherwise.

◆ ad5758_select_adc_ip()

int32_t ad5758_select_adc_ip ( struct ad5758_dev dev,
enum ad5758_adc_ip  adc_ip_sel 
)

Select which node to multiplex to the ADC.

Parameters
dev- The device structure.
adc_ip_sel- diagnostic select Accepted values: ADC_IP_MAIN_DIE_TEMP ADC_IP_DCDC_DIE_TEMP ADC_IP_REFIN ADC_IP_REF2 ADC_IP_VSENSE ADC_IP_MVSENSE ADC_IP_INT_AVCC ADC_IP_REGOUT ADC_IP_VLOGIC ADC_IP_INT_CURR_MON_VOUT ADC_IP_REFGND ADC_IP_AGND ADC_IP_DGND ADC_IP_VDPC ADC_IP_AVDD2 ADC_IP_AVSS ADC_IP_DCDC_DIE_NODE ADC_IP_REFOUT
Returns
0 in case of success, negative error code otherwise.

◆ ad5758_set_adc_channel_input()

int32_t ad5758_set_adc_channel_input ( struct ad5758_dev dev,
uint8_t  channel,
enum ad5758_adc_ip  adc_ip_sel 
)

Load the desired channel into the sequencer with the adc input

Parameters
dev- The device structure.
channel- Desired channel Accepted values: 0 = channel 1, 1 = channel 2... 7 = channel 8
adc_ip_sel- diagnostic select Accepted values: ADC_IP_MAIN_DIE_TEMP ADC_IP_DCDC_DIE_TEMP ADC_IP_REFIN ADC_IP_REF2 ADC_IP_VSENSE ADC_IP_MVSENSE ADC_IP_INT_AVCC ADC_IP_REGOUT ADC_IP_VLOGIC ADC_IP_INT_CURR_MON_VOUT ADC_IP_REFGND ADC_IP_AGND ADC_IP_DGND ADC_IP_VDPC ADC_IP_AVDD2 ADC_IP_AVSS ADC_IP_DCDC_DIE_NODE ADC_IP_REFOUT
Returns
0 in case of success, negative error code otherwise.

◆ ad5758_set_adc_mode()

int32_t ad5758_set_adc_mode ( struct ad5758_dev dev,
enum ad5758_adc_mode  adc_mode,
uint8_t  enable 
)

Configure the ADC into one of four modes of operation

Parameters
dev- The device structure.
adc_mode- ADC mode of operation Accepted values: ADC_MODE_KEY_SEQ ADC_MODE_AUTO_SEQ ADC_MODE_SINGLE_CONV ADC_MODE_SINGLE_KEY_CONV
enable- enable or disable the selected mode Accepted values: 0: disable 1: enable
Returns
0 in case of success, negative error code otherwise.

◆ ad5758_set_clkout_config()

int32_t ad5758_set_clkout_config ( struct ad5758_dev dev,
enum ad5758_clkout_config  config,
enum ad5758_clkout_freq  freq 
)

Configure CLKOUT by setting the frequency and enabling/disabling the option

Parameters
dev- The device structure.
config- Enable or disable Accepted values: CLKOUT_DISABLE CLKOUT_ENABLE
freq- configure the frequency of CLKOUT. Accepted values: CLKOUT_FREQ_416_KHZ CLKOUT_FREQ_435_KHZ CLKOUT_FREQ_454_KHZ CLKOUT_FREQ_476_KHZ CLKOUT_FREQ_500_KHZ CLKOUT_FREQ_526_KHZ CLKOUT_FREQ_555_KHZ CLKOUT_FREQ_588_KHZ
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_set_crc()

int32_t ad5758_set_crc ( struct ad5758_dev dev,
uint8_t  crc_en 
)

Enable/disable SPI CRC function.

Parameters
dev- The device structure.
crc_en- CRC status Accepted values: 0 - disabled 1 - enabled
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_set_dc_dc_conv_mode()

int32_t ad5758_set_dc_dc_conv_mode ( struct ad5758_dev dev,
enum ad5758_dc_dc_mode  mode 
)

Configure the dc-to-dc controller mode

Parameters
dev- The device structure.
mode- Mode[1:0] bits. Accepted values: DC_DC_POWER_OFF DPC_CURRENT_MODE DPC_VOLTAGE_MODE PPC_CURRENT_MODE
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_set_dc_dc_ilimit()

int32_t ad5758_set_dc_dc_ilimit ( struct ad5758_dev dev,
enum ad5758_dc_dc_ilimt  ilimit 
)

Set the dc-to-dc converter current limit.

Parameters
dev- The device structure.
ilimit- current limit in mA Accepted values: ILIMIT_150_mA ILIMIT_200_mA ILIMIT_250_mA ILIMIT_300_mA ILIMIT_350_mA ILIMIT_400_mA
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_set_out_range()

int32_t ad5758_set_out_range ( struct ad5758_dev dev,
enum ad5758_output_range  range 
)

Select Output Range.

Parameters
dev- The device structure.
range- output range Accepted values: RANGE_0V_5V RANGE_0V_10V RANGE_M5V_5V RANGE_M10V_10V RANGE_0mA_20mA RANGE_0mA_24mA RANGE_4mA_24mA RANGE_M20mA_20mA RANGE_M24mA_24mA RANGE_M1mA_22mA
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_slew_rate_config()

int32_t ad5758_slew_rate_config ( struct ad5758_dev dev,
enum ad5758_slew_rate_clk  clk,
uint8_t  enable 
)

Configure the slew rate by setting the clock and enable/disable the control

Parameters
dev- The device structure.
clk- Slew rate clock. Accepted values: SR_CLOCK_240_KHZ SR_CLOCK_200_KHZ SR_CLOCK_150_KHZ SR_CLOCK_128_KHZ SR_CLOCK_64_KHZ SR_CLOCK_32_KHZ SR_CLOCK_16_KHZ SR_CLOCK_8_KHZ SR_CLOCK_4_KHZ SR_CLOCK_2_KHZ SR_CLOCK_1_KHZ SR_CLOCK_512_HZ SR_CLOCK_256_HZ SR_CLOCK_128_HZ SR_CLOCK_64_HZ SR_CLOCK_16_HZ
enable- enable or disable the sr coontrol Accepted values: 0: disable 1: enable
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5758_soft_reset()

int32_t ad5758_soft_reset ( struct ad5758_dev dev)

Initiate a software reset

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

◆ ad5758_spi_reg_read()

int32_t ad5758_spi_reg_read ( struct ad5758_dev dev,
uint8_t  reg_addr,
uint16_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:

◆ ad5758_spi_reg_write()

int32_t ad5758_spi_reg_write ( struct ad5758_dev dev,
uint8_t  reg_addr,
uint16_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:

◆ ad5758_wait_for_refresh_cycle()

int32_t ad5758_wait_for_refresh_cycle ( struct ad5758_dev dev)

Busy wait until CAL_MEM_UNREFRESHED bit in the DIGITAL_DIAG_RESULTS clears

Parameters
dev- The device structure.
Returns
0 in case of success
Here is the caller graph for this function: