AD717X implementation file. Devices: AD7172-2, AD7172-4, AD7173-8, AD7175-2, AD7175-8, AD7176-2 AD7177-2, AD4111, AD4112, AD4113, AD4114, AD4115, AD4116.
More...
#include <stdlib.h>
#include "ad717x.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
|
| int | ad717x_set_channel_status (ad717x_dev *device, uint8_t channel_id, bool channel_status) |
| | Set channel status - Enable/Disable.
|
| |
| int | ad717x_set_adc_mode (ad717x_dev *device, enum ad717x_mode adc_mode) |
| | Set ADC Mode.
|
| |
| int | ad717x_connect_analog_input (ad717x_dev *device, uint8_t channel_id, union ad717x_analog_inputs analog_input) |
| | Set Analog Inputs to channel.
|
| |
| int | ad717x_assign_setup (ad717x_dev *device, uint8_t channel_id, uint8_t setup) |
| | Assign Setup to Channel.
|
| |
| int | ad717x_set_polarity (ad717x_dev *device, bool bipolar, uint8_t setup_id) |
| | Set Polarity.
|
| |
| int | ad717x_set_reference_source (ad717x_dev *device, enum ad717x_reference_source ref_source, uint8_t setup_id) |
| | Select the reference source.
|
| |
| int | ad717x_enable_buffers (ad717x_dev *device, bool inbuf_en, bool refbuf_en, uint8_t setup_id) |
| | Enable input and reference buffers.
|
| |
| int | ad717x_single_read (ad717x_dev *device, uint8_t id, int32_t *adc_raw_data) |
| | Perform Single Conversion.
|
| |
| 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.
|
| |
| int32_t | AD717X_ReadRegister (ad717x_dev *device, uint8_t addr) |
| | Reads the value of the specified register.
|
| |
| int32_t | AD717X_WriteRegister (ad717x_dev *device, uint8_t addr) |
| | Writes the value of the specified register.
|
| |
| int32_t | AD717X_Reset (ad717x_dev *device) |
| | Resets the device.
|
| |
| int32_t | AD717X_WaitForReady (ad717x_dev *device, uint32_t timeout) |
| | Waits until a new conversion result is available.
|
| |
| int32_t | AD717X_ReadData (ad717x_dev *device, int32_t *pData) |
| | Reads the conversion result from the device.
|
| |
| int32_t | AD717X_ComputeDataregSize (ad717x_dev *device) |
| | Computes data register read size to account for bit number and status read.
|
| |
| uint8_t | AD717X_ComputeCRC8 (uint8_t *pBuf, uint8_t bufSize) |
| | Computes the CRC checksum for a data buffer.
|
| |
| uint8_t | AD717X_ComputeXOR8 (uint8_t *pBuf, uint8_t bufSize) |
| | Computes the XOR checksum for a data buffer.
|
| |
| int32_t | AD717X_UpdateCRCSetting (ad717x_dev *device) |
| | Updates the CRC settings.
|
| |
| int32_t | ad717x_configure_device_odr (ad717x_dev *dev, uint8_t filtcon_id, uint8_t odr_sel) |
| | Configure ODR for the device.
|
| |
| int32_t | AD717X_Init (ad717x_dev **device, ad717x_init_param init_param) |
| | Initializes the AD717X.
|
| |
| int32_t | AD717X_remove (ad717x_dev *dev) |
| | Free the resources allocated by AD717X_Init().
|
| |
AD717X implementation file. Devices: AD7172-2, AD7172-4, AD7173-8, AD7175-2, AD7175-8, AD7176-2 AD7177-2, AD4111, AD4112, AD4113, 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.
SPDX-License-Identifier: BSD-3-Clause
◆ 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 */ |
◆ 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.
◆ 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.
◆ 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.
◆ 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.
◆ 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
◆ ad717x_connect_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.
◆ ad717x_enable_buffers()
| int ad717x_enable_buffers |
( |
ad717x_dev * | device, |
|
|
bool | inbuf_en, |
|
|
bool | refbuf_en, |
|
|
uint8_t | setup_id ) |
Enable input and reference buffers.
- 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.
◆ AD717X_GetReg()
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.
◆ AD717X_Init()
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.
◆ AD717X_remove()
Free the resources allocated by AD717X_Init().
- Parameters
-
| dev | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ AD717X_Reset()
Resets the device.
- Parameters
-
| device | - The handler of the instance of the driver. |
- Returns
- Returns 0 for success or negative error code.
◆ ad717x_set_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.
◆ 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.
◆ 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.
◆ ad717x_set_reference_source()
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.
◆ 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_data | ADC 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.
◆ 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.