precision-converters-firmware
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
ad405x_iio.c File Reference

Implementation of AD405X IIO Application Interface. More...

#include <string.h>
#include <math.h>
#include "app_config.h"
#include "app_support.h"
#include "ad405x.h"
#include "ad405x_iio.h"
#include "ad405x_user_config.h"
#include "common.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_gpio.h"
#include "no_os_pwm.h"
#include "no_os_alloc.h"
#include "no_os_util.h"
#include "iio_trigger.h"
#include "version.h"
Include dependency graph for ad405x_iio.c:

Macros

#define AD405X_CHN_ATTR(_name, _priv)
 
#define AD405X_CHN_AVAIL_ATTR(_name, _priv)
 
#define NUM_OF_IIO_DEVICES   2
 
#define AD405X_IIO_TRIGGER_NAME   ACTIVE_DEVICE_NAME"_iio_trigger"
 
#define DEV_AD4050   "ad4050"
 
#define DEV_AD4052   "ad4052"
 
#define DEV_AD4060   "ad4060"
 
#define DEV_AD4062   "ad4062"
 
#define COMPENSATION_FACTOR   1.1
 
#define CONVERSION_TIME_NS   250
 
#define MAX_SAMPLING_PERIOD_NSEC   2500000
 

Enumerations

enum  ad405x_attribute_ids {
  ADC_RAW ,
  ADC_SCALE ,
  ADC_OFFSET ,
  ADC_OPERATING_MODE ,
  ADC_SAMPLE_RATE ,
  RESTART_IIO ,
  ADC_BURST_SAMPLE_RATE ,
  ADC_FILTER_LENGTH
}
 

Functions

void data_capture_callback (void *context)
 Interrupt Service Routine to monitor data ready event.
 
int iio_params_deinit (void)
 DeInitialize the IIO params.
 
int32_t iio_ad405x_initialize (void)
 Initialize the IIO interface for AD405X IIO device.
 
void iio_ad405x_event_handler (void)
 Run the AD405X IIO event handler.
 

Variables

struct ad405x_dev * p_ad405x_dev = NULL
 
struct iio_device * p_iio_ad405x_dev [NUM_OF_IIO_DEVICES]
 
struct iio_hw_trig * ad405x_hw_trig_desc
 
enum ad405x_operation_mode ad405x_operating_mode = AD405X_ADC_MODE_OP
 
enum ad405x_interface_modes ad405x_interface_mode = SPI_DMA
 
volatile bool data_ready = false
 
volatile uint8_t * buff_start_addr
 
volatile struct iio_device_data * iio_dev_data_g
 
uint8_t bytes_per_sample
 
struct no_os_spi_msg ad405x_spi_msg
 
struct stm32_spi_init_param * spi_init_param
 

Detailed Description

Implementation of AD405X IIO Application Interface.

This module acts as an interface for AD405X IIO device

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

◆ AD405X_CHN_ATTR

#define AD405X_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = iio_ad405x_attr_get,\
.store = iio_ad405x_attr_set\
}

◆ AD405X_CHN_AVAIL_ATTR

#define AD405X_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = iio_ad405x_attr_available_get,\
.store = iio_ad405x_attr_available_set\
}

◆ AD405X_IIO_TRIGGER_NAME

#define AD405X_IIO_TRIGGER_NAME   ACTIVE_DEVICE_NAME"_iio_trigger"

◆ COMPENSATION_FACTOR

#define COMPENSATION_FACTOR   1.1

◆ CONVERSION_TIME_NS

#define CONVERSION_TIME_NS   250

◆ DEV_AD4050

#define DEV_AD4050   "ad4050"

◆ DEV_AD4052

#define DEV_AD4052   "ad4052"

◆ DEV_AD4060

#define DEV_AD4060   "ad4060"

◆ DEV_AD4062

#define DEV_AD4062   "ad4062"

◆ MAX_SAMPLING_PERIOD_NSEC

#define MAX_SAMPLING_PERIOD_NSEC   2500000

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   2

Enumeration Type Documentation

◆ ad405x_attribute_ids

Enumerator
ADC_RAW 
ADC_SCALE 
ADC_OFFSET 
ADC_OPERATING_MODE 
ADC_SAMPLE_RATE 
RESTART_IIO 
ADC_BURST_SAMPLE_RATE 
ADC_FILTER_LENGTH 

Function Documentation

◆ data_capture_callback()

void data_capture_callback ( void *  context)

Interrupt Service Routine to monitor data ready event.

Parameters
context[in]- Callback context (unused)
Returns
none
Here is the caller graph for this function:

◆ iio_ad405x_event_handler()

void iio_ad405x_event_handler ( void  )

Run the AD405X IIO event handler.

Returns
none

This function monitors the new IIO client event

Here is the caller graph for this function:

◆ iio_ad405x_initialize()

int32_t iio_ad405x_initialize ( void  )

Initialize the IIO interface for AD405X IIO device.

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

◆ iio_params_deinit()

int iio_params_deinit ( void  )

DeInitialize the IIO params.

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

Variable Documentation

◆ ad405x_hw_trig_desc

struct iio_hw_trig* ad405x_hw_trig_desc

◆ ad405x_interface_mode

enum ad405x_interface_modes ad405x_interface_mode = SPI_DMA

◆ ad405x_operating_mode

enum ad405x_operation_mode ad405x_operating_mode = AD405X_ADC_MODE_OP

◆ ad405x_spi_msg

struct no_os_spi_msg ad405x_spi_msg

◆ buff_start_addr

volatile uint8_t* buff_start_addr

◆ bytes_per_sample

uint8_t bytes_per_sample

◆ data_ready

volatile bool data_ready = false

◆ iio_dev_data_g

volatile struct iio_device_data* iio_dev_data_g

◆ p_ad405x_dev

struct ad405x_dev* p_ad405x_dev = NULL

◆ p_iio_ad405x_dev

struct iio_device* p_iio_ad405x_dev[NUM_OF_IIO_DEVICES]

◆ spi_init_param

struct stm32_spi_init_param* spi_init_param