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

AD579x IIO application interface module. More...

#include <string.h>
#include "app_config.h"
#include "ad579x_iio.h"
#include "ad579x_support.h"
#include "ad5791.h"
#include "ad579x_user_config.h"
#include "common.h"
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_gpio.h"
#include "no_os_pwm.h"
#include "iio_trigger.h"
Include dependency graph for ad579x_iio.c:

Macros

#define AD579X_CHN_ATTR(_name, _priv)
 
#define AD579X_CHN_AVAIL_ATTR(_name, _priv)
 
#define AD579X_CH(_name, _idx, _type)
 
#define NUM_OF_IIO_DEVICES   1
 
#define AD579X_IIO_TRIGGER_NAME   "ad579x_iio_trigger"
 
#define DEFAULT_SCALE   (((float)DAC_CH_SPAN/DAC_MAX_COUNT_BIN_OFFSET)*1000)
 
#define BYTES_PER_SAMPLE   sizeof(uint32_t)
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define DATA_BUFFER_SIZE   (32768)
 

Enumerations

enum  ad579x_attribute_ids {
  DAC_RAW ,
  DAC_SCALE ,
  DAC_OFFSET ,
  DAC_POWERDOWN ,
  DAC_CLR_CODE ,
  DAC_LIN_COMP ,
  DAC_OUTPUT_AMPLIFIER ,
  DAC_POWERDOWN_MODE ,
  DAC_CODE_SELECT ,
  DAC_SAMPLING_FREQUENCY ,
  DAC_LDAC ,
  DAC_CLR
}
 
enum  code_format_selection {
  TWOS_COMPLEMNT ,
  BINARY_OFFSET
}
 

Functions

int32_t ad579x_set_sampling_rate (uint32_t *sampling_rate)
 Set the sampling rate and get the updated value supported by MCU platform. More...
 
int ad579x_get_scale (float *scale)
 Get the IIO scale factor. More...
 
int ad579x_get_offset (uint32_t raw, int32_t *offset)
 Get the IIO offset value. More...
 
int32_t ad579x_iio_init ()
 Initialize the IIO interface for AD579x IIO device. More...
 
void ad579x_iio_event_handler (void)
 Run the AD579x IIO event handler. More...
 

Variables

struct ad5791_dev * ad579x_dev_desc = NULL
 
struct scan_type ad579x_iio_scan_type
 

Detailed Description

AD579x IIO application interface module.

Copyright (c) 2023-24 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

◆ AD579X_CH

#define AD579X_CH (   _name,
  _idx,
  _type 
)
Value:
{\
.name = _name, \
.ch_type = _type,\
.ch_out = true,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = &ad579x_iio_scan_type,\
.attributes = ad579x_iio_ch_attributes\
}
struct scan_type ad579x_iio_scan_type
Definition: ad579x_iio.c:170

◆ AD579X_CHN_ATTR

#define AD579X_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad579x_iio_attr_get,\
.store = ad579x_iio_attr_set\
}

◆ AD579X_CHN_AVAIL_ATTR

#define AD579X_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad579x_iio_attr_available_get,\
.store = ad579x_iio_attr_available_set\
}

◆ AD579X_IIO_TRIGGER_NAME

#define AD579X_IIO_TRIGGER_NAME   "ad579x_iio_trigger"

◆ BYTES_PER_SAMPLE

#define BYTES_PER_SAMPLE   sizeof(uint32_t)

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (32768)

◆ DEFAULT_SCALE

#define DEFAULT_SCALE   (((float)DAC_CH_SPAN/DAC_MAX_COUNT_BIN_OFFSET)*1000)

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

Enumeration Type Documentation

◆ ad579x_attribute_ids

Enumerator
DAC_RAW 
DAC_SCALE 
DAC_OFFSET 
DAC_POWERDOWN 
DAC_CLR_CODE 
DAC_LIN_COMP 
DAC_OUTPUT_AMPLIFIER 
DAC_POWERDOWN_MODE 
DAC_CODE_SELECT 
DAC_SAMPLING_FREQUENCY 
DAC_LDAC 
DAC_CLR 

◆ code_format_selection

Enumerator
TWOS_COMPLEMNT 
BINARY_OFFSET 

Function Documentation

◆ ad579x_get_offset()

int ad579x_get_offset ( uint32_t  raw,
int32_t *  offset 
)

Get the IIO offset value.

Parameters
raw[in]- DAC raw data
offset[in,out]- IIO offset value
Returns
0 in case of success, negative error code otherwise

◆ ad579x_get_scale()

int ad579x_get_scale ( float *  scale)

Get the IIO scale factor.

Parameters
scale[in,out]- IIO scale value
Returns
0 in case of success, negative error code otherwise

◆ ad579x_iio_event_handler()

void ad579x_iio_event_handler ( void  )

Run the AD579x IIO event handler.

Returns
none

This function monitors the new IIO client event

Here is the caller graph for this function:

◆ ad579x_iio_init()

int32_t ad579x_iio_init ( )

Initialize the IIO interface for AD579x IIO device.

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

◆ ad579x_set_sampling_rate()

int32_t ad579x_set_sampling_rate ( uint32_t *  sampling_rate)

Set the sampling rate and get the updated value supported by MCU platform.

Parameters
sampling_rate[in,out]- Sampling rate value
Returns
0 in case of success, negative error code otherwise

Variable Documentation

◆ ad579x_dev_desc

struct ad5791_dev* ad579x_dev_desc = NULL

◆ ad579x_iio_scan_type

struct scan_type ad579x_iio_scan_type
Initial value:
= {
.sign = 's',
.realbits = DAC_RESOLUTION,
.storagebits = CHN_STORAGE_BITS,
.shift = 0,
.is_big_endian = false
}
#define DAC_RESOLUTION
Definition: app_config.h:112
#define CHN_STORAGE_BITS
Definition: ad579x_iio.c:101