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

Implementation of AD469x IIO application interfaces. More...

#include <inttypes.h>
#include <string.h>
#include <math.h>
#include "app_config.h"
#include "ad469x_iio.h"
#include "ad469x_support.h"
#include "ad469x_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 "no_os_print_log.h"
#include "iio_trigger.h"
Include dependency graph for ad469x_iio.c:

Macros

#define AD469X_CHN_ATTR(_name, _priv)
 
#define AD469X_CHN_AVAIL_ATTR(_name, _priv)
 
#define AD469X_IIO_CH(_name, _idx)
 
#define DATA_BUFFER_SIZE   (32768)
 
#define NUM_OF_IIO_DEVICES   1
 
#define AD469x_IIO_TRIGGER_NAME   "ad469x_iio_trigger"
 
#define REGISTER_MAX_VAL   0x017F
 
#define PWM_PERIOD_TO_FREQUENCY(x)   (1000000000.0 / x)
 
#define BUF_READ_TIMEOUT   0xffffffff
 
#define AD469X_GAIN_CORR_SCALE(x)   (float)(x) / (float)(ADC_MAX_COUNT_BIPOLAR)
 
#define MAX_LOCAL_BUF_SIZE   8000
 
#define MAX_DMA_NDTR   (no_os_min(65535, MAX_LOCAL_BUF_SIZE/2))
 

Enumerations

enum  ad469x_attribute_ids {
  ADC_RAW ,
  ADC_SCALE ,
  ADC_OFFSET ,
  ADC_REFERENCE_SEL ,
  ADC_OFFSET_CORRECTION ,
  ADC_GAIN_CORRECTION ,
  ADC_AIN_HIGH_Z ,
  ADC_SAMPLING_FREQUENCY
}
 

Functions

int32_t ad469x_update_sampling_frequency (uint32_t *sampling_rate)
 Set the sampling rate and get the updated value supported by MCU platform. More...
 
int32_t ad469x_trigger_handler (struct iio_device_data *iio_dev_data)
 Push data into IIO buffer when trigger handler IRQ is invoked. More...
 
void burst_capture_callback (void *context)
 Interrupt Service Routine to monitor end of conversion event. More...
 
int32_t ad469x_iio_initialize (void)
 Release resources allocated for IIO device. More...
 
void ad469x_iio_event_handler (void)
 Run the ad469x IIO event handler. More...
 

Variables

struct ad469x_dev * p_ad469x_dev = NULL
 
volatile bool ad469x_conversion_flag = false
 
volatile uint32_t * buff_start_addr
 
volatile bool dma_config_updated = false
 
struct scan_type ad469x_iio_scan_type
 
volatile struct iio_device_data * global_iio_dev_data
 
uint32_t global_nb_of_samples
 
int32_t data_read
 

Detailed Description

Implementation of AD469x IIO application interfaces.

This module acts as an interface for AD469x IIO application

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

◆ AD469X_CHN_ATTR

#define AD469X_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad469x_iio_attr_get,\
.store = ad469x_iio_attr_set\
}

◆ AD469X_CHN_AVAIL_ATTR

#define AD469X_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad469x_iio_attr_available_get,\
.store = ad469x_iio_attr_available_set\
}

◆ AD469X_GAIN_CORR_SCALE

#define AD469X_GAIN_CORR_SCALE (   x)    (float)(x) / (float)(ADC_MAX_COUNT_BIPOLAR)

◆ AD469X_IIO_CH

#define AD469X_IIO_CH (   _name,
  _idx 
)
Value:
{\
.name = _name #_idx, \
.ch_type = IIO_VOLTAGE,\
.ch_out = false,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = &ad469x_iio_scan_type,\
.attributes = ad469x_iio_ch_attributes\
}
struct scan_type ad469x_iio_scan_type
Definition: ad469x_iio.c:190

◆ AD469x_IIO_TRIGGER_NAME

#define AD469x_IIO_TRIGGER_NAME   "ad469x_iio_trigger"

◆ BUF_READ_TIMEOUT

#define BUF_READ_TIMEOUT   0xffffffff

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (32768)

◆ MAX_DMA_NDTR

#define MAX_DMA_NDTR   (no_os_min(65535, MAX_LOCAL_BUF_SIZE/2))

◆ MAX_LOCAL_BUF_SIZE

#define MAX_LOCAL_BUF_SIZE   8000

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

◆ PWM_PERIOD_TO_FREQUENCY

#define PWM_PERIOD_TO_FREQUENCY (   x)    (1000000000.0 / x)

◆ REGISTER_MAX_VAL

#define REGISTER_MAX_VAL   0x017F

Enumeration Type Documentation

◆ ad469x_attribute_ids

Enumerator
ADC_RAW 
ADC_SCALE 
ADC_OFFSET 
ADC_REFERENCE_SEL 
ADC_OFFSET_CORRECTION 
ADC_GAIN_CORRECTION 
ADC_AIN_HIGH_Z 
ADC_SAMPLING_FREQUENCY 

Function Documentation

◆ ad469x_iio_event_handler()

void ad469x_iio_event_handler ( void  )

Run the ad469x IIO event handler.

Returns
None
Here is the caller graph for this function:

◆ ad469x_iio_initialize()

int32_t ad469x_iio_initialize ( void  )

Release resources allocated for IIO device.

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

◆ ad469x_trigger_handler()

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

◆ ad469x_update_sampling_frequency()

int32_t ad469x_update_sampling_frequency ( 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

◆ burst_capture_callback()

void burst_capture_callback ( void *  context)

Interrupt Service Routine to monitor end of conversion event.

Parameters
context[in]- Callback context (unused)
Returns
none

Variable Documentation

◆ ad469x_conversion_flag

volatile bool ad469x_conversion_flag = false

◆ ad469x_iio_scan_type

struct scan_type ad469x_iio_scan_type
Initial value:
= {
.sign = 'u',
.realbits = CHN_STORAGE_BITS,
.storagebits = ADC_RESOLUTION,
.shift = 0,
.is_big_endian = false
}
#define CHN_STORAGE_BITS
Definition: ad2s1210_iio.c:70
#define ADC_RESOLUTION
Definition: app_config.h:162

◆ buff_start_addr

volatile uint32_t* buff_start_addr

◆ data_read

int32_t data_read

◆ dma_config_updated

volatile bool dma_config_updated = false

◆ global_iio_dev_data

volatile struct iio_device_data* global_iio_dev_data

◆ global_nb_of_samples

uint32_t global_nb_of_samples

◆ p_ad469x_dev

struct ad469x_dev* p_ad469x_dev = NULL