no-OS
Macros | Functions | Variables
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. More...
 
int32_t dac_submit_samples (struct iio_device_data *dev_data)
 function for writing samples to the device. More...
 
int32_t 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. More...
 
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. More...
 

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.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ DAC_DEMO_ATTR

#define DAC_DEMO_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
}

◆ 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,\
}

Function Documentation

◆ dac_demo_trigger_handler()

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

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

struct iio_device dac_demo_iio_descriptor
Initial value:
= {
.num_ch = TOTAL_DAC_CHANNELS,
.channels = iio_dac_channels,
.debug_attributes = NULL,
.buffer_attributes = NULL,
.pre_enable = (int32_t (*)())update_dac_channels,
.post_disable = close_dac_channels,
.trigger_handler = (int32_t (*)())dac_demo_trigger_handler,
.submit = (int32_t (*)())dac_submit_samples,
.debug_reg_read = (int32_t (*)()) dac_demo_reg_read,
.debug_reg_write = (int32_t (*)()) dac_demo_reg_write
}

◆ dac_global_attributes

struct iio_attribute dac_global_attributes[]
Initial value:

◆ dac_scan_type

struct scan_type dac_scan_type
Initial value:
= {
.sign = 's',
.realbits = 16,
.storagebits = 16,
.shift = 0,
.is_big_endian = false
}
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.
Definition: iio_dac_demo.c:82
dac_demo_reg_write
int32_t dac_demo_reg_write(struct dac_demo_desc *desc, uint8_t reg_index, uint8_t writeval)
write function for the dac demo driver
Definition: dac_demo.c:157
dac_channel_attributes
struct iio_attribute dac_channel_attributes[]
Definition: iio_dac_demo.c:250
END_ATTRIBUTES_ARRAY
#define END_ATTRIBUTES_ARRAY
Definition: iio_types.h:122
close_dac_channels
int32_t close_dac_channels(void *dev)
close all channels
Definition: dac_demo.c:119
dac_demo_reg_read
int32_t dac_demo_reg_read(struct dac_demo_desc *desc, uint8_t reg_index, uint8_t *readval)
read function for the dac demo driver
Definition: dac_demo.c:139
update_dac_channels
int32_t update_dac_channels(void *dev, int32_t mask)
update number of active channels
Definition: dac_demo.c:101
dac_global_attributes
struct iio_attribute dac_global_attributes[]
Definition: iio_dac_demo.c:255
dac_submit_samples
int32_t dac_submit_samples(struct iio_device_data *dev_data)
function for writing samples to the device.
Definition: iio_dac_demo.c:110
DAC_GLOBAL_ATTR
@ DAC_GLOBAL_ATTR
Definition: dac_demo.h:96
DAC_DEMO_ATTR
#define DAC_DEMO_ATTR(_name, _priv)
Definition: iio_dac_demo.c:224
dac_demo_trigger_handler
int32_t 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:153
IIO_VOLTAGE
@ IIO_VOLTAGE
Definition: iio_types.h:71
iio_channel::attributes
struct iio_attribute * attributes
Definition: iio_types.h:192
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.
Definition: iio_dac_demo.c:199
DAC_CHANNEL_ATTR
@ DAC_CHANNEL_ATTR
Definition: dac_demo.h:95
NULL
#define NULL
Definition: wrapper.h:64
TOTAL_DAC_CHANNELS
#define TOTAL_DAC_CHANNELS
Definition: dac_demo.h:57
dac_scan_type
struct scan_type dac_scan_type
Definition: iio_dac_demo.c:242