no-OS
Loading...
Searching...
No Matches
iio_adc_demo.c File Reference

Implementation of iio_adc_demo. More...

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "no_os_error.h"
#include "no_os_util.h"
#include "iio_adc_demo.h"
#include "iio.h"
Include dependency graph for iio_adc_demo.c:

Macros

#define ADC_DEMO_ATTR(_name, _priv)
 
#define IIO_DEMO_ADC_CHANNEL(_idx)
 

Functions

int get_adc_demo_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 get attributes for adc.
 
int set_adc_demo_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 set attributes for adc.
 
int adc_submit_samples (struct iio_device_data *dev_data)
 function for reading samples from the device.
 
int adc_demo_trigger_handler (struct iio_device_data *dev_data)
 Handles trigger: reads one data-set and writes it to the buffer.
 

Variables

struct scan_type adc_scan_type
 
struct iio_attribute adc_channel_attributes []
 
struct iio_attribute iio_adc_global_attributes []
 
struct iio_device adc_demo_iio_descriptor
 

Detailed Description

Implementation of iio_adc_demo.

Author
Andrei Drimbarean (andre.nosp@m.i.dr.nosp@m.imbar.nosp@m.ean@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2021(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ ADC_DEMO_ATTR

#define ADC_DEMO_ATTR ( _name,
_priv )
Value:
{\
.name = _name,\
.priv = _priv,\
.store = set_adc_demo_attr \
}
int get_adc_demo_attr(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
get attributes for adc.
Definition iio_adc_demo.c:53
int set_adc_demo_attr(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
set attributes for adc.
Definition iio_adc_demo.c:84

◆ IIO_DEMO_ADC_CHANNEL

#define IIO_DEMO_ADC_CHANNEL ( _idx)
Value:
{\
.name = "adc_in_ch" # _idx,\
.ch_type = IIO_VOLTAGE,\
.channel = _idx,\
.scan_index = _idx,\
.indexed = true,\
.scan_type = &adc_scan_type,\
.attributes = adc_channel_attributes,\
.ch_out = false,\
}
struct scan_type adc_scan_type
Definition iio_adc_demo.c:206
struct iio_attribute adc_channel_attributes[]
Definition iio_adc_demo.c:214
@ IIO_VOLTAGE
Definition iio_types.h:33

Function Documentation

◆ adc_demo_trigger_handler()

int adc_demo_trigger_handler ( struct iio_device_data * dev_data)

Handles trigger: reads one data-set and writes it to the buffer.

Parameters
dev_data- The iio device data structure.
Returns
ret - Result of the handling procedure. In case of success, the size of the written data is returned.

◆ adc_submit_samples()

int adc_submit_samples ( struct iio_device_data * dev_data)

function for reading samples from the device.

Parameters
dev_data- The iio device data structure.
Returns
the number of read samples.

◆ get_adc_demo_attr()

int get_adc_demo_attr ( void * device,
char * buf,
uint32_t len,
const struct iio_ch_info * channel,
intptr_t attr_id )

get attributes for adc.

Parameters
device-Physical instance of a iio_demo_device.
buf- Where value is stored.
len- Maximum length of value to be stored in buf.
channel- Channel properties.
attr_id- Attribute ID
Returns
Length of chars written in buf, or negative value on failure.

◆ set_adc_demo_attr()

int set_adc_demo_attr ( void * device,
char * buf,
uint32_t len,
const struct iio_ch_info * channel,
intptr_t attr_id )

set attributes for adc.

Parameters
device- Physical instance of a iio_demo_device.
buf- Value to be written to attribute.
len- Length of the data in "buf".
channel- Channel properties.
attr_id- Attribute ID
Returns
: Number of bytes written to device, or negative value on failure.

Variable Documentation

◆ adc_channel_attributes

struct iio_attribute adc_channel_attributes[]
Initial value:
= {
ADC_DEMO_ATTR("adc_channel_attr", ADC_CHANNEL_ATTR),
}
@ ADC_CHANNEL_ATTR
Definition adc_demo.h:59
#define ADC_DEMO_ATTR(_name, _priv)
Definition iio_adc_demo.c:199
#define END_ATTRIBUTES_ARRAY
Definition iio_types.h:85

◆ adc_demo_iio_descriptor

struct iio_device adc_demo_iio_descriptor
Initial value:
= {
.num_ch = TOTAL_ADC_CHANNELS,
.channels = iio_adc_channels,
.debug_attributes = NULL,
.buffer_attributes = NULL,
.pre_enable = update_adc_channels,
.post_disable = close_adc_channels,
.trigger_handler = adc_demo_trigger_handler,
.submit = adc_submit_samples,
.debug_reg_read = iio_adc_demo_reg_read,
.debug_reg_write = iio_adc_demo_reg_write
}
int close_adc_channels(void *dev)
close all channels
Definition adc_demo.c:105
int update_adc_channels(void *dev, uint32_t mask)
active adc channels
Definition adc_demo.c:85
int adc_demo_trigger_handler(struct iio_device_data *dev_data)
Handles trigger: reads one data-set and writes it to the buffer.
Definition iio_adc_demo.c:161
int adc_submit_samples(struct iio_device_data *dev_data)
function for reading samples from the device.
Definition iio_adc_demo.c:114
#define TOTAL_ADC_CHANNELS
Definition adc_demo.h:21
struct iio_attribute iio_adc_global_attributes[]
Definition iio_adc_demo.c:219
#define NULL
Definition wrapper.h:67

◆ adc_scan_type

struct scan_type adc_scan_type
Initial value:
= {
.sign = 's',
.realbits = 16,
.storagebits = 16,
.shift = 0,
.is_big_endian = false
}

◆ iio_adc_global_attributes

struct iio_attribute iio_adc_global_attributes[]
Initial value:
= {
ADC_DEMO_ATTR("adc_global_attr", ADC_GLOBAL_ATTR),
}
@ ADC_GLOBAL_ATTR
Definition adc_demo.h:60