precision-converters-firmware
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
ad7606_iio.c File Reference
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "app_config.h"
#include "ad7606_iio.h"
#include "ad7606.h"
#include "ad7606_support.h"
#include "ad7606_user_config.h"
#include "common.h"
#include "no_os_error.h"
#include "no_os_gpio.h"
#include "iio_trigger.h"
Include dependency graph for ad7606_iio.c:

Macros

#define DEFAULT_SCALE   ((DEFAULT_CHN_RANGE / ADC_MAX_COUNT_BIPOLAR) * 1000)
 
#define MANUAL_OPEN_DETECT_ENTRY_TRHLD   350
 
#define MANUAL_OPEN_DETECT_THRESHOLD_RPD50K   20
 
#define MANUAL_OPEN_DETECT_CONV_CNTS   10
 
#define MANUAL_OPEN_DETECT_CONV_TRSHLD   10
 
#define MANUAL_OPEN_DETECT_CM_CNV_CNT   3
 
#define AUTO_OPEN_DETECT_QUEUE_MAX_CNT   128
 
#define AUTO_OPEN_DETECT_QUEUE_EXTRA_CONV_CNT   15
 
#define ADC_CALIBRATION_GAIN_MAX   64.0
 
#define OFFSET_REG_RESOLUTION   1
 
#define NUM_OF_IIO_DEVICES   1
 
#define IIO_TRIGGER_NAME   "ad7606_iio_trigger"
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define DATA_BUFFER_SIZE   (32768)
 

Enumerations

enum  ad7606_attribute_id {
  RAW_ATTR_ID ,
  SCALE_ATTR_ID ,
  OFFSET_ATTR_ID ,
  SAMPLING_FREQ_ATTR_ID
}
 
enum  range_e {
  LOW ,
  HIGH
}
 

Functions

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.
 
int32_t iio_ad7606_trigger_handler (struct iio_device_data *iio_dev_data)
 Push data into IIO buffer when trigger handler IRQ is invoked.
 
int32_t ad7606_iio_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

struct ad7606_dev * p_ad7606_dev_inst = NULL
 
struct iio_attribute channel_input_attributes []
 

Macro Definition Documentation

◆ ADC_CALIBRATION_GAIN_MAX

#define ADC_CALIBRATION_GAIN_MAX   64.0

◆ AUTO_OPEN_DETECT_QUEUE_EXTRA_CONV_CNT

#define AUTO_OPEN_DETECT_QUEUE_EXTRA_CONV_CNT   15

◆ AUTO_OPEN_DETECT_QUEUE_MAX_CNT

#define AUTO_OPEN_DETECT_QUEUE_MAX_CNT   128

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (32768)

◆ DEFAULT_SCALE

#define DEFAULT_SCALE   ((DEFAULT_CHN_RANGE / ADC_MAX_COUNT_BIPOLAR) * 1000)

◆ IIO_TRIGGER_NAME

#define IIO_TRIGGER_NAME   "ad7606_iio_trigger"

◆ MANUAL_OPEN_DETECT_CM_CNV_CNT

#define MANUAL_OPEN_DETECT_CM_CNV_CNT   3

◆ MANUAL_OPEN_DETECT_CONV_CNTS

#define MANUAL_OPEN_DETECT_CONV_CNTS   10

◆ MANUAL_OPEN_DETECT_CONV_TRSHLD

#define MANUAL_OPEN_DETECT_CONV_TRSHLD   10

◆ MANUAL_OPEN_DETECT_ENTRY_TRHLD

#define MANUAL_OPEN_DETECT_ENTRY_TRHLD   350

◆ MANUAL_OPEN_DETECT_THRESHOLD_RPD50K

#define MANUAL_OPEN_DETECT_THRESHOLD_RPD50K   20

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

◆ OFFSET_REG_RESOLUTION

#define OFFSET_REG_RESOLUTION   1

Enumeration Type Documentation

◆ ad7606_attribute_id

Enumerator
RAW_ATTR_ID 
SCALE_ATTR_ID 
OFFSET_ATTR_ID 
SAMPLING_FREQ_ATTR_ID 

◆ range_e

enum range_e
Enumerator
LOW 
HIGH 

Function Documentation

◆ ad7606_iio_event_handler()

void ad7606_iio_event_handler ( void  )

Run the AD7606 IIO event handler.

Returns
none

This function monitors the new IIO client event

Here is the caller graph for this function:

◆ ad7606_iio_initialize()

int32_t ad7606_iio_initialize ( void  )

Initialize the IIO interface for AD7606 IIO device.

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

◆ ad7606_iio_remove()

int32_t ad7606_iio_remove ( struct iio_desc *  desc)

Release resources allocated for IIO device.

Parameters
desc[in]- IIO device descriptor
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ debug_reg_read()

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

Read the debug register value.

Parameters
dev[in]-Pointer to IIO device instance
reg[in]-Register address to read from
readval[out]-Pointer to variable to read data into
Returns
0 in case of success, negative error code otherwise

◆ debug_reg_write()

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

Write into the debug register.

Parameters
dev[in]-Pointer to IIO device instance
reg[in]-Register address to write into
writeval[in]-Register value to write
Returns
0 in case of success, negative error code otherwise

◆ iio_ad7606_trigger_handler()

int32_t iio_ad7606_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

Variable Documentation

◆ channel_input_attributes

struct iio_attribute channel_input_attributes[]

◆ p_ad7606_dev_inst

struct ad7606_dev* p_ad7606_dev_inst = NULL

Pointer to the struct representing the AD7606 IIO device