no-OS
Functions
ad7293.c File Reference

Implementation of ad7293 Driver. More...

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

Functions

int ad7293_spi_read (struct ad7293_dev *dev, unsigned int reg, uint16_t *val)
 Reads data from AD7293 over SPI. More...
 
int ad7293_spi_write (struct ad7293_dev *dev, unsigned int reg, uint16_t val)
 Writes data to AD7293 over SPI. More...
 
int ad7293_spi_update_bits (struct ad7293_dev *dev, unsigned int reg, uint16_t mask, uint16_t val)
 Update AD7293 register. More...
 
int ad7293_adc_get_range (struct ad7293_dev *dev, unsigned int ch, uint16_t *range)
 Get the range value for ADC channels. More...
 
int ad7293_adc_set_range (struct ad7293_dev *dev, unsigned int ch, uint16_t range)
 Set the range value for ADC channels. More...
 
int ad7293_isense_set_gain (struct ad7293_dev *dev, unsigned int ch, uint16_t gain)
 Set the gain value for ISENSE channels. More...
 
int ad7293_isense_get_gain (struct ad7293_dev *dev, unsigned int ch, uint16_t *gain)
 Get the gain value for ISENSE channels. More...
 
int ad7293_get_offset (struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t *offset)
 Set offset value for specific channel and channel type. More...
 
int ad7293_set_offset (struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t offset)
 Set offset value for specific channel and channel type. More...
 
int ad7293_dac_write_raw (struct ad7293_dev *dev, unsigned int ch, uint16_t raw)
 Set the DAC output raw value. More...
 
int ad7293_ch_read_raw (struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t *raw)
 Read raw value for specific channel and channel type. More...
 
int ad7293_soft_reset (struct ad7293_dev *dev)
 Perform software reset. More...
 
int ad7293_reset (struct ad7293_dev *dev)
 Perform both hardware and software reset. More...
 
int ad7293_init (struct ad7293_dev **device, struct ad7293_init_param *init_param)
 Initializes the ad7293. More...
 
int ad7293_remove (struct ad7293_dev *dev)
 AD7293 Resources Deallocation. More...
 

Detailed Description

Implementation of ad7293 Driver.

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

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

◆ ad7293_adc_get_range()

int ad7293_adc_get_range ( struct ad7293_dev dev,
unsigned int  ch,
uint16_t *  range 
)

Get the range value for ADC channels.

Parameters
dev- The device structure.
ch- the channel number.
range- the range value.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_adc_set_range()

int ad7293_adc_set_range ( struct ad7293_dev dev,
unsigned int  ch,
uint16_t  range 
)

Set the range value for ADC channels.

Parameters
dev- The device structure.
ch- the channel number.
range- the range value.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_ch_read_raw()

int ad7293_ch_read_raw ( struct ad7293_dev dev,
enum ad7293_ch_type  type,
unsigned int  ch,
uint16_t *  raw 
)

Read raw value for specific channel and channel type.

Parameters
dev- The device structure.
type- The channel type.
ch- the channel number.
raw- the raw value read.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_dac_write_raw()

int ad7293_dac_write_raw ( struct ad7293_dev dev,
unsigned int  ch,
uint16_t  raw 
)

Set the DAC output raw value.

Parameters
dev- The device structure.
ch- the channel number.
raw- the raw value to be written.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_get_offset()

int ad7293_get_offset ( struct ad7293_dev dev,
enum ad7293_ch_type  type,
unsigned int  ch,
uint16_t *  offset 
)

Set offset value for specific channel and channel type.

Parameters
dev- The device structure.
type- The channel type.
ch- the channel number.
offset- the raw value to be written.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_init()

int ad7293_init ( struct ad7293_dev **  device,
struct ad7293_init_param init_param 
)

Initializes the ad7293.

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.

◆ ad7293_isense_get_gain()

int ad7293_isense_get_gain ( struct ad7293_dev dev,
unsigned int  ch,
uint16_t *  gain 
)

Get the gain value for ISENSE channels.

Parameters
dev- The device structure.
ch- the channel number.
gain- the gain read.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_isense_set_gain()

int ad7293_isense_set_gain ( struct ad7293_dev dev,
unsigned int  ch,
uint16_t  gain 
)

Set the gain value for ISENSE channels.

Parameters
dev- The device structure.
ch- the channel number.
gain- the range value.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_remove()

int ad7293_remove ( struct ad7293_dev dev)

AD7293 Resources Deallocation.

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

◆ ad7293_reset()

int ad7293_reset ( struct ad7293_dev dev)

Perform both hardware and 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:

◆ ad7293_set_offset()

int ad7293_set_offset ( struct ad7293_dev dev,
enum ad7293_ch_type  type,
unsigned int  ch,
uint16_t  offset 
)

Set offset value for specific channel and channel type.

Parameters
dev- The device structure.
type- The channel type.
ch- the channel number.
offset- the raw value read.
Returns
Returns 0 in case of success or negative error code.

◆ ad7293_soft_reset()

int ad7293_soft_reset ( struct ad7293_dev dev)

Perform 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:

◆ ad7293_spi_read()

int ad7293_spi_read ( struct ad7293_dev dev,
unsigned int  reg,
uint16_t *  val 
)

Reads data from AD7293 over SPI.

Parameters
dev- The device structure.
reg- The register address.
val- 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:

◆ ad7293_spi_update_bits()

int ad7293_spi_update_bits ( struct ad7293_dev dev,
unsigned int  reg,
uint16_t  mask,
uint16_t  val 
)

Update AD7293 register.

Parameters
dev- The device structure.
reg- The register address.
mask- Mask for specific register bits to be updated.
val- Data written to the device (requires prior bit shifting).
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ ad7293_spi_write()

int ad7293_spi_write ( struct ad7293_dev dev,
unsigned int  reg,
uint16_t  val 
)

Writes data to AD7293 over SPI.

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