no-OS
Loading...
Searching...
No Matches
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.
 
int ad7293_spi_write (struct ad7293_dev *dev, unsigned int reg, uint16_t val)
 Writes data to AD7293 over SPI.
 
int ad7293_spi_update_bits (struct ad7293_dev *dev, unsigned int reg, uint16_t mask, uint16_t val)
 Update AD7293 register.
 
int ad7293_adc_get_range (struct ad7293_dev *dev, unsigned int ch, uint16_t *range)
 Get the range value for ADC channels.
 
int ad7293_adc_set_range (struct ad7293_dev *dev, unsigned int ch, uint16_t range)
 Set the range value for ADC channels.
 
int ad7293_isense_set_gain (struct ad7293_dev *dev, unsigned int ch, uint16_t gain)
 Set the gain value for ISENSE channels.
 
int ad7293_isense_get_gain (struct ad7293_dev *dev, unsigned int ch, uint16_t *gain)
 Get the gain value for ISENSE channels.
 
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.
 
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.
 
int ad7293_dac_write_raw (struct ad7293_dev *dev, unsigned int ch, uint16_t raw)
 Set the DAC output raw value.
 
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.
 
int ad7293_soft_reset (struct ad7293_dev *dev)
 Perform software reset.
 
int ad7293_reset (struct ad7293_dev *dev)
 Perform both hardware and software reset.
 
int ad7293_init (struct ad7293_dev **device, struct ad7293_init_param *init_param)
 Initializes the ad7293.
 
int ad7293_remove (struct ad7293_dev *dev)
 AD7293 Resources Deallocation.
 

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.

SPDX-License-Identifier: BSD-3-Clause

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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.