precision-converters-firmware
Macros | Enumerations | Functions | Variables
ad777x_iio.c File Reference

Source file of AD777x IIO interfaces. More...

#include <string.h>
#include "ad777x_user_config.h"
#include "ad777x_support.h"
#include "no_os_error.h"
#include "iio_trigger.h"
#include "no_os_util.h"
#include "no_os_gpio.h"
#include "no_os_irq.h"
#include "ad777x_iio.h"
#include "app_config.h"
#include "common.h"
#include "ad7779.h"
#include "iio.h"
Include dependency graph for ad777x_iio.c:

Macros

#define AD777x_CH_ATTR(_name, _idx)
 
#define AD777x_CH_AVAIL_ATTR(_name, _priv)
 
#define AD777x_CHANNEL(_name, _idx)
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define AD777x_INTERNAL_REF_VAL   2.5
 
#define AD777x_EXTERNAL_REF_VAL   2.5
 
#define AD777X_SAR_RESOLUTION   12
 
#define AD777X_SAR_REFERENCE   3.3
 
#define AD777X_SAR_SCALE   AD777X_SAR_REFERENCE/(1 << (AD777X_SAR_RESOLUTION-1))
 
#define SRC_LOAD_UPDATE_HIGH   0x1
 
#define SRC_LOAD_UPDATE_LOW   0x0
 
#define AD777X_SRC_ATT_FACTOR   6
 
#define DATA_BUFFER_SIZE   (128000)
 
#define AD777X_IIO_TRIGGER_NAME   "ad777x_iio_trigger"
 
#define NUM_OF_IIO_DEVICES   1
 

Enumerations

enum  ad777x_attribute_id {
  RAW_ATTR_ID ,
  SCALE_ATTR_ID ,
  OFFSET_ATTR_ID ,
  PGA_ATTR_ATTR_ID ,
  PHASE_COMP_ATTR_ID ,
  GAIN_COMP_ATTR_ID ,
  OFFSET_COMP_ATTR_ID ,
  SAMPLING_FREQ_ATTR_ID ,
  SRC_ATTR_ID_INT ,
  SRC_ATTR_ID_DEC ,
  CONV_MODE_ATTR_ID ,
  ERROR_FLAG1_ATTR_ID ,
  ERROR_FLAG2_ATTR_ID ,
  ERROR_FLAG3_ATTR_ID ,
  AUXAINP_AUXAINN_MUX_ATTR_ID ,
  DVBE_AVSSX_MUX_ATTR_ID ,
  REF1P_REF1N_MUX_ATTR_ID ,
  REF2P_REF2N_MUX_ATTR_ID ,
  REF_OUT_AVSSX_MUX_ATTR_ID ,
  VCM_AVSSX_MUX_ATTR_ID ,
  AREG1CAP_AVSSX_MUX_ATTR_ID ,
  AREG2CAP_AVSSX_MUX_ATTR_ID ,
  DREGCAP_DGND_MUX_ATTR_ID ,
  AVDD1A_AVSSX_MUX_ATTR_ID ,
  AVDD1B_AVSSX_MUX_ATTR_ID ,
  AVDD2A_AVSSX_MUX_ATTR_ID ,
  AVDD2B_AVSSX_MUX_ATTR_ID ,
  IOVDD_DGND_MUX_ATTR_ID ,
  AVDD4_AVSSX_MUX_ATTR_ID ,
  DGND_AVSS1A_MUX_ATTR_ID ,
  DGND_AVSS1B_MUX_ATTR_ID ,
  DGND_AVSSX_MUX_ATTR_ID ,
  AVDD4_AVSSX_ATT_MUX_ATTR_ID ,
  REF1P_AVSSX_MUX_ATTR_ID ,
  REF2P_AVSSX_MUX_ATTR_ID ,
  AVSSX_AVDD4_MUX_ATTR_ID ,
  SINC5_STATE_ATTR_ID
}
 

Functions

int32_t ad777x_trigger_handler (struct iio_device_data *iio_dev_data)
 Push data into IIO buffer when trigger handler IRQ is invoked. More...
 
void data_capture_callback (void *ctx)
 Interrupt Service Routine to monitor end of conversion event. More...
 
int32_t iio_ad777x_init (struct iio_device **desc)
 Init for reading/writing and parameterization of a AD777x IIO device. More...
 
int32_t ad777x_iio_initialize (void)
 Initialize the IIO interface for AD777x IIO device. More...
 
void ad777x_iio_event_handler (void)
 Run the AD777x IIO event handler. More...
 

Variables

ad7779_dev * p_ad777x_dev_inst = NULL
 
struct scan_type ad777x_scan_type
 
struct iio_device_data * ad777x_iio_dev_data
 
bool data_capture_operation = false
 

Detailed Description

Source file of AD777x IIO interfaces.

Copyright (c) 2022-2024 Analog Devices, Inc. All rights reserved.

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.

Macro Definition Documentation

◆ AD777x_CH_ATTR

#define AD777x_CH_ATTR (   _name,
  _idx 
)
Value:
{\
.name = _name,\
.priv = _idx,\
.show = ad777x_get_attribute,\
.store = ad777x_set_attribute\
}

◆ AD777x_CH_AVAIL_ATTR

#define AD777x_CH_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad777x_get_avail_attribute,\
.store = ad777x_set_avail_attribute \
}

◆ AD777x_CHANNEL

#define AD777x_CHANNEL (   _name,
  _idx 
)
Value:
{\
.name = _name # _idx, \
.ch_type = IIO_VOLTAGE,\
.ch_out = false,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = &ad777x_scan_type,\
.attributes = ad777x_channel_attributes\
}
struct scan_type ad777x_scan_type
Definition: ad777x_iio.c:182

◆ AD777x_EXTERNAL_REF_VAL

#define AD777x_EXTERNAL_REF_VAL   2.5

◆ AD777X_IIO_TRIGGER_NAME

#define AD777X_IIO_TRIGGER_NAME   "ad777x_iio_trigger"

◆ AD777x_INTERNAL_REF_VAL

#define AD777x_INTERNAL_REF_VAL   2.5

◆ AD777X_SAR_REFERENCE

#define AD777X_SAR_REFERENCE   3.3

◆ AD777X_SAR_RESOLUTION

#define AD777X_SAR_RESOLUTION   12

◆ AD777X_SAR_SCALE

#define AD777X_SAR_SCALE   AD777X_SAR_REFERENCE/(1 << (AD777X_SAR_RESOLUTION-1))

◆ AD777X_SRC_ATT_FACTOR

#define AD777X_SRC_ATT_FACTOR   6

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (128000)

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

◆ SRC_LOAD_UPDATE_HIGH

#define SRC_LOAD_UPDATE_HIGH   0x1

◆ SRC_LOAD_UPDATE_LOW

#define SRC_LOAD_UPDATE_LOW   0x0

Enumeration Type Documentation

◆ ad777x_attribute_id

Enumerator
RAW_ATTR_ID 
SCALE_ATTR_ID 
OFFSET_ATTR_ID 
PGA_ATTR_ATTR_ID 
PHASE_COMP_ATTR_ID 
GAIN_COMP_ATTR_ID 
OFFSET_COMP_ATTR_ID 
SAMPLING_FREQ_ATTR_ID 
SRC_ATTR_ID_INT 
SRC_ATTR_ID_DEC 
CONV_MODE_ATTR_ID 
ERROR_FLAG1_ATTR_ID 
ERROR_FLAG2_ATTR_ID 
ERROR_FLAG3_ATTR_ID 
AUXAINP_AUXAINN_MUX_ATTR_ID 
DVBE_AVSSX_MUX_ATTR_ID 
REF1P_REF1N_MUX_ATTR_ID 
REF2P_REF2N_MUX_ATTR_ID 
REF_OUT_AVSSX_MUX_ATTR_ID 
VCM_AVSSX_MUX_ATTR_ID 
AREG1CAP_AVSSX_MUX_ATTR_ID 
AREG2CAP_AVSSX_MUX_ATTR_ID 
DREGCAP_DGND_MUX_ATTR_ID 
AVDD1A_AVSSX_MUX_ATTR_ID 
AVDD1B_AVSSX_MUX_ATTR_ID 
AVDD2A_AVSSX_MUX_ATTR_ID 
AVDD2B_AVSSX_MUX_ATTR_ID 
IOVDD_DGND_MUX_ATTR_ID 
AVDD4_AVSSX_MUX_ATTR_ID 
DGND_AVSS1A_MUX_ATTR_ID 
DGND_AVSS1B_MUX_ATTR_ID 
DGND_AVSSX_MUX_ATTR_ID 
AVDD4_AVSSX_ATT_MUX_ATTR_ID 
REF1P_AVSSX_MUX_ATTR_ID 
REF2P_AVSSX_MUX_ATTR_ID 
AVSSX_AVDD4_MUX_ATTR_ID 
SINC5_STATE_ATTR_ID 

Function Documentation

◆ ad777x_iio_event_handler()

void ad777x_iio_event_handler ( void  )

Run the AD777x IIO event handler.

Returns
None
Here is the caller graph for this function:

◆ ad777x_iio_initialize()

int32_t ad777x_iio_initialize ( void  )

Initialize the IIO interface for AD777x IIO device.

Returns
none
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad777x_trigger_handler()

int32_t ad777x_trigger_handler ( struct iio_device_data *  iio_dev_data)

Push data into IIO buffer when trigger handler IRQ is invoked.

Parameters
iio_dev_data[in]- IIO device data instance
Returns
0 in case of success or negative value otherwise
Note
This function is utilized only in case of continuous capture in SPI Mode. In TDM Mode, it is utilized only to copy the private data member iio_dev_data

◆ data_capture_callback()

void data_capture_callback ( void *  ctx)

Interrupt Service Routine to monitor end of conversion event.

Interrupt Service Routine to monitor data ready event.

Parameters
ctx[in]- Callback context (unused)
Returns
none
Note
Callback registered for the the DRDY interrupt to indicate end of conversion in case of burst data capturing with SPI operation.

◆ iio_ad777x_init()

int32_t iio_ad777x_init ( struct iio_device **  desc)

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

Parameters
desc[in,out]- IIO device descriptor
Returns
0 in case of success or negative value otherwise

Variable Documentation

◆ ad777x_iio_dev_data

struct iio_device_data* ad777x_iio_dev_data

◆ ad777x_scan_type

struct scan_type ad777x_scan_type
Initial value:
= {
.storagebits = CHN_STORAGE_BITS,
.realbits = ADC_RESOLUTION,
.shift = 0,
.is_big_endian = false,
.sign = 's'
}
#define ADC_RESOLUTION
Definition: app_config.h:162
#define CHN_STORAGE_BITS
Definition: ad777x_iio.c:83

◆ data_capture_operation

bool data_capture_operation = false

◆ p_ad777x_dev_inst

ad7779_dev* p_ad777x_dev_inst = NULL