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

Implementation of AD5754R IIO application interfaces. More...

#include <stdlib.h>
#include <string.h>
#include "app_config.h"
#include "ad5754r_iio.h"
#include "ad5754r_user_config.h"
#include "cn0586_support.h"
#include "common.h"
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_delay.h"
#include "no_os_gpio.h"
#include "no_os_pwm.h"
#include "no_os_alloc.h"
#include "iio_trigger.h"
Include dependency graph for ad5754r_iio.c:

Macros

#define AD5754R_IIO_TRIGGER_NAME   "ad5754r_iio_trigger"
 
#define AD5754R_CHN_ATTR(_name, _priv)
 
#define AD5754R_CHN_AVAIL_ATTR(_name, _priv)
 
#define CN0586_CHN_ATTR(_name, _priv)
 
#define CN0586_CHN_AVAIL_ATTR(_name, _priv)
 
#define AD5754R_DAC_CH(_name, _idx)
 
#define NUM_OF_IIO_DEVICES   2
 
#define BYTES_PER_SAMPLE   sizeof(uint16_t)
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define BYTE_SIZE   (uint32_t)8
 
#define BYTE_MASK   (uint32_t)0xff
 
#define DATA_BUFFER_SIZE   (32768)
 
#define AD5754R_ATTRS_OFFSET   6
 

Enumerations

enum  ad5754r_attribute_ids {
  HVOUT_STATE ,
  HVOUT_RANGE ,
  HVOUT_VOLTS ,
  DAC_CH_RAW ,
  DAC_CH_REG ,
  DAC_CH_SCALE ,
  DAC_CH_OFFSET ,
  DAC_CH_POWERUP ,
  DAC_CH_RANGE ,
  DAC_INT_REF_POWERUP ,
  DAC_CLEAR_SETTING ,
  DAC_SDO_DIS ,
  DAC_UPDATE_RATE ,
  DAC_CLAMP_EN ,
  DAC_TSD_EN ,
  DAC_OC_TSD ,
  DAC_ALL_CH_CLR ,
  DAC_SW_LDAC ,
  DAC_HW_LDAC
}
 

Functions

int ad5754r_reconfig_ldac (struct ad5754r_dev *device)
 Reconfigure LDAC pin as GPIO output. More...
 
int32_t ad5754r_iio_init (void)
 Initialize the IIO interface for AD5754R IIO device. More...
 
void ad5754r_iio_event_handler (void)
 Run the AD5754r IIO event handler. More...
 

Variables

struct cn0586_devcn0586_dev_inst = NULL
 
struct ad5754r_dev * ad5754r_dev_inst = NULL
 
struct scan_type iio_ad5754r_scan_type
 

Detailed Description

Implementation of AD5754R IIO application interfaces.

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

◆ AD5754R_ATTRS_OFFSET

#define AD5754R_ATTRS_OFFSET   6

◆ AD5754R_CHN_ATTR

#define AD5754R_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad5754r_iio_attr_get,\
.store = ad5754r_iio_attr_set\
}

◆ AD5754R_CHN_AVAIL_ATTR

#define AD5754R_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad5754r_iio_attr_available_get,\
.store = ad5754r_iio_attr_available_set\
}

◆ AD5754R_DAC_CH

#define AD5754R_DAC_CH (   _name,
  _idx 
)
Value:
{\
.name = _name # _idx, \
.ch_type = IIO_VOLTAGE,\
.ch_out = 1,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = &iio_ad5754r_scan_type,\
.attributes = iio_ad5754r_dac_ch_attributes\
}
struct scan_type iio_ad5754r_scan_type
Definition: ad5754r_iio.c:188

◆ AD5754R_IIO_TRIGGER_NAME

#define AD5754R_IIO_TRIGGER_NAME   "ad5754r_iio_trigger"

◆ BYTE_MASK

#define BYTE_MASK   (uint32_t)0xff

◆ BYTE_SIZE

#define BYTE_SIZE   (uint32_t)8

◆ BYTES_PER_SAMPLE

#define BYTES_PER_SAMPLE   sizeof(uint16_t)

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ CN0586_CHN_ATTR

#define CN0586_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad5754r_iio_attr_get,\
.store = ad5754r_iio_attr_set\
}

◆ CN0586_CHN_AVAIL_ATTR

#define CN0586_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad5754r_iio_attr_available_get,\
.store = ad5754r_iio_attr_available_set\
}

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (32768)

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   2

Enumeration Type Documentation

◆ ad5754r_attribute_ids

Enumerator
HVOUT_STATE 
HVOUT_RANGE 
HVOUT_VOLTS 
DAC_CH_RAW 
DAC_CH_REG 
DAC_CH_SCALE 
DAC_CH_OFFSET 
DAC_CH_POWERUP 
DAC_CH_RANGE 
DAC_INT_REF_POWERUP 
DAC_CLEAR_SETTING 
DAC_SDO_DIS 
DAC_UPDATE_RATE 
DAC_CLAMP_EN 
DAC_TSD_EN 
DAC_OC_TSD 
DAC_ALL_CH_CLR 
DAC_SW_LDAC 
DAC_HW_LDAC 

Function Documentation

◆ ad5754r_iio_event_handler()

void ad5754r_iio_event_handler ( void  )

Run the AD5754r IIO event handler.

Returns
none.

This function monitors the new IIO client event.

Here is the caller graph for this function:

◆ ad5754r_iio_init()

int32_t ad5754r_iio_init ( void  )

Initialize the IIO interface for AD5754R IIO device.

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

◆ ad5754r_reconfig_ldac()

int ad5754r_reconfig_ldac ( struct ad5754r_dev *  device)

Reconfigure LDAC pin as GPIO output.

Parameters
device[in]- AD5754R device instance
Returns
0 in case of success, negative error code otherwise

Variable Documentation

◆ ad5754r_dev_inst

struct ad5754r_dev* ad5754r_dev_inst = NULL

◆ cn0586_dev_inst

struct cn0586_dev* cn0586_dev_inst = NULL

◆ iio_ad5754r_scan_type

struct scan_type iio_ad5754r_scan_type
Initial value:
= {
.sign = 'u',
.realbits = AD5754R_MAX_RESOLUTION,
.storagebits = CHN_STORAGE_BITS,
.shift = 0,
.is_big_endian = false
}
#define CHN_STORAGE_BITS
Definition: ad5754r_iio.c:113