no-OS
Loading...
Searching...
No Matches
ad7746.c File Reference

Implementation of AD7746 Driver. More...

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

Functions

int32_t ad7746_init (struct ad7746_dev **device, struct ad7746_init_param *init_param)
 Initialize the ad7606 device structure.
 
int32_t ad7746_reg_write (struct ad7746_dev *dev, uint8_t reg, uint8_t *data, uint16_t bytes_number)
 Writes data into AD7746 registers, starting from the selected register address pointer.
 
int32_t ad7746_reg_read (struct ad7746_dev *dev, uint8_t reg, uint8_t *data, uint16_t bytes_number)
 Reads data from AD7746 registers, starting from the selected register address pointer.
 
int32_t ad7746_reset (struct ad7746_dev *dev)
 Resets the AD7746.
 
int32_t ad7746_remove (struct ad7746_dev *dev)
 Deinitialize the ad7746 driver and free all allocated resources.
 
int32_t ad7746_set_cap (struct ad7746_dev *dev, struct ad7746_cap cap)
 Configure the capacitive setup register.
 
int32_t ad7746_set_vt (struct ad7746_dev *dev, struct ad7746_vt vt)
 Configure the voltage/temperature setup register.
 
int32_t ad7746_set_exc (struct ad7746_dev *dev, struct ad7746_exc exc)
 Configure the excitation setup register.
 
int32_t ad7746_set_config (struct ad7746_dev *dev, struct ad7746_config config)
 Set the configuration register.
 
int32_t ad7746_set_cap_dac_a (struct ad7746_dev *dev, bool enable, uint8_t code)
 Set the DAC code and enable state for EXCA.
 
int32_t ad7746_set_cap_dac_b (struct ad7746_dev *dev, bool enable, uint8_t code)
 Set the DAC code and enable state for EXCB.
 
int32_t ad7746_set_cap_offset (struct ad7746_dev *dev, uint16_t offset)
 Set the capacitive offset.
 
int32_t ad7746_set_cap_gain (struct ad7746_dev *dev, uint16_t gain)
 Set the capacitive gain.
 
int32_t ad7746_set_volt_gain (struct ad7746_dev *dev, uint16_t gain)
 Set the voltage gain.
 
int32_t ad7746_get_vt_data (struct ad7746_dev *dev, uint32_t *vt_data)
 Waits until a conversion on a voltage/temperature channel has been finished and returns the output data.
 
int32_t ad7746_get_cap_data (struct ad7746_dev *dev, uint32_t *cap_data)
 Waits until a conversion on the capacitive channel has been finished and returns the output data.
 
int32_t ad7746_calibrate (struct ad7746_dev *dev, enum ad7746_md md)
 Perform offset/gain calibration.
 

Detailed Description

Implementation of AD7746 Driver.

Author
Dragos Bogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)
Darius Berghe (dariu.nosp@m.s.be.nosp@m.rghe@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2021(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ad7746_calibrate()

int32_t ad7746_calibrate ( struct ad7746_dev * dev,
enum ad7746_md md )

Perform offset/gain calibration.

Parameters
dev- Device descriptor pointer.
md- AD7746 calibration mode specifier.
Returns
return code. Example: -EINVAL - Wrong input values. -EIO - I2C Communication error. 0 - No errors encountered.

◆ ad7746_get_cap_data()

int32_t ad7746_get_cap_data ( struct ad7746_dev * dev,
uint32_t * cap_data )

Waits until a conversion on the capacitive channel has been finished and returns the output data.

Parameters
dev- Device descriptor pointer.
cap_data- The content of the Capacitive Data register.
Returns
return code. Example: -EINVAL - Wrong input values. -EIO - I2C Communication error. 0 - No errors encountered.

◆ ad7746_get_vt_data()

int32_t ad7746_get_vt_data ( struct ad7746_dev * dev,
uint32_t * vt_data )

Waits until a conversion on a voltage/temperature channel has been finished and returns the output data.

Parameters
dev- Device descriptor pointer.
vt_data- The content of the VT Data register.
Returns
return code. Example: -EINVAL - Wrong input values. -EIO - I2C Communication error. 0 - No errors encountered.

◆ ad7746_init()

int32_t ad7746_init ( struct ad7746_dev ** device,
struct ad7746_init_param * init_param )

Initialize the ad7606 device structure.

Performs memory allocation of the device structure.

Parameters
device- Pointer to location of device structure to write.
init_param- Pointer to the configuration of the driver.
Returns
ret - return code. Example: -ENOMEM - Memory allocation error. -EIO - I2C communication error. 0 - No errors encountered.

◆ ad7746_reg_read()

int32_t ad7746_reg_read ( struct ad7746_dev * dev,
uint8_t reg,
uint8_t * data,
uint16_t bytes_number )

Reads data from AD7746 registers, starting from the selected register address pointer.

Parameters
dev- Device descriptor pointer.
reg- The selected register address pointer.
data- Pointer to a buffer that will store the received data.
bytes_number- Number of bytes to read (typically 1, other values when using the address auto-increment).
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_reg_write()

int32_t ad7746_reg_write ( struct ad7746_dev * dev,
uint8_t reg,
uint8_t * data,
uint16_t bytes_number )

Writes data into AD7746 registers, starting from the selected register address pointer.

Parameters
dev- Device descriptor pointer.
reg- The selected register address.
data- Pointer to data to transmit.
bytes_number- Number of bytes to send (typically 1, other values when using the address auto-increment).
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_remove()

int32_t ad7746_remove ( struct ad7746_dev * dev)

Deinitialize the ad7746 driver and free all allocated resources.

Parameters
dev- Device descriptor pointer.
Returns
0

◆ ad7746_reset()

int32_t ad7746_reset ( struct ad7746_dev * dev)

Resets the AD7746.

Parameters
dev- Device descriptor pointer.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_cap()

int32_t ad7746_set_cap ( struct ad7746_dev * dev,
struct ad7746_cap cap )

Configure the capacitive setup register.

Parameters
dev- Device descriptor pointer.
cap- Capacitive setup settings.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_cap_dac_a()

int32_t ad7746_set_cap_dac_a ( struct ad7746_dev * dev,
bool enable,
uint8_t code )

Set the DAC code and enable state for EXCA.

Parameters
dev- Device descriptor pointer.
enable- DAC_A Enable.
code- DAC_A register code.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_cap_dac_b()

int32_t ad7746_set_cap_dac_b ( struct ad7746_dev * dev,
bool enable,
uint8_t code )

Set the DAC code and enable state for EXCB.

Parameters
dev- Device descriptor pointer.
enable- DAC_B Enable.
code- DAC_B register code.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_cap_gain()

int32_t ad7746_set_cap_gain ( struct ad7746_dev * dev,
uint16_t gain )

Set the capacitive gain.

Parameters
dev- Device descriptor pointer.
gain- Gain as raw code.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_cap_offset()

int32_t ad7746_set_cap_offset ( struct ad7746_dev * dev,
uint16_t offset )

Set the capacitive offset.

Parameters
dev- Device descriptor pointer.
offset- Offset as raw code.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_config()

int32_t ad7746_set_config ( struct ad7746_dev * dev,
struct ad7746_config config )

Set the configuration register.

Parameters
dev- Device descriptor pointer.
config- Configuration register settings.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_exc()

int32_t ad7746_set_exc ( struct ad7746_dev * dev,
struct ad7746_exc exc )

Configure the excitation setup register.

Parameters
dev- Device descriptor pointer.
exc- Excitation setup settings.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_volt_gain()

int32_t ad7746_set_volt_gain ( struct ad7746_dev * dev,
uint16_t gain )

Set the voltage gain.

Parameters
dev- Device descriptor pointer.
gain- Gain as raw code.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.

◆ ad7746_set_vt()

int32_t ad7746_set_vt ( struct ad7746_dev * dev,
struct ad7746_vt vt )

Configure the voltage/temperature setup register.

Parameters
dev- Device descriptor pointer.
vt- Voltage/Temperature setup settings.
Returns
return code. Example: -EINVAL - Wrong input values. 0 - No errors encountered.