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

#include <stdlib.h>
#include "ad717x.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

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

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

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

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