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

Main interface for AD7124 IIO Application firmware example program. More...

#include <stdio.h>
#include <string.h>
#include "ad7124_user_config.h"
#include "ad7124_iio.h"
#include "no_os_util.h"
#include "no_os_error.h"
#include "common.h"
#include "no_os_gpio.h"
#include "no_os_irq.h"
#include "ad7124_support.h"
#include "iio_trigger.h"
Include dependency graph for ad7124_iio.c:

Macros

#define BYTES_PER_SAMPLE   sizeof(uint32_t)
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define ADC_BUFFER_SIZE   (32768)
 
#define AD7124_DEFAULT_REF_VOLTAGE   (2.5)
 
#define NUM_OF_IIO_DEVICES   1
 
#define AD7124_CHN_ATTR(_name, _priv)
 
#define AD7124_CHN_AVAIL_ATTR(_name, _priv)
 
#define AD7124_CH(_name, _dev, _idx, _type)
 
#define AD7124_DEFAULT_CHN_SCAN
 
#define SAMPLING_RATE_LOW_POWER   2400
 
#define SAMPLING_RATE_MID_POWER   4800
 
#define SAMPLING_RATE_HIGH_POWER   19200
 
#define SAMPLING_RATE   19200
 
#define AD7124_MAX_REG   AD7124_GAIN7_REG
 
#define AD7124_IIO_TRIGGER_NAME   "ad7124_iio_trigger"
 

Enumerations

enum  ad7124_iio_attr_id {
  IIO_RAW_ATTR_ID ,
  IIO_SCALE_ATTR_ID ,
  IIO_OFFSET_ATTR_ID ,
  NUM_OF_CHN_ATTR ,
  IIO_3DB_FREQUENCY_ID ,
  IIO_SAMPLING_FREQUENCY_ID ,
  IIO_POWER_MODE_ID
}
 

Functions

int32_t ad7124_trigger_handler (struct iio_device_data *iio_dev_data)
 
void data_capture_callback (void *ctx)
 Interrupt Service Routine to monitor end of conversion event. More...
 
int ad7124_iio_remove (struct iio_desc *desc)
 Release resources allocated for IIO device. More...
 
int ad7124_iio_init (struct iio_device **desc, uint8_t dev_indx)
 Init for reading/writing and parameterization of a AD7124 IIO device. More...
 
int32_t ad7124_iio_initialize (void)
 Initialize the AD7124 IIO Interface. More...
 
void ad7124_iio_event_handler (void)
 Run the AD7124 IIO event handler. More...
 

Variables

struct ad7124_dev * ad7124_dev_inst = NULL
 
struct scan_type chn_scan [NUM_OF_IIO_DEVICES][AD7124_MAX_CHANNELS]
 
volatile bool data_capture_done = false
 
struct iio_trigger_init iio_trigger_init_params
 

Detailed Description

Main interface for AD7124 IIO Application firmware example program.

This module acts as an interface for the AD7124 IIO Application.

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

◆ AD7124_CH

#define AD7124_CH (   _name,
  _dev,
  _idx,
  _type 
)
Value:
{\
.name = _name, \
.ch_type = _type,\
.ch_out = 0,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = chn_scan[_dev],\
.attributes = chn_attr[_dev]\
}
struct scan_type chn_scan[NUM_OF_IIO_DEVICES][AD7124_MAX_CHANNELS]
Definition: ad7124_iio.c:173

◆ AD7124_CHN_ATTR

#define AD7124_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad7124_iio_attr_get,\
.store = ad7124_iio_attr_set\
}

◆ AD7124_CHN_AVAIL_ATTR

#define AD7124_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ad7124_iio_attr_available_get,\
.store = ad7124_iio_attr_available_set\
}

◆ AD7124_DEFAULT_CHN_SCAN

#define AD7124_DEFAULT_CHN_SCAN
Value:
{\
.sign = 's',\
.realbits = ADC_RESOLUTION,\
.storagebits = CHN_STORAGE_BITS,\
.shift = 0,\
.is_big_endian = false\
}
#define ADC_RESOLUTION
Definition: app_config.h:162
#define CHN_STORAGE_BITS
Definition: ad7124_iio.c:81

◆ AD7124_DEFAULT_REF_VOLTAGE

#define AD7124_DEFAULT_REF_VOLTAGE   (2.5)

◆ AD7124_IIO_TRIGGER_NAME

#define AD7124_IIO_TRIGGER_NAME   "ad7124_iio_trigger"

◆ AD7124_MAX_REG

#define AD7124_MAX_REG   AD7124_GAIN7_REG

◆ ADC_BUFFER_SIZE

#define ADC_BUFFER_SIZE   (32768)

◆ BYTES_PER_SAMPLE

#define BYTES_PER_SAMPLE   sizeof(uint32_t)

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

◆ SAMPLING_RATE

#define SAMPLING_RATE   19200

◆ SAMPLING_RATE_HIGH_POWER

#define SAMPLING_RATE_HIGH_POWER   19200

◆ SAMPLING_RATE_LOW_POWER

#define SAMPLING_RATE_LOW_POWER   2400

◆ SAMPLING_RATE_MID_POWER

#define SAMPLING_RATE_MID_POWER   4800

Enumeration Type Documentation

◆ ad7124_iio_attr_id

Enumerator
IIO_RAW_ATTR_ID 
IIO_SCALE_ATTR_ID 
IIO_OFFSET_ATTR_ID 
NUM_OF_CHN_ATTR 
IIO_3DB_FREQUENCY_ID 
IIO_SAMPLING_FREQUENCY_ID 
IIO_POWER_MODE_ID 

Function Documentation

◆ ad7124_iio_event_handler()

void ad7124_iio_event_handler ( void  )

Run the AD7124 IIO event handler.

Returns
None
Here is the caller graph for this function:

◆ ad7124_iio_init()

int ad7124_iio_init ( struct iio_device **  desc,
uint8_t  dev_indx 
)

Init for reading/writing and parameterization of a AD7124 IIO device.

Parameters
desc[in,out]- IIO device descriptor
dev_indx[in]- IIO device number
Returns
0 in case of success, negative error code otherwise

◆ ad7124_iio_initialize()

int32_t ad7124_iio_initialize ( void  )

Initialize the AD7124 IIO Interface.

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

◆ ad7124_iio_remove()

int ad7124_iio_remove ( struct iio_desc *  desc)

Release resources allocated for IIO device.

Parameters
desc[in]- IIO device descriptor
Returns
0 in case of success, negative error code otherwise

◆ ad7124_trigger_handler()

int32_t ad7124_trigger_handler ( struct iio_device_data *  iio_dev_data)

◆ data_capture_callback()

void data_capture_callback ( void *  ctx)

Interrupt Service Routine to monitor end of conversion event.

Interrupt Service Routine to monitor data ready event.

Parameters
ctx[in]- Callback context (unused)
Returns
none
Note
Callback registered for the the RDY interrupt to indicate end of conversion in case of burst data capturing.

Variable Documentation

◆ ad7124_dev_inst

struct ad7124_dev* ad7124_dev_inst = NULL

◆ chn_scan

struct scan_type chn_scan[NUM_OF_IIO_DEVICES][AD7124_MAX_CHANNELS]
Initial value:
= {
}
#define AD7124_DEFAULT_CHN_SCAN
Definition: ad7124_iio.c:127

◆ data_capture_done

volatile bool data_capture_done = false

◆ iio_trigger_init_params

struct iio_trigger_init iio_trigger_init_params
Initial value:
= {
.descriptor = &ad7124_iio_trig_desc,
}
#define AD7124_IIO_TRIGGER_NAME
Definition: ad7124_iio.c:191