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

Implementation of iio_dac_demo. More...

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

Macros

#define DAC_DEMO_ATTR(_name, _priv)
 
#define IIO_DEMO_DAC_CHANNEL(_idx)
 

Functions

int get_dac_demo_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 get attributes for dac.
 
int dac_submit_samples (struct iio_device_data *dev_data)
 function for writing samples to the device.
 
int dac_demo_trigger_handler (struct iio_device_data *dev_data)
 Handles trigger: reads one data-set from iio buffer and writes it to the dac buffer.
 
int set_dac_demo_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 set attributes for dac.
 

Variables

struct scan_type dac_scan_type
 
struct iio_attribute dac_channel_attributes []
 
struct iio_attribute dac_global_attributes []
 
struct iio_device dac_demo_iio_descriptor
 

Detailed Description

Implementation of iio_dac_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

◆ DAC_DEMO_ATTR

#define DAC_DEMO_ATTR ( _name,
_priv )
Value:
{\
.name = _name,\
.priv = _priv,\
}
int get_dac_demo_attr(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
get attributes for dac.
Definition iio_dac_demo.c:53
int set_dac_demo_attr(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
set attributes for dac.
Definition iio_dac_demo.c:170

◆ IIO_DEMO_DAC_CHANNEL

#define IIO_DEMO_DAC_CHANNEL ( _idx)
Value:
{\
.name = "dac_out_ch" # _idx,\
.ch_type = IIO_VOLTAGE,\
.channel = _idx,\
.scan_index = _idx,\
.indexed = true,\
.scan_type = &dac_scan_type,\
.attributes = dac_channel_attributes,\
.ch_out = true,\
}
struct scan_type dac_scan_type
Definition iio_dac_demo.c:213
struct iio_attribute dac_channel_attributes[]
Definition iio_dac_demo.c:221
@ IIO_VOLTAGE
Definition iio_types.h:33

Function Documentation

◆ dac_demo_trigger_handler()

int dac_demo_trigger_handler ( struct iio_device_data * dev_data)

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

Parameters
dev_data- The iio device data structure.
Returns
ret - Result of the handling procedure. Returns 0 in case of success and a negative code otherwise.

◆ dac_submit_samples()

int dac_submit_samples ( struct iio_device_data * dev_data)

function for writing samples to the device.

Parameters
dev_data- The iio device data structure.
Returns
ret - Result of the writing procedure. Returns 0 in case of success and a negative code otherwise.

◆ get_dac_demo_attr()

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

get attributes for dac.

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_dac_demo_attr()

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

set attributes for dac.

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

◆ dac_channel_attributes

struct iio_attribute dac_channel_attributes[]
Initial value:
= {
DAC_DEMO_ATTR("dac_channel_attr", DAC_CHANNEL_ATTR),
}
@ DAC_CHANNEL_ATTR
Definition dac_demo.h:58
#define DAC_DEMO_ATTR(_name, _priv)
Definition iio_dac_demo.c:195
#define END_ATTRIBUTES_ARRAY
Definition iio_types.h:85

◆ dac_demo_iio_descriptor

struct iio_device dac_demo_iio_descriptor
Initial value:
= {
.num_ch = TOTAL_DAC_CHANNELS,
.channels = iio_dac_channels,
.attributes = dac_global_attributes,
.debug_attributes = NULL,
.buffer_attributes = NULL,
.pre_enable = iio_update_dac_channels,
.post_disable = close_dac_channels,
.trigger_handler = dac_demo_trigger_handler,
.submit = dac_submit_samples,
.debug_reg_read = iio_dac_demo_reg_read,
.debug_reg_write = iio_dac_demo_reg_write
}
int close_dac_channels(void *dev)
close all channels
Definition dac_demo.c:82
int dac_submit_samples(struct iio_device_data *dev_data)
function for writing samples to the device.
Definition iio_dac_demo.c:81
int dac_demo_trigger_handler(struct iio_device_data *dev_data)
Handles trigger: reads one data-set from iio buffer and writes it to the dac buffer.
Definition iio_dac_demo.c:124
#define TOTAL_DAC_CHANNELS
Definition dac_demo.h:20
struct iio_attribute dac_global_attributes[]
Definition iio_dac_demo.c:226
#define NULL
Definition wrapper.h:67

◆ dac_global_attributes

struct iio_attribute dac_global_attributes[]
Initial value:
= {
DAC_DEMO_ATTR("dac_global_attr", DAC_GLOBAL_ATTR),
}
@ DAC_GLOBAL_ATTR
Definition dac_demo.h:59

◆ dac_scan_type

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