no-OS
Functions
ad405x.c File Reference
#include <stdlib.h>
#include <errno.h>
#include "ad405x.h"
#include "no_os_delay.h"
#include "no_os_print_log.h"
Include dependency graph for ad405x.c:

Functions

int ad405x_write (struct ad405x_dev *dev, uint8_t reg_addr, uint8_t reg_val)
 Write device register. More...
 
int ad405x_read (struct ad405x_dev *dev, uint8_t reg_addr, uint8_t *reg_val)
 Read device register. More...
 
int ad405x_update_bits (struct ad405x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_val)
 Update specific register bits. More...
 
int ad405x_exit_command (struct ad405x_dev *dev)
 Send EXIT command. More...
 
int ad405x_reset_pattern_command (struct ad405x_dev *dev)
 
int ad405x_soft_reset (struct ad405x_dev *dev)
 Software reset the device. More...
 
int ad405x_set_adc_mode (struct ad405x_dev *dev)
 Enter ADC Mode. More...
 
int ad405x_set_burst_averaging_mode (struct ad405x_dev *dev)
 Enter Burst Averaging Mode. More...
 
int ad405x_set_averaging_mode (struct ad405x_dev *dev)
 Enter Averaging Mode. More...
 
int ad405x_set_config_mode (struct ad405x_dev *dev)
 Enter Config Mode. More...
 
int ad405x_set_operation_mode (struct ad405x_dev *dev, enum ad405x_operation_mode mode)
 Set operation mode. More...
 
int ad405x_convst (struct ad405x_dev *dev)
 Toggle the CNV pin to start a conversion. More...
 
int ad405x_spi_data_read (struct ad405x_dev *dev, int32_t *data)
 Read conversion data. More...
 
int ad405x_read_val (struct ad405x_dev *dev, int32_t *data)
 Trigger conversion and read data. More...
 
int ad405x_set_sample_rate (struct ad405x_dev *dev, enum ad405x_sample_rate rate)
 Select sample rate for Burst and Autonomous Modes. More...
 
int ad405x_set_averaging_filter_length (struct ad405x_dev *dev, enum ad405x_avg_filter_l length)
 Set averaging filter window length. More...
 
enum ad405x_avg_filter_l ad405x_get_averaging_filter_length (struct ad405x_dev *dev)
 Get averaging filter window length. More...
 
int ad405x_set_dev_en_polarity (struct ad405x_dev *dev, enum ad405x_dev_en_polarity polarity)
 Set DEV_EN signal polarity. More...
 
enum ad405x_dev_en_polarity ad405x_get_dev_en_polarity (struct ad405x_dev *dev)
 Get DEV_EN signal polarity. More...
 
int ad405x_enable_invert_on_chop (struct ad405x_dev *dev)
 Enable INVERT_ON_CHOP. More...
 
int ad405x_disable_invert_on_chop (struct ad405x_dev *dev)
 Disable INVERT_ON_CHOP. More...
 
enum ad405x_invert_on_chop ad405x_get_invert_on_chop_state (struct ad405x_dev *dev)
 Get INVERT_ON_CHOP setting. More...
 
int ad405x_set_gp_mode (struct ad405x_dev *dev, enum ad405x_gp_select gp, enum ad405x_gp_mode mode)
 Set GP mode. More...
 
enum ad405x_gp_mode ad405x_get_gp_mode (struct ad405x_dev *dev, enum ad405x_gp_select gp)
 Get GP mode setting. More...
 
int ad405x_set_data_format (struct ad405x_dev *dev, enum ad405x_out_data_format data_format)
 Set output data format. More...
 
int ad405x_init (struct ad405x_dev **device, struct ad405x_init_param init_param)
 Initialize the device. More...
 
int ad405x_remove (struct ad405x_dev *dev)
 Remove the device and release resources. More...
 

Function Documentation

◆ ad405x_convst()

int ad405x_convst ( struct ad405x_dev dev)

Toggle the CNV pin to start a conversion.

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

CNV High Time 10 ns

Here is the caller graph for this function:

◆ ad405x_disable_invert_on_chop()

int ad405x_disable_invert_on_chop ( struct ad405x_dev dev)

Disable INVERT_ON_CHOP.

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

◆ ad405x_enable_invert_on_chop()

int ad405x_enable_invert_on_chop ( struct ad405x_dev dev)

Enable INVERT_ON_CHOP.

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

◆ ad405x_exit_command()

int ad405x_exit_command ( struct ad405x_dev dev)

Send EXIT command.

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

◆ ad405x_get_averaging_filter_length()

enum ad405x_avg_filter_l ad405x_get_averaging_filter_length ( struct ad405x_dev dev)

Get averaging filter window length.

Parameters
dev- The device structure.
Returns
Average filter value

◆ ad405x_get_dev_en_polarity()

enum ad405x_dev_en_polarity ad405x_get_dev_en_polarity ( struct ad405x_dev dev)

Get DEV_EN signal polarity.

Parameters
dev- The device structure.
Returns
DEV_EN signal polarity

◆ ad405x_get_gp_mode()

enum ad405x_gp_mode ad405x_get_gp_mode ( struct ad405x_dev dev,
enum ad405x_gp_select  gp 
)

Get GP mode setting.

G

Parameters
dev- The device structure.
gp- GP1/GP0 select.
Returns
GP mode.

◆ ad405x_get_invert_on_chop_state()

enum ad405x_invert_on_chop ad405x_get_invert_on_chop_state ( struct ad405x_dev dev)

Get INVERT_ON_CHOP setting.

Parameters
dev- The device structure.
Returns
INVERT_ON_CHOP setting

◆ ad405x_init()

int ad405x_init ( struct ad405x_dev **  device,
struct ad405x_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.

◆ ad405x_read()

int ad405x_read ( struct ad405x_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_val 
)

Read device register.

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

◆ ad405x_read_val()

int ad405x_read_val ( struct ad405x_dev dev,
int32_t *  data 
)

Trigger conversion and read data.

Parameters
dev- The device structure.
data- Pointer to location of buffer where to store the data.
Returns
0 in case of success, negative error code otherwise.

◆ ad405x_remove()

int ad405x_remove ( struct ad405x_dev dev)

Remove the device and release resources.

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

◆ ad405x_reset_pattern_command()

int ad405x_reset_pattern_command ( struct ad405x_dev dev)

Send RESET pattern command.

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

◆ ad405x_set_adc_mode()

int ad405x_set_adc_mode ( struct ad405x_dev dev)

Enter ADC Mode.

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

◆ ad405x_set_averaging_filter_length()

int ad405x_set_averaging_filter_length ( struct ad405x_dev dev,
enum ad405x_avg_filter_l  length 
)

Set averaging filter window length.

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

◆ ad405x_set_averaging_mode()

int ad405x_set_averaging_mode ( struct ad405x_dev dev)

Enter Averaging Mode.

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

◆ ad405x_set_burst_averaging_mode()

int ad405x_set_burst_averaging_mode ( struct ad405x_dev dev)

Enter Burst Averaging Mode.

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

◆ ad405x_set_config_mode()

int ad405x_set_config_mode ( struct ad405x_dev dev)

Enter Config Mode.

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

◆ ad405x_set_data_format()

int ad405x_set_data_format ( struct ad405x_dev dev,
enum ad405x_out_data_format  data_format 
)

Set output data format.

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

◆ ad405x_set_dev_en_polarity()

int ad405x_set_dev_en_polarity ( struct ad405x_dev dev,
enum ad405x_dev_en_polarity  polarity 
)

Set DEV_EN signal polarity.

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

◆ ad405x_set_gp_mode()

int ad405x_set_gp_mode ( struct ad405x_dev dev,
enum ad405x_gp_select  gp,
enum ad405x_gp_mode  mode 
)

Set GP mode.

Parameters
dev- The device structure.
gp- GP1/GP0 select.
mode- mode select.
Returns
0 in case of success, negative error code otherwise.

◆ ad405x_set_operation_mode()

int ad405x_set_operation_mode ( struct ad405x_dev dev,
enum ad405x_operation_mode  mode 
)

Set operation mode.

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

◆ ad405x_set_sample_rate()

int ad405x_set_sample_rate ( struct ad405x_dev dev,
enum ad405x_sample_rate  rate 
)

Select sample rate for Burst and Autonomous Modes.

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

◆ ad405x_soft_reset()

int ad405x_soft_reset ( struct ad405x_dev dev)

Software reset the device.

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

◆ ad405x_spi_data_read()

int ad405x_spi_data_read ( struct ad405x_dev dev,
int32_t *  data 
)

Read conversion data.

Parameters
dev- The device structure.
data- Pointer to location of buffer where to store the data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad405x_update_bits()

int ad405x_update_bits ( struct ad405x_dev dev,
uint8_t  reg_addr,
uint8_t  mask,
uint8_t  reg_val 
)

Update specific register bits.

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

◆ ad405x_write()

int ad405x_write ( struct ad405x_dev dev,
uint8_t  reg_addr,
uint8_t  reg_val 
)

Write device register.

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