libiio
0.21
Library for interfacing with IIO devices
|
18 #ifndef __IIO_BACKEND_H__
19 #define __IIO_BACKEND_H__
26 enum iio_backend_api_ver {
27 IIO_BACKEND_API_V1 = 1,
31 IIO_ATTR_TYPE_DEVICE = 0,
36 struct iio_backend_ops {
38 ssize_t (*read)(
const struct iio_device *dev,
void *dst,
size_t len,
39 uint32_t *mask,
size_t words);
41 const void *src,
size_t len);
43 size_t samples_count,
bool cyclic);
46 int (*set_blocking_mode)(
const struct iio_device *dev,
bool blocking);
50 int (*set_kernel_buffers_count)(
const struct iio_device *dev,
51 unsigned int nb_blocks);
52 ssize_t (*get_buffer)(
const struct iio_device *dev,
53 void **addr_ptr,
size_t bytes_used,
54 uint32_t *mask,
size_t words);
56 ssize_t (*read_device_attr)(
const struct iio_device *dev,
57 const char *attr,
char *dst,
size_t len,
enum iio_attr_type);
58 ssize_t (*write_device_attr)(
const struct iio_device *dev,
59 const char *attr,
const char *src,
60 size_t len,
enum iio_attr_type);
61 ssize_t (*read_channel_attr)(
const struct iio_channel *chn,
62 const char *attr,
char *dst,
size_t len);
63 ssize_t (*write_channel_attr)(
const struct iio_channel *chn,
64 const char *attr,
const char *src,
size_t len);
66 int (*get_trigger)(
const struct iio_device *dev,
68 int (*set_trigger)(
const struct iio_device *dev,
73 char * (*get_description)(
const struct iio_context *ctx);
75 int (*get_version)(
const struct iio_context *ctx,
unsigned int *major,
76 unsigned int *minor,
char git_tag[8]);
78 int (*set_timeout)(
struct iio_context *ctx,
unsigned int timeout);
90 unsigned int api_version;
92 const char *uri_prefix;
93 const struct iio_backend_ops *ops;
94 unsigned int sizeof_context_pdata;
97 __api
struct iio_context * iio_context_create_from_backend(
98 const struct iio_backend *backend,
99 const char *description);
__api __check_ret ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf, ssize_t(*callback)(const struct iio_channel *chn, void *src, size_t bytes, void *d), void *data)
Call the supplied callback for each sample found in a buffer.
void iio_channel_convert_inverse(const struct iio_channel *chn, void *dst, const void *src)
Convert the sample from host format to hardware format.
Definition: channel.c:610
void * iio_buffer_end(const struct iio_buffer *buffer)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:303
ssize_t iio_device_debug_attr_write(const struct iio_device *dev, const char *attr, const char *src)
Set the value of the given debug attribute.
Definition: device.c:790
Represents an input or output channel of a device.
int iio_device_buffer_attr_write_bool(const struct iio_device *dev, const char *attr, bool val)
Set the value of the given buffer-specific attribute.
Definition: device.c:757
ssize_t iio_buffer_push_partial(struct iio_buffer *buffer, size_t samples_count)
Send a given number of samples to the hardware.
Definition: buffer.c:193
ssize_t iio_buffer_push(struct iio_buffer *buffer)
Send the samples to the hardware.
Definition: buffer.c:157
ssize_t iio_device_buffer_attr_read(const struct iio_device *dev, const char *attr, char *dst, size_t len)
Read the content of the given buffer-specific attribute.
Definition: device.c:467
ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn, const char *attr, const void *src, size_t len)
Set the value of the given channel-specific attribute.
Definition: channel.c:410
int iio_device_attr_write_longlong(const struct iio_device *dev, const char *attr, long long val)
Set the value of the given device-specific attribute.
Definition: device.c:656
bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:447
unsigned int iio_context_get_attrs_count(const struct iio_context *ctx)
Get the number of context-specific attributes.
Definition: context.c:467
int iio_device_debug_attr_write_bool(const struct iio_device *dev, const char *attr, bool val)
Set the value of the given debug attribute.
Definition: device.c:874
int iio_device_reg_write(struct iio_device *dev, uint32_t address, uint32_t value)
Set the value of a hardware register.
Definition: device.c:926
ssize_t iio_device_debug_attr_read(const struct iio_device *dev, const char *attr, char *dst, size_t len)
Read the content of the given debug attribute.
Definition: device.c:770
The information related to a discovered context.
void * iio_device_get_data(const struct iio_device *dev)
Retrieve a previously associated pointer of an iio_device structure.
Definition: device.c:498
const char * iio_device_find_buffer_attr(const struct iio_device *dev, const char *name)
Try to find a buffer-specific attribute by its name.
Definition: device.c:345
void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:431
struct iio_channel * iio_device_find_channel(const struct iio_device *dev, const char *name, bool output)
Try to find a channel structure by its name of ID.
Definition: device.c:289
int iio_device_buffer_attr_write_all(struct iio_device *dev, ssize_t(*cb)(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d), void *data)
Set the values of all buffer-specific attributes.
Definition: device.c:1175
const char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition: context.c:235
int iio_channel_attr_read_longlong(const struct iio_channel *chn, const char *attr, long long *val)
Read the content of the given channel-specific attribute.
Definition: channel.c:705
void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:426
const char * iio_device_get_debug_attr(const struct iio_device *dev, unsigned int index)
Get the debug attribute present at the given index.
Definition: device.c:801
int iio_device_attr_read_double(const struct iio_device *dev, const char *attr, double *val)
Read the content of the given device-specific attribute.
Definition: device.c:645
struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:427
const struct iio_context * iio_device_get_context(const struct iio_device *dev)
Retrieve a pointer to the iio_context structure.
Definition: device.c:1191
size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buf, void *dst, size_t len)
Demultiplex and convert the samples of a given channel.
Definition: channel.c:658
const char * iio_channel_get_attr(const struct iio_channel *chn, unsigned int index)
Get the channel-specific attribute present at the given index.
Definition: channel.c:379
int iio_channel_attr_write_longlong(const struct iio_channel *chn, const char *attr, long long val)
Set the value of the given channel-specific attribute.
Definition: channel.c:745
void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:308
__api __check_ret int iio_device_buffer_attr_read_all(struct iio_device *dev, int(*cb)(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d), void *data)
Read the content of all buffer-specific attributes.
ssize_t iio_channel_attr_write(const struct iio_channel *chn, const char *attr, const char *src)
Set the value of the given channel-specific attribute.
Definition: channel.c:420
int iio_device_attr_read_bool(const struct iio_device *dev, const char *attr, bool *val)
Read the content of the given device-specific attribute.
Definition: device.c:633
int iio_device_attr_write_double(const struct iio_device *dev, const char *attr, double val)
Set the value of the given device-specific attribute.
Definition: device.c:668
void iio_channel_enable(struct iio_channel *chn)
Enable the given channel.
Definition: channel.c:453
void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:459
struct iio_device * iio_context_get_device(const struct iio_context *ctx, unsigned int index)
Get the device present at the given index.
Definition: context.c:285
int iio_context_set_timeout(struct iio_context *ctx, unsigned int timeout)
Set a timeout for I/O operations.
Definition: context.c:364
struct iio_context * iio_create_network_context(const char *hostname)
Create a context from the network.
Definition: context.c:437
ptrdiff_t iio_buffer_step(const struct iio_buffer *buffer)
Get the step size between two samples of one channel.
Definition: buffer.c:298
const char * iio_channel_find_attr(const struct iio_channel *chn, const char *name)
Try to find a channel-specific attribute by its name.
Definition: channel.c:388
int iio_channel_attr_write_bool(const struct iio_channel *chn, const char *attr, bool val)
Set the value of the given channel-specific attribute.
Definition: channel.c:767
enum iio_chan_type iio_channel_get_type(const struct iio_channel *chn)
Get the type of the given channel.
Definition: channel.c:369
const char * iio_device_find_debug_attr(const struct iio_device *dev, const char *name)
Try to find a debug attribute by its name.
Definition: device.c:357
ssize_t iio_buffer_refill(struct iio_buffer *buffer)
Fetch more samples from the hardware.
Definition: buffer.c:133
struct iio_context * iio_create_xml_context_mem(const char *xml, size_t len)
Create a context from XML data in memory.
Definition: context.c:447
const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:265
__api __check_ret int iio_device_attr_read_all(struct iio_device *dev, int(*cb)(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d), void *data)
Read the content of all device-specific attributes.
int iio_device_identify_filename(const struct iio_device *dev, const char *filename, struct iio_channel **chn, const char **attr)
Identify the channel or debug attribute corresponding to a filename.
Definition: device.c:887
const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:245
const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition: channel.c:349
ssize_t iio_device_attr_write_raw(const struct iio_device *dev, const char *attr, const void *src, size_t len)
Set the value of the given device-specific attribute.
Definition: device.c:451
struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:372
int iio_device_buffer_attr_read_longlong(const struct iio_device *dev, const char *attr, long long *val)
Read the content of the given buffer-specific attribute.
Definition: device.c:693
const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:344
unsigned int iio_context_get_devices_count(const struct iio_context *ctx)
Enumerate the devices found in the given context.
Definition: context.c:280
struct iio_channel * iio_device_get_channel(const struct iio_device *dev, unsigned int index)
Get the channel present at the given index.
Definition: device.c:280
int iio_device_reg_read(struct iio_device *dev, uint32_t address, uint32_t *value)
Get the value of a hardware register.
Definition: device.c:939
An input or output buffer, used to read or write samples.
void iio_device_set_data(struct iio_device *dev, void *data)
Associate a pointer to an iio_device structure.
Definition: device.c:493
int iio_device_debug_attr_write_double(const struct iio_device *dev, const char *attr, double val)
Set the value of the given debug attribute.
Definition: device.c:862
int iio_device_get_trigger(const struct iio_device *dev, const struct iio_device **trigger)
Retrieve the trigger of a given device.
Definition: device.c:526
int iio_buffer_get_poll_fd(struct iio_buffer *buffer)
Get a pollable file descriptor.
Definition: buffer.c:123
bool iio_channel_is_output(const struct iio_channel *chn)
Return True if the given channel is an output channel.
Definition: channel.c:354
void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:253
int iio_channel_attr_write_double(const struct iio_channel *chn, const char *attr, double val)
Set the value of the given channel-specific attribute.
Definition: channel.c:755
int iio_buffer_set_blocking_mode(struct iio_buffer *buffer, bool blocking)
Make iio_buffer_refill() and iio_buffer_push() blocking or not.
Definition: buffer.c:128
int iio_device_buffer_attr_read_bool(const struct iio_device *dev, const char *attr, bool *val)
Read the content of the given buffer-specific attribute.
Definition: device.c:710
__api __check_ret int iio_device_debug_attr_read_all(struct iio_device *dev, int(*cb)(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d), void *data)
Read the content of all debug attributes.
int iio_device_debug_attr_read_longlong(const struct iio_device *dev, const char *attr, long long *val)
Read the content of the given debug attribute.
Definition: device.c:810
void iio_buffer_destroy(struct iio_buffer *buffer)
Destroy the given buffer.
Definition: buffer.c:114
void iio_buffer_cancel(struct iio_buffer *buf)
Cancel all buffer operations.
Definition: buffer.c:323
const char * iio_device_find_attr(const struct iio_device *dev, const char *name)
Try to find a device-specific attribute by its name.
Definition: device.c:319
int iio_device_buffer_attr_read_double(const struct iio_device *dev, const char *attr, double *val)
Read the content of the given buffer-specific attribute.
Definition: device.c:722
ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:611
ssize_t iio_device_attr_read(const struct iio_device *dev, const char *attr, char *dst, size_t len)
Read the content of the given device-specific attribute.
Definition: device.c:441
unsigned int iio_channel_get_attrs_count(const struct iio_channel *chn)
Enumerate the channel-specific attributes of the given channel.
Definition: channel.c:374
bool iio_channel_is_scan_element(const struct iio_channel *chn)
Return True if the given channel is a scan element.
Definition: channel.c:359
size_t iio_channel_write_raw(const struct iio_channel *chn, struct iio_buffer *buf, const void *src, size_t len)
Multiplex the samples of a given channel.
Definition: channel.c:674
ssize_t iio_channel_attr_read(const struct iio_channel *chn, const char *attr, char *dst, size_t len)
Read the content of the given channel-specific attribute.
Definition: channel.c:400
int iio_device_debug_attr_read_double(const struct iio_device *dev, const char *attr, double *val)
Read the content of the given debug attribute.
Definition: device.c:839
long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:436
int iio_context_get_attr(const struct iio_context *ctx, unsigned int index, const char **name, const char **value)
Retrieve the name and value of a context-specific attribute.
Definition: context.c:472
int iio_device_set_trigger(const struct iio_device *dev, const struct iio_device *trigger)
Associate a trigger to a given device.
Definition: device.c:537
unsigned int iio_device_get_buffer_attrs_count(const struct iio_device *dev)
Enumerate the buffer-specific attributes of the given device.
Definition: device.c:331
ssize_t iio_device_buffer_attr_write_raw(const struct iio_device *dev, const char *attr, const void *src, size_t len)
Set the value of the given buffer-specific attribute.
Definition: device.c:477
int iio_channel_attr_read_all(struct iio_channel *chn, int(*cb)(struct iio_channel *chn, const char *attr, const char *val, size_t len, void *d), void *data)
Read the content of all channel-specific attributes.
Definition: channel.c:789
int iio_channel_attr_write_all(struct iio_channel *chn, ssize_t(*cb)(struct iio_channel *chn, const char *attr, void *buf, size_t len, void *d), void *data)
Set the values of all channel-specific attributes.
Definition: channel.c:848
Contains the representation of an IIO context.
void * iio_buffer_first(const struct iio_buffer *buffer, const struct iio_channel *chn)
Find the first sample of a channel in a buffer.
Definition: buffer.c:260
void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:313
Represents a device in the IIO context.
const struct iio_device * iio_channel_get_device(const struct iio_channel *chn)
Retrieve a pointer to the iio_device structure.
Definition: channel.c:891
unsigned int iio_get_backends_count(void)
Get the number of available backends.
Definition: backend.c:23
iio_modifier
IIO channel modifier.
Definition: iio.h:148
int iio_device_buffer_attr_write_double(const struct iio_device *dev, const char *attr, double val)
Set the value of the given buffer-specific attribute.
Definition: device.c:745
struct iio_context * iio_create_context_from_uri(const char *uri)
Create a context from a URI description.
Definition: context.c:382
void * iio_buffer_start(const struct iio_buffer *buffer)
Get the start address of the buffer.
Definition: buffer.c:255
const char * iio_channel_attr_get_filename(const struct iio_channel *chn, const char *attr)
Retrieve the filename of an attribute.
Definition: channel.c:778
const char * iio_device_get_attr(const struct iio_device *dev, unsigned int index)
Get the device-specific attribute present at the given index.
Definition: device.c:310
int iio_device_debug_attr_write_longlong(const struct iio_device *dev, const char *attr, long long val)
Set the value of the given debug attribute.
Definition: device.c:850
int iio_device_attr_read_longlong(const struct iio_device *dev, const char *attr, long long *val)
Read the content of the given device-specific attribute.
Definition: device.c:616
int iio_channel_attr_read_bool(const struct iio_channel *chn, const char *attr, bool *val)
Read the content of the given channel-specific attribute.
Definition: channel.c:722
bool iio_has_backend(const char *backend)
Check if the specified backend is available.
Definition: backend.c:75
iio_chan_type
IIO channel type.
Definition: iio.h:102
ssize_t iio_device_buffer_attr_write(const struct iio_device *dev, const char *attr, const char *src)
Set the value of the given buffer-specific attribute.
Definition: device.c:487
const struct iio_data_format * iio_channel_get_data_format(const struct iio_channel *chn)
Get a pointer to a channel's data format structure.
Definition: channel.c:441
unsigned int iio_device_get_debug_attrs_count(const struct iio_device *dev)
Enumerate the debug attributes of the given device.
Definition: device.c:796
struct iio_device * iio_context_find_device(const struct iio_context *ctx, const char *name)
Try to find a device structure by its name of ID.
Definition: context.c:294
ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev, const char *attr, const void *src, size_t len)
Set the value of the given debug attribute.
Definition: device.c:780
const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:270
int iio_device_debug_attr_read_bool(const struct iio_device *dev, const char *attr, bool *val)
Read the content of the given debug attribute.
Definition: device.c:827
int iio_device_attr_write_bool(const struct iio_device *dev, const char *attr, bool val)
Set the value of the given device-specific attribute.
Definition: device.c:680
const char * iio_context_get_attr_value(const struct iio_context *ctx, const char *name)
Retrieve the value of a context-specific attribute.
Definition: context.c:485
int iio_device_debug_attr_write_all(struct iio_device *dev, ssize_t(*cb)(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d), void *data)
Set the values of all debug attributes.
Definition: device.c:1167
int iio_context_get_version(const struct iio_context *ctx, unsigned int *major, unsigned int *minor, char git_tag[8])
Get the version of the backend in use.
Definition: context.c:354
struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev, size_t samples_count, bool cyclic)
Create an input or output buffer associated to the given device.
Definition: buffer.c:36
int iio_device_set_kernel_buffers_count(const struct iio_device *dev, unsigned int nb_buffers)
Configure the number of kernel buffers for a device.
Definition: device.c:515
unsigned int iio_device_get_attrs_count(const struct iio_device *dev)
Enumerate the device-specific attributes of the given device.
Definition: device.c:305
int iio_device_buffer_attr_write_longlong(const struct iio_device *dev, const char *attr, long long val)
Set the value of the given buffer-specific attribute.
Definition: device.c:733
enum iio_modifier iio_channel_get_modifier(const struct iio_channel *chn)
Get the modifier type of the given channel.
Definition: channel.c:364
struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:457
size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buf, void *dst, size_t len)
Demultiplex the samples of a given channel.
Definition: channel.c:643
const struct iio_device * iio_buffer_get_device(const struct iio_buffer *buf)
Retrieve a pointer to the iio_device structure.
Definition: buffer.c:318
__api void iio_library_get_version(unsigned int *major, unsigned int *minor, char git_tag[8])
Get the version of the libiio library.
Definition: utilities.c:195
int iio_device_attr_write_all(struct iio_device *dev, ssize_t(*cb)(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d), void *data)
Set the values of all device-specific attributes.
Definition: device.c:1183
const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:240
bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition: device.c:503
void iio_channel_convert(const struct iio_channel *chn, void *dst, const void *src)
Convert the sample from hardware format to host format.
Definition: channel.c:574
ssize_t iio_device_attr_write(const struct iio_device *dev, const char *attr, const char *src)
Set the value of the given device-specific attribute.
Definition: device.c:461
int iio_channel_attr_read_double(const struct iio_channel *chn, const char *attr, double *val)
Read the content of the given channel-specific attribute.
Definition: channel.c:734
struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:413
unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:275
size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buf, const void *src, size_t len)
Convert and multiplex the samples of a given channel.
Definition: channel.c:689
const char * iio_device_get_buffer_attr(const struct iio_device *dev, unsigned int index)
Get the buffer-specific attribute present at the given index.
Definition: device.c:336
const char * iio_get_backend(unsigned int index)
Retrieve the name of a given backend.
Definition: backend.c:46