no-OS
Functions
ada4250.c File Reference

Implementation of ADA4250 Driver. More...

#include <stdlib.h>
#include "ada4250.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
Include dependency graph for ada4250.c:

Functions

int32_t ada4250_write (struct ada4250_dev *dev, uint8_t reg_addr, uint8_t data)
 Writes data to ada4250 over SPI. More...
 
int32_t ada4250_read (struct ada4250_dev *dev, uint8_t reg_addr, uint8_t *data)
 Reads data from ada4250 over SPI. More...
 
int32_t ada4250_update (struct ada4250_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
 Update ADA4250 register. More...
 
int32_t ada4250_update_desc (struct ada4250_dev *dev)
 Update ADA4250 device descriptor. More...
 
int32_t ada4250_soft_reset (struct ada4250_dev *dev)
 Software reset. More...
 
int32_t ada4250_en_refbuf (struct ada4250_dev *dev, bool refbuf)
 Enable/Disable Reference Buffer. More...
 
int32_t ada4250_set_bias (struct ada4250_dev *dev, enum ada4250_bias bias)
 Set current bias for ADA4250. More...
 
int32_t ada4250_set_gain (struct ada4250_dev *dev, enum ada4250_gain gain)
 Set gain for ADA4250. More...
 
int32_t ada4250_set_offset (struct ada4250_dev *dev, int64_t offset)
 Set offset value for ADA4250. More...
 
int32_t ada4250_set_bandwidth (struct ada4250_dev *dev, enum ada4250_bandwidth bw)
 Set the bandwidth value for ADA4250. More...
 
int32_t ada4250_set_slp_shtdwn_mode (struct ada4250_dev *dev, enum ada4250_power_mode pwrmode)
 Set the ADA4250 into sleep or shutdown mode. More...
 
int32_t ada4250_set_normal_mode (struct ada4250_dev *dev, bool reconfig)
 Sets the ADA4250 into normal mode and reconfigures it according to the user input. More...
 
int32_t ada4250_init (struct ada4250_dev **device, struct ada4250_init_param *init_param)
 Initialize the ADA4250 device. More...
 
int32_t ada4250_remove (struct ada4250_dev *dev)
 Free resoulces allocated for ADA4250. More...
 

Detailed Description

Implementation of ADA4250 Driver.

Author
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)

Copyright 2021(c) 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.

Function Documentation

◆ ada4250_en_refbuf()

int32_t ada4250_en_refbuf ( struct ada4250_dev dev,
bool  refbuf 
)

Enable/Disable Reference Buffer.

Parameters
dev- The device structure.
refbuf- REFBUF enable/disable.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_init()

int32_t ada4250_init ( struct ada4250_dev **  device,
struct ada4250_init_param init_param 
)

Initialize the ADA4250 device.

Parameters
device- The device structure.
init_param- The structure containing the device initial parameters.
Returns
Returns 0 in case of success or negative error code.
Here is the caller graph for this function:

◆ ada4250_read()

int32_t ada4250_read ( struct ada4250_dev dev,
uint8_t  reg_addr,
uint8_t *  data 
)

Reads data from ada4250 over SPI.

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

◆ ada4250_remove()

int32_t ada4250_remove ( struct ada4250_dev dev)

Free resoulces allocated for ADA4250.

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

◆ ada4250_set_bandwidth()

int32_t ada4250_set_bandwidth ( struct ada4250_dev dev,
enum ada4250_bandwidth  bw 
)

Set the bandwidth value for ADA4250.

Parameters
dev- The device structure.
bw- Bandwidth value.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_set_bias()

int32_t ada4250_set_bias ( struct ada4250_dev dev,
enum ada4250_bias  bias 
)

Set current bias for ADA4250.

Parameters
dev- The device structure.
bias- Current bias option.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_set_gain()

int32_t ada4250_set_gain ( struct ada4250_dev dev,
enum ada4250_gain  gain 
)

Set gain for ADA4250.

Parameters
dev- The device structure.
gain- Gain Value.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_set_normal_mode()

int32_t ada4250_set_normal_mode ( struct ada4250_dev dev,
bool  reconfig 
)

Sets the ADA4250 into normal mode and reconfigures it according to the user input.

Parameters
dev- The device structure.
reconfig- Reconfiguration enable/disable.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_set_offset()

int32_t ada4250_set_offset ( struct ada4250_dev dev,
int64_t  offset 
)

Set offset value for ADA4250.

Parameters
dev- The device structure.
offset- Offset Value in nV.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_set_slp_shtdwn_mode()

int32_t ada4250_set_slp_shtdwn_mode ( struct ada4250_dev dev,
enum ada4250_power_mode  pwrmode 
)

Set the ADA4250 into sleep or shutdown mode.

Parameters
dev- The device structure.
pwrmode- Power mode option.
Returns
Returns 0 in case of success or negative error code.

◆ ada4250_soft_reset()

int32_t ada4250_soft_reset ( struct ada4250_dev dev)

Software reset.

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

◆ ada4250_update()

int32_t ada4250_update ( struct ada4250_dev dev,
uint8_t  reg_addr,
uint8_t  mask,
uint8_t  data 
)

Update ADA4250 register.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Mask for specific register bits to be updated.
data- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ ada4250_update_desc()

int32_t ada4250_update_desc ( struct ada4250_dev dev)

Update ADA4250 device descriptor.

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

◆ ada4250_write()

int32_t ada4250_write ( struct ada4250_dev dev,
uint8_t  reg_addr,
uint8_t  data 
)

Writes data to ada4250 over SPI.

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