no-OS
Classes | Macros | Enumerations | Functions
ad799x.h File Reference

Header file of AD799x Driver. More...

#include <stdint.h>
#include "no_os_i2c.h"
Include dependency graph for ad799x.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad799x_dev
 
struct  ad799x_init_param
 

Macros

#define AD799X_CHANNEL(ch)   ((1 << ch) << 4)
 
#define AD799X_REF_SEL   (1 << 3)
 
#define AD799X_FLTR   (1 << 2)
 
#define AD799X_BIT_TRIAL_DELAY   (1 << 1)
 
#define AD799X_SAMPLE_DELAY   (1 << 0)
 

Enumerations

enum  ad799x_type {
  AD7991,
  AD7995,
  AD7999
}
 

Functions

int8_t ad799x_init (struct ad799x_dev **device, struct ad799x_init_param init_param)
 Initializes I2C. More...
 
int32_t ad799x_remove (struct ad799x_dev *dev)
 Free the resources allocated by ad799x_init(). More...
 
void ad799x_set_configuration_reg (struct ad799x_dev *dev, uint8_t register_value)
 Writes data into the Configuration Register. More...
 
void ad799x_get_conversion_result (struct ad799x_dev *dev, int16_t *conv_value, int8_t *channel)
 Reads the High byte and the Low byte of the conversion. More...
 
float ad799x_convert_to_volts (struct ad799x_dev *dev, int16_t raw_sample, float v_ref)
 Converts a raw sample to volts. More...
 

Detailed Description

Header file of AD799x Driver.

Author
DNechita (Dan.N.nosp@m.echi.nosp@m.ta@an.nosp@m.alog.nosp@m..com)

Copyright 2012(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.

Macro Definition Documentation

◆ AD799X_BIT_TRIAL_DELAY

#define AD799X_BIT_TRIAL_DELAY   (1 << 1)

◆ AD799X_CHANNEL

#define AD799X_CHANNEL (   ch)    ((1 << ch) << 4)

◆ AD799X_FLTR

#define AD799X_FLTR   (1 << 2)

◆ AD799X_REF_SEL

#define AD799X_REF_SEL   (1 << 3)

◆ AD799X_SAMPLE_DELAY

#define AD799X_SAMPLE_DELAY   (1 << 0)

Enumeration Type Documentation

◆ ad799x_type

Enumerator
AD7991 
AD7995 
AD7999 

Function Documentation

◆ ad799x_convert_to_volts()

float ad799x_convert_to_volts ( struct ad799x_dev dev,
int16_t  raw_sample,
float  v_ref 
)

Converts a raw sample to volts.

Converts a raw sample to volts.

Parameters
dev- The device structure.
raw_sample- The data sample.
v_ref- The value of the voltage reference used by the device.
Returns
voltage - The result of the conversion expressed as volts.

◆ ad799x_get_conversion_result()

void ad799x_get_conversion_result ( struct ad799x_dev dev,
int16_t *  conv_value,
int8_t *  channel 
)

Reads the High byte and the Low byte of the conversion.

Reads the High byte and the Low byte of the conversion.

Parameters
dev- The device structure.
conv_value- It is used to store the conversion value.
channel- Stores the channel number for the current conversion.
Returns
none.

◆ ad799x_init()

int8_t ad799x_init ( struct ad799x_dev **  device,
struct ad799x_init_param  init_param 
)

Initializes I2C.

Initializes I2C.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
status - Initialization status. Example: -1 - Initialization failed; 0 - Initialization succeeded.

◆ ad799x_remove()

int32_t ad799x_remove ( struct ad799x_dev dev)

Free the resources allocated by ad799x_init().

Free the resources allocated by ad799x_init().

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

◆ ad799x_set_configuration_reg()

void ad799x_set_configuration_reg ( struct ad799x_dev dev,
uint8_t  register_value 
)

Writes data into the Configuration Register.

Writes data into the Configuration Register.

Parameters
dev- The device structure.
register_value- Data value to write.
Returns
None.