Example Program for EVAL-AD7606

Dependencies:   platform_drivers

Embed: (wiki syntax)

« Back to documentation index

iio_ad7606.c File Reference

iio_ad7606.c File Reference

Implementation of AD7606 IIO application interfaces. More...

Go to the source code of this file.

Functions

static float get_vltg_conv_scale_factor (float chn_range, polarity_e polarity)
 Get scale factor for adc data to voltage conversion for IIO client.
static void save_local_attributes (void)
 Save local variables.
static ssize_t get_chn_scale (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the scale attribute value.
static ssize_t get_sampling_frequency (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the sampling frequency attribute value.
static ssize_t get_chn_raw (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the raw attribute value.
static ssize_t get_operating_mode (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the operating mode attribute value.
static ssize_t get_power_down_mode (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the power down mode attribute value.
static ssize_t get_range (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the range attribute value.
static ssize_t get_oversampling (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the oversampling attribute value.
static ssize_t get_bandwidth (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the bandwidth attribute value.
static ssize_t get_chn_range (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel range attribute value.
static ssize_t get_chn_offset (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel offset attribute value.
static ssize_t get_chn_phase_offset (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel pahse offset attribute value.
static ssize_t get_chn_temperature (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel temperature attribute value.
static ssize_t get_chn_vref (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel Vref attribute value.
static ssize_t get_chn_vdrive (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel Vdrive attribute value.
static ssize_t get_chn_aldo (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel ALDO attribute value.
static ssize_t get_chn_dldo (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel DLDO attribute value.
static ssize_t get_chn_open_circuit_detect_manual (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel open circuit detect manual attribute value.
static ssize_t get_chn_open_circuit_detect_auto (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the channel open circuit detect auto attribute value.
static ssize_t get_chn_calibrate_adc_offset (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the adc offset calibration.
static ssize_t get_chn_calibrate_adc_gain (void *device, char *buf, size_t len, const struct iio_ch_info *channel, intptr_t id)
 Getter/Setter for the adc gain calibration.
int32_t debug_reg_read (void *dev, uint32_t reg, uint32_t *readval)
 Read the debug register value.
int32_t debug_reg_write (void *dev, uint32_t reg, uint32_t writeval)
 Write into the debug register.
static ssize_t iio_ad7606_read_data (void *dev_instance, char *pbuf, size_t offset, size_t bytes_count, uint32_t ch_mask)
 Read buffer data corresponding to AD7606 IIO device.
static ssize_t iio_ad7606_transfer_dev_data (void *dev_instance, size_t bytes_count, uint32_t ch_mask)
 Transfer the device data into memory (optional)
static int32_t iio_ad7606_start_transfer (void *dev_instance, uint32_t ch_mask)
 Perform tasks before new data transfer.
static int32_t iio_ad7606_stop_transfer (void *dev)
 Perform tasks before end of current data transfer.
static int32_t iio_ad7606_init (struct iio_device **desc)
 Init for reading/writing and parameterization of a ad7606 IIO device.
static int32_t iio_ad7606_remove (struct iio_desc *desc)
 Release resources allocated for IIO device.
int32_t ad7606_iio_initialize (void)
 Initialize the IIO interface for AD7606 IIO device.
void ad7606_iio_event_handler (void)
 Run the AD7606 IIO event handler.

Variables

static const char dev_name [] = ACTIVE_DEVICE_NAME
 Device name.
struct ad7606_dev * p_ad7606_dev_inst = NULL
 Pointer to the struct representing the AD7606 IIO device.

Detailed Description

Implementation of AD7606 IIO application interfaces.

This module acts as an interface for AD7606 IIO application

Copyright (c) 2020-2021 Analog Devices, Inc.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Definition in file iio_ad7606.c.


Function Documentation

void ad7606_iio_event_handler ( void   )

Run the AD7606 IIO event handler.

Returns:
none

This function monitors the new IIO client event

Definition at line 2020 of file iio_ad7606.c.

int32_t ad7606_iio_initialize ( void   )

Initialize the IIO interface for AD7606 IIO device.

Returns:
none
SUCCESS in case of success, FAILURE otherwise

IIO interface init parameters

Definition at line 1959 of file iio_ad7606.c.

int32_t debug_reg_read ( void *  dev,
uint32_t  reg,
uint32_t *  readval 
)

Read the debug register value.

Parameters:
dev-Pointer to IIO device instance
reg-Register address to read from
readval-Pointer to variable to read data into
Returns:
SUCCESS in case of success, negative value otherwise

Definition at line 1512 of file iio_ad7606.c.

int32_t debug_reg_write ( void *  dev,
uint32_t  reg,
uint32_t  writeval 
)

Write into the debug register.

Parameters:
dev-Pointer to IIO device instance
reg-Register address to write into
writeval-Register value to write
Returns:
SUCCESS in case of success, negative value otherwise

Definition at line 1532 of file iio_ad7606.c.

static ssize_t get_bandwidth ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the bandwidth attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available for only AD7606C

Definition at line 619 of file iio_ad7606.c.

static ssize_t get_chn_aldo ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel ALDO attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 1032 of file iio_ad7606.c.

static ssize_t get_chn_calibrate_adc_gain ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the adc gain calibration.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written

Definition at line 1449 of file iio_ad7606.c.

static ssize_t get_chn_calibrate_adc_offset ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the adc offset calibration.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written

Definition at line 1392 of file iio_ad7606.c.

static ssize_t get_chn_dldo ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel DLDO attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 1094 of file iio_ad7606.c.

static ssize_t get_chn_offset ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel offset attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 759 of file iio_ad7606.c.

static ssize_t get_chn_open_circuit_detect_auto ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel open circuit detect auto attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written

Definition at line 1276 of file iio_ad7606.c.

static ssize_t get_chn_open_circuit_detect_manual ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel open circuit detect manual attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written

Definition at line 1155 of file iio_ad7606.c.

static ssize_t get_chn_phase_offset ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel pahse offset attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 803 of file iio_ad7606.c.

static ssize_t get_chn_range ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel range attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 685 of file iio_ad7606.c.

static ssize_t get_chn_raw ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the raw attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written

Definition at line 292 of file iio_ad7606.c.

static ssize_t get_chn_scale ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the scale attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written

Definition at line 223 of file iio_ad7606.c.

static ssize_t get_chn_temperature ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel temperature attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 848 of file iio_ad7606.c.

static ssize_t get_chn_vdrive ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel Vdrive attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 973 of file iio_ad7606.c.

static ssize_t get_chn_vref ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the channel Vref attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 911 of file iio_ad7606.c.

static ssize_t get_operating_mode ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the operating mode attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available only for AD7606B and AD7606C

Definition at line 328 of file iio_ad7606.c.

static ssize_t get_oversampling ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the oversampling attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available for all devices except AD7606B and AD7606C

Definition at line 541 of file iio_ad7606.c.

static ssize_t get_power_down_mode ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the power down mode attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available for all devices except AD7606B and AD7606C

Definition at line 382 of file iio_ad7606.c.

static ssize_t get_range ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the range attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written
Note:
Available for all devices except AD7606B and AD7606C

Definition at line 485 of file iio_ad7606.c.

static ssize_t get_sampling_frequency ( void *  device,
char *  buf,
size_t  len,
const struct iio_ch_info *  channel,
intptr_t  id 
) [static]

Getter/Setter for the sampling frequency attribute value.

Parameters:
device-pointer to IIO device structure
buf-pointer to buffer holding attribute value
len-length of buffer string data
channel-pointer to IIO channel structure
Returns:
Number of characters read/written This attribute is used to define the timeout period in IIO client during data capture. Timeout = (number of requested samples * (1/sampling frequency)) + 1sec e.g. if sampling frequency = 1KSPS and requested samples = 400 Timeout = (400 * 0.001) + 1 = 1.4sec

Definition at line 264 of file iio_ad7606.c.

static float get_vltg_conv_scale_factor ( float  chn_range,
polarity_e  polarity 
) [static]

Get scale factor for adc data to voltage conversion for IIO client.

Parameters:
chn_range[in]- Current channel voltage range
chn_range_bits[in]- Channel range register bits
Returns:
scale

This function samples and capture the new data when previous data is transmitted to IIO client

Definition at line 1915 of file iio_ad7606.c.

static int32_t iio_ad7606_init ( struct iio_device **  desc ) [static]

Init for reading/writing and parameterization of a ad7606 IIO device.

Parameters:
desc[in,out]- IIO device descriptor
init[in]- Configuration structure
Returns:
SUCCESS in case of success, FAILURE otherwise

Definition at line 1855 of file iio_ad7606.c.

static ssize_t iio_ad7606_read_data ( void *  dev_instance,
char *  pbuf,
size_t  offset,
size_t  bytes_count,
uint32_t  ch_mask 
) [static]

Read buffer data corresponding to AD7606 IIO device.

Parameters:
dev_instance[in]- IIO device instance
pbuf[out]- Pointer to output data buffer
Returns:
SUCCESS in case of success or negative value otherwise

Definition at line 1551 of file iio_ad7606.c.

static int32_t iio_ad7606_remove ( struct iio_desc *  desc ) [static]

Release resources allocated for IIO device.

Parameters:
desc[in]- IIO device descriptor
Returns:
SUCCESS in case of success, FAILURE otherwise

Definition at line 1890 of file iio_ad7606.c.

static int32_t iio_ad7606_start_transfer ( void *  dev_instance,
uint32_t  ch_mask 
) [static]

Perform tasks before new data transfer.

Parameters:
dev_instance[in]- IIO device instance
ch_mask[in]- Channels select mask
Returns:
SUCCESS in case of success or negative value otherwise

Definition at line 1600 of file iio_ad7606.c.

static int32_t iio_ad7606_stop_transfer ( void *  dev ) [static]

Perform tasks before end of current data transfer.

Parameters:
dev_instance[in]- IIO device instance
Returns:
SUCCESS in case of success or negative value otherwise

Definition at line 1611 of file iio_ad7606.c.

static ssize_t iio_ad7606_transfer_dev_data ( void *  dev_instance,
size_t  bytes_count,
uint32_t  ch_mask 
) [static]

Transfer the device data into memory (optional)

Parameters:
dev_instance[in]- IIO device instance
bytes_count[in]- Number of bytes to read
ch_mask[in]- Channels select mask
Returns:
SUCCESS in case of success or negative value otherwise

Definition at line 1578 of file iio_ad7606.c.

static void save_local_attributes ( void   ) [static]

Save local variables.

Returns:
none

This function saves the local parameters with updated device values

Definition at line 1935 of file iio_ad7606.c.


Variable Documentation

const char dev_name[] = ACTIVE_DEVICE_NAME [static]

Device name.

Definition at line 97 of file iio_ad7606.c.

struct ad7606_dev* p_ad7606_dev_inst = NULL

Pointer to the struct representing the AD7606 IIO device.

Definition at line 102 of file iio_ad7606.c.