libiio  0.5
Library for interfacing with IIO devices
Data Structures | Macros | Functions
/home/rgetz/github/libiio/iio.h File Reference

Public interface. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  iio_data_format
 Contains the format of a data sample. More...
 

Functions

__api void iio_library_get_version (unsigned int *major, unsigned int *minor, char git_tag[8])
 Get the version of the libiio library. More...
 
__api struct iio_contextiio_create_default_context (void)
 Create a context from local or remote IIO devices. More...
 
__api struct iio_contextiio_create_local_context (void)
 Create a context from local IIO devices (Linux only) More...
 
__api struct iio_contextiio_create_xml_context (const char *xml_file)
 Create a context from a XML file. More...
 
__api struct iio_contextiio_create_xml_context_mem (const char *xml, size_t len)
 Create a context from XML data in memory. More...
 
__api struct iio_contextiio_create_network_context (const char *host)
 Create a context from the network. More...
 
__api struct iio_contextiio_context_clone (const struct iio_context *ctx)
 Duplicate a pre-existing IIO context. More...
 
__api void iio_context_destroy (struct iio_context *ctx)
 Destroy the given context. More...
 
__api 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. More...
 
__api __pure const char * iio_context_get_xml (const struct iio_context *ctx)
 Obtain a XML representation of the given context. More...
 
__api __pure const char * iio_context_get_name (const struct iio_context *ctx)
 Get the name of the given context. More...
 
__api __pure const char * iio_context_get_description (const struct iio_context *ctx)
 Get a description of the given context. More...
 
__api __pure unsigned int iio_context_get_devices_count (const struct iio_context *ctx)
 Enumerate the devices found in the given context. More...
 
__api __pure struct iio_deviceiio_context_get_device (const struct iio_context *ctx, unsigned int index)
 Get the device present at the given index. More...
 
__api __pure struct iio_deviceiio_context_find_device (const struct iio_context *ctx, const char *name)
 Try to find a device structure by its name of ID. More...
 
__api int iio_context_set_timeout (struct iio_context *ctx, unsigned int timeout_ms)
 Set a timeout for I/O operations. More...
 
__api __pure const char * iio_device_get_id (const struct iio_device *dev)
 Retrieve the device ID (e.g. iio:device0) More...
 
__api __pure const char * iio_device_get_name (const struct iio_device *dev)
 Retrieve the device name (e.g. xadc) More...
 
__api __pure unsigned int iio_device_get_channels_count (const struct iio_device *dev)
 Enumerate the channels of the given device. More...
 
__api __pure unsigned int iio_device_get_attrs_count (const struct iio_device *dev)
 Enumerate the device-specific attributes of the given device. More...
 
__api __pure struct iio_channeliio_device_get_channel (const struct iio_device *dev, unsigned int index)
 Get the channel present at the given index. More...
 
__api __pure const char * iio_device_get_attr (const struct iio_device *dev, unsigned int index)
 Get the device-specific attribute present at the given index. More...
 
__api __pure struct iio_channeliio_device_find_channel (const struct iio_device *dev, const char *name, bool output)
 Try to find a channel structure by its name of ID. More...
 
__api __pure const char * iio_device_find_attr (const struct iio_device *dev, const char *name)
 Try to find a device-specific attribute by its name. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api void iio_device_set_data (struct iio_device *dev, void *data)
 Associate a pointer to an iio_device structure. More...
 
__api void * iio_device_get_data (const struct iio_device *dev)
 Retrieve a previously associated pointer of an iio_device structure. More...
 
__api int iio_device_get_trigger (const struct iio_device *dev, const struct iio_device **trigger)
 Retrieve the trigger of a given device. More...
 
__api int iio_device_set_trigger (const struct iio_device *dev, const struct iio_device *trigger)
 Associate a trigger to a given device. More...
 
__api __pure bool iio_device_is_trigger (const struct iio_device *dev)
 Return True if the given device is a trigger. More...
 
__api __pure const char * iio_channel_get_id (const struct iio_channel *chn)
 Retrieve the channel ID (e.g. voltage0) More...
 
__api __pure const char * iio_channel_get_name (const struct iio_channel *chn)
 Retrieve the channel name (e.g. vccint) More...
 
__api __pure bool iio_channel_is_output (const struct iio_channel *chn)
 Return True if the given channel is an output channel. More...
 
__api __pure bool iio_channel_is_scan_element (const struct iio_channel *chn)
 Return True if the given channel is a scan element. More...
 
__api __pure unsigned int iio_channel_get_attrs_count (const struct iio_channel *chn)
 Enumerate the channel-specific attributes of the given channel. More...
 
__api __pure const char * iio_channel_get_attr (const struct iio_channel *chn, unsigned int index)
 Get the channel-specific attribute present at the given index. More...
 
__api __pure const char * iio_channel_find_attr (const struct iio_channel *chn, const char *name)
 Try to find a channel-specific attribute by its name. More...
 
__api __pure const char * iio_channel_attr_get_filename (const struct iio_channel *chn, const char *attr)
 Retrieve the filename of an attribute. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api void iio_channel_enable (struct iio_channel *chn)
 Enable the given channel. More...
 
__api void iio_channel_disable (struct iio_channel *chn)
 Disable the given channel. More...
 
__api bool iio_channel_is_enabled (const struct iio_channel *chn)
 Returns True if the channel is enabled. More...
 
__api size_t iio_channel_read_raw (const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
 
__api size_t iio_channel_read (const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
 
__api size_t iio_channel_write_raw (const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
 
__api size_t iio_channel_write (const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
 
__api void iio_channel_set_data (struct iio_channel *chn, void *data)
 Associate a pointer to an iio_channel structure. More...
 
__api void * iio_channel_get_data (const struct iio_channel *chn)
 Retrieve a previously associated pointer of an iio_channel structure. More...
 
__api struct iio_bufferiio_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. More...
 
__api void iio_buffer_destroy (struct iio_buffer *buf)
 Destroy the given buffer. More...
 
__api ssize_t iio_buffer_refill (struct iio_buffer *buf)
 Fetch more samples from the hardware. More...
 
__api ssize_t iio_buffer_push (struct iio_buffer *buf)
 Send the samples to the hardware. More...
 
__api void * iio_buffer_start (const struct iio_buffer *buf)
 Get the start address of the buffer. More...
 
__api void * iio_buffer_first (const struct iio_buffer *buf, const struct iio_channel *chn)
 Find the first sample of a channel in a buffer. More...
 
__api ptrdiff_t iio_buffer_step (const struct iio_buffer *buf)
 Get the step size between two samples of one channel. More...
 
__api void * iio_buffer_end (const struct iio_buffer *buf)
 Get the address that follows the last sample in a buffer. More...
 
__api 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. More...
 
__api void iio_buffer_set_data (struct iio_buffer *buf, void *data)
 Associate a pointer to an iio_buffer structure. More...
 
__api void * iio_buffer_get_data (const struct iio_buffer *buf)
 Retrieve a previously associated pointer of an iio_buffer structure. More...
 
__api ssize_t iio_device_get_sample_size (const struct iio_device *dev)
 Get the current sample size. More...
 
__api __pure long iio_channel_get_index (const struct iio_channel *chn)
 Get the index of the given channel. More...
 
__api __cnst const struct iio_data_formatiio_channel_get_data_format (const struct iio_channel *chn)
 Get a pointer to a channel's data format structure. More...
 
__api void iio_channel_convert (const struct iio_channel *chn, void *dst, const void *src)
 Convert the sample from hardware format to host format. More...
 
__api void iio_channel_convert_inverse (const struct iio_channel *chn, void *dst, const void *src)
 Convert the sample from host format to hardware format. More...
 
__api __pure unsigned int iio_device_get_debug_attrs_count (const struct iio_device *dev)
 Enumerate the debug attributes of the given device. More...
 
__api __pure const char * iio_device_get_debug_attr (const struct iio_device *dev, unsigned int index)
 Get the debug attribute present at the given index. More...
 
__api __pure const char * iio_device_find_debug_attr (const struct iio_device *dev, const char *name)
 Try to find a debug attribute by its name. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api 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. More...
 
__api int iio_device_reg_write (struct iio_device *dev, uint32_t address, uint32_t value)
 Set the value of a hardware register. More...
 
__api int iio_device_reg_read (struct iio_device *dev, uint32_t address, uint32_t *value)
 Get the value of a hardware register. More...
 

Detailed Description

Public interface.