no-OS
Macros | Functions
ad717x.c File Reference

AD717X implementation file. Devices: AD7172-2, AD7172-4, AD7173-8, AD7175-2, AD7175-8, AD7176-2 AD7177-2, AD4111, AD4112, AD4114, AD4115, AD4116. More...

#include <stdlib.h>
#include "ad717x.h"
#include "no_os_error.h"
Include dependency graph for ad717x.c:

Macros

#define INVALID_VAL   -1 /* Invalid argument */
 
#define COMM_ERR   -2 /* Communication error on receive */
 
#define TIMEOUT   -3 /* A timeout has occured */
 

Functions

int ad717x_set_channel_status (ad717x_dev *device, uint8_t channel_id, bool channel_status)
 Set channel status - Enable/Disable. More...
 
int ad717x_set_adc_mode (ad717x_dev *device, enum ad717x_mode adc_mode)
 Set ADC Mode. More...
 
int ad717x_connect_analog_input (ad717x_dev *device, uint8_t channel_id, union ad717x_analog_inputs analog_input)
 Set Analog Inputs to channel. More...
 
int ad717x_assign_setup (ad717x_dev *device, uint8_t channel_id, uint8_t setup)
 Assign Setup to Channel. More...
 
int ad717x_set_polarity (ad717x_dev *device, bool bipolar, uint8_t setup_id)
 Set Polarity. More...
 
int ad717x_set_reference_source (ad717x_dev *device, enum ad717x_reference_source ref_source, uint8_t setup_id)
 Select the reference source. More...
 
int ad717x_enable_input_buffer (ad717x_dev *device, bool inbuf_en, bool refbuf_en, uint8_t setup_id)
 Enable Input Buffer. More...
 
int ad717x_single_read (ad717x_dev *device, uint8_t id, int32_t *adc_raw_data)
 Perform Single Conversion. More...
 
ad717x_st_regAD717X_GetReg (ad717x_dev *device, uint8_t reg_address)
 Searches through the list of registers of the driver instance and retrieves a pointer to the register that matches the given address. More...
 
int32_t AD717X_ReadRegister (ad717x_dev *device, uint8_t addr)
 Reads the value of the specified register. More...
 
int32_t AD717X_WriteRegister (ad717x_dev *device, uint8_t addr)
 Writes the value of the specified register. More...
 
int32_t AD717X_Reset (ad717x_dev *device)
 Resets the device. More...
 
int32_t AD717X_WaitForReady (ad717x_dev *device, uint32_t timeout)
 Waits until a new conversion result is available. More...
 
int32_t AD717X_ReadData (ad717x_dev *device, int32_t *pData)
 Reads the conversion result from the device. More...
 
int32_t AD717X_ComputeDataregSize (ad717x_dev *device)
 Computes data register read size to account for bit number and status read. More...
 
uint8_t AD717X_ComputeCRC8 (uint8_t *pBuf, uint8_t bufSize)
 Computes the CRC checksum for a data buffer. More...
 
uint8_t AD717X_ComputeXOR8 (uint8_t *pBuf, uint8_t bufSize)
 Computes the XOR checksum for a data buffer. More...
 
int32_t AD717X_UpdateCRCSetting (ad717x_dev *device)
 Updates the CRC settings. More...
 
int32_t ad717x_configure_device_odr (ad717x_dev *dev, uint8_t filtcon_id, uint8_t odr_sel)
 Configure ODR for the device. More...
 
int32_t AD717X_Init (ad717x_dev **device, ad717x_init_param init_param)
 Initializes the AD717X. More...
 
int32_t AD717X_remove (ad717x_dev *dev)
 Free the resources allocated by AD717X_Init(). More...
 

Detailed Description

AD717X implementation file. Devices: AD7172-2, AD7172-4, AD7173-8, AD7175-2, AD7175-8, AD7176-2 AD7177-2, AD4111, AD4112, AD4114, AD4115, AD4116.

Author
acozma (andre.nosp@m.i.co.nosp@m.zma@a.nosp@m.nalo.nosp@m.g.com) dnechita (dan.n.nosp@m.echi.nosp@m.ta@an.nosp@m.alog.nosp@m..com)

Copyright 2015(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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

◆ COMM_ERR

#define COMM_ERR   -2 /* Communication error on receive */

◆ INVALID_VAL

#define INVALID_VAL   -1 /* Invalid argument */

◆ TIMEOUT

#define TIMEOUT   -3 /* A timeout has occured */

Function Documentation

◆ ad717x_assign_setup()

int ad717x_assign_setup ( ad717x_dev device,
uint8_t  channel_id,
uint8_t  setup 
)

Assign Setup to Channel.

Parameters
device- AD717x Device Descriptor
channel_id- Channel ID (number)
setup- Setup ID (number)
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ AD717X_ComputeCRC8()

uint8_t AD717X_ComputeCRC8 ( uint8_t *  pBuf,
uint8_t  bufSize 
)

Computes the CRC checksum for a data buffer.

Parameters
pBuf- Data buffer
bufSize- Data buffer size in bytes
Returns
Returns the computed CRC checksum.
Here is the caller graph for this function:

◆ AD717X_ComputeDataregSize()

int32_t AD717X_ComputeDataregSize ( ad717x_dev device)

Computes data register read size to account for bit number and status read.

Parameters
device- The handler of the instance of the driver.
Returns
0in case of success or negative code in case of failure.
Here is the caller graph for this function:

◆ AD717X_ComputeXOR8()

uint8_t AD717X_ComputeXOR8 ( uint8_t *  pBuf,
uint8_t  bufSize 
)

Computes the XOR checksum for a data buffer.

Parameters
pBuf- Data buffer
bufSize- Data buffer size in bytes
Returns
Returns the computed XOR checksum.
Here is the caller graph for this function:

◆ ad717x_configure_device_odr()

int32_t ad717x_configure_device_odr ( ad717x_dev dev,
uint8_t  filtcon_id,
uint8_t  odr_sel 
)

Configure ODR for the device.

Parameters
dev- The AD717x Device descriptor
filtcon_id- Filter Configuration Register ID (Number)
odr_sel- ODR[4:0] bitfield value as a decimal
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad717x_connect_analog_input()

int ad717x_connect_analog_input ( ad717x_dev device,
uint8_t  channel_id,
union ad717x_analog_inputs  analog_input 
)

Set Analog Inputs to channel.

Parameters
device- AD717x Device Descriptor
channel_id- Channel whose Analog input is to be configured
analog_input- Analog Inputs to the Channel
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ ad717x_enable_input_buffer()

int ad717x_enable_input_buffer ( ad717x_dev device,
bool  inbuf_en,
bool  refbuf_en,
uint8_t  setup_id 
)

Enable Input Buffer.

Parameters
device- AD717x Device Descriptor
inbuf_en- Enable Inpur Buffer
refbuf_en- Enable referece Buffer
setup_id- Setup ID (Number)
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ AD717X_GetReg()

ad717x_st_reg* AD717X_GetReg ( ad717x_dev device,
uint8_t  reg_address 
)

Searches through the list of registers of the driver instance and retrieves a pointer to the register that matches the given address.

Parameters
device- The handler of the instance of the driver.
reg_address- The address to be used to find the register.
Returns
A pointer to the register if found or 0.
Here is the caller graph for this function:

◆ AD717X_Init()

int32_t AD717X_Init ( ad717x_dev **  device,
ad717x_init_param  init_param 
)

Initializes the AD717X.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
Returns 0 for success or negative error code.

◆ AD717X_ReadData()

int32_t AD717X_ReadData ( ad717x_dev device,
int32_t *  pData 
)

Reads the conversion result from the device.

Parameters
device- The handler of the instance of the driver.
pData- Pointer to store the read data.
Returns
Returns 0 for success or negative error code.
Here is the caller graph for this function:

◆ AD717X_ReadRegister()

int32_t AD717X_ReadRegister ( ad717x_dev device,
uint8_t  addr 
)

Reads the value of the specified register.

Parameters
device- The handler of the instance of the driver.
addr- The address of the register to be read. The value will be stored inside the register structure that holds info about this register.
Returns
Returns 0 for success or negative error code.
Here is the caller graph for this function:

◆ AD717X_remove()

int32_t AD717X_remove ( ad717x_dev dev)

Free the resources allocated by AD717X_Init().

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

◆ AD717X_Reset()

int32_t AD717X_Reset ( ad717x_dev device)

Resets the device.

Parameters
device- The handler of the instance of the driver.
Returns
Returns 0 for success or negative error code.
Here is the caller graph for this function:

◆ ad717x_set_adc_mode()

int ad717x_set_adc_mode ( ad717x_dev device,
enum ad717x_mode  adc_mode 
)

Set ADC Mode.

Parameters
device- AD717x Device Descriptor
adc_mode- ADC Mode to be configured
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ ad717x_set_channel_status()

int ad717x_set_channel_status ( ad717x_dev device,
uint8_t  channel_id,
bool  channel_status 
)

Set channel status - Enable/Disable.

Parameters
device- AD717x Device descriptor.
channel_id- Channel ID (number) of the channel whose status is to be set.
channel_status- Required status of the channel-True in case of Enable and False in case of Disable
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ ad717x_set_polarity()

int ad717x_set_polarity ( ad717x_dev device,
bool  bipolar,
uint8_t  setup_id 
)

Set Polarity.

Parameters
device- AD717x Device Descriptor
bipolar- Polarity Select:True in case of Bipolar, False in case of Unipolar
setup_id- Setup ID (number)
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ ad717x_set_reference_source()

int ad717x_set_reference_source ( ad717x_dev device,
enum ad717x_reference_source  ref_source,
uint8_t  setup_id 
)

Select the reference source.

Parameters
device- AD717x Device Descriptor
ref_source- Reference source
setup_id- Setup ID (Number)
Returns
Returns 0 for success or negative error code in case of failure.
Here is the caller graph for this function:

◆ ad717x_single_read()

int ad717x_single_read ( ad717x_dev device,
uint8_t  id,
int32_t *  adc_raw_data 
)

Perform Single Conversion.

Parameters
device- AD717x Device Descriptor
id- Channel ID (number) requested
adc_raw_dataADC Raw Value
Returns
Returns 0 for success or negative error code in case of failure.

◆ AD717X_UpdateCRCSetting()

int32_t AD717X_UpdateCRCSetting ( ad717x_dev device)

Updates the CRC settings.

Parameters
device- The handler of the instance of the driver.
Returns
Returns 0 for success or negative error code.
Here is the caller graph for this function:

◆ AD717X_WaitForReady()

int32_t AD717X_WaitForReady ( ad717x_dev device,
uint32_t  timeout 
)

Waits until a new conversion result is available.

Parameters
device- The handler of the instance of the driver.
timeout- Count representing the number of polls to be done until the function returns if no new data is available.
Returns
Returns 0 for success or negative error code.
Here is the caller graph for this function:

◆ AD717X_WriteRegister()

int32_t AD717X_WriteRegister ( ad717x_dev device,
uint8_t  addr 
)

Writes the value of the specified register.

Parameters
device- The handler of the instance of the driver.
addr- The address of the register to be written with the value stored inside the register structure that holds info about this register.
Returns
Returns 0 for success or negative error code.
Here is the caller graph for this function: