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

AD738x IIO application interface module. More...

#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include "app_config.h"
#include "ad738x_iio.h"
#include "ad738x_user_config.h"
#include "common.h"
#include "iio.h"
#include "iio_types.h"
#include "iio_trigger.h"
#include "no_os_error.h"
#include "no_os_delay.h"
Include dependency graph for ad738x_iio.c:

Macros

#define AD738X_CHN_ATTR(_name, _priv)
 
#define AD738X_CH(_name, _idx, _type)
 
#define NUM_OF_IIO_DEVICES   1
 
#define BYTES_PER_SAMPLE   2
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define AD738X_MIN_SAMPLING_FREQ   (100 / ADC_CHANNELS)
 
#define AD738X_DEF_IIO_SCALE   (ADC_REF_VOLTAGE / ADC_MAX_COUNT_BIPOLAR) * 1000
 
#define AD738X_IIO_TRIGGER_NAME   "ad738x_iio_trigger"
 
#define DATA_BUFFER_SIZE   (32768)
 

Enumerations

enum  ad738x_attribute_id {
  RAW_ATTR_ID ,
  SCALE_ATTR_ID ,
  OFFSET_ATTR_ID ,
  SAMPLING_FREQ_ATTR_ID
}
 

Functions

int32_t ad738x_trigger_handler (struct iio_device_data *iio_dev_data)
 Push data into IIO buffer when trigger handler IRQ is invoked. More...
 
int32_t ad738x_iio_initialize (void)
 Initialize the IIO interface for AD738x IIO device. More...
 
void ad738x_iio_event_handler (void)
 Run the AD738x IIO event handler. More...
 

Variables

struct ad738x_dev * ad738x_dev_inst = NULL
 

Detailed Description

AD738x IIO application interface module.

Copyright (c) 2022-23 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.

Macro Definition Documentation

◆ AD738X_CH

#define AD738X_CH (   _name,
  _idx,
  _type 
)
Value:
{\
.name = _name, \
.ch_type = _type,\
.ch_out = false,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = &chn_scan,\
.attributes = ad738x_iio_ch_attributes\
}
struct scan_type chn_scan[RESOLVER_CHANNELS]
Definition: ad2s1210_iio.c:110

◆ AD738X_CHN_ATTR

#define AD738X_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = iio_ad738x_attr_get,\
.store = iio_ad738x_attr_set\
}

◆ AD738X_DEF_IIO_SCALE

#define AD738X_DEF_IIO_SCALE   (ADC_REF_VOLTAGE / ADC_MAX_COUNT_BIPOLAR) * 1000

◆ AD738X_IIO_TRIGGER_NAME

#define AD738X_IIO_TRIGGER_NAME   "ad738x_iio_trigger"

◆ AD738X_MIN_SAMPLING_FREQ

#define AD738X_MIN_SAMPLING_FREQ   (100 / ADC_CHANNELS)

◆ BYTES_PER_SAMPLE

#define BYTES_PER_SAMPLE   2

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (32768)

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

Enumeration Type Documentation

◆ ad738x_attribute_id

Enumerator
RAW_ATTR_ID 
SCALE_ATTR_ID 
OFFSET_ATTR_ID 
SAMPLING_FREQ_ATTR_ID 

Function Documentation

◆ ad738x_iio_event_handler()

void ad738x_iio_event_handler ( void  )

Run the AD738x IIO event handler.

Returns
none

This function monitors the new IIO client event

Here is the caller graph for this function:

◆ ad738x_iio_initialize()

int32_t ad738x_iio_initialize ( void  )

Initialize the IIO interface for AD738x IIO device.

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

◆ ad738x_trigger_handler()

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

◆ ad738x_dev_inst

struct ad738x_dev* ad738x_dev_inst = NULL