libiio  0.3
Library for interfacing with IIO devices
/home/rgetz/github/libiio/iio.h
Go to the documentation of this file.
1 /*
2  * libiio - Library for interfacing industrial I/O (IIO) devices
3  *
4  * Copyright (C) 2014 Analog Devices, Inc.
5  * Author: Paul Cercueil <paul.cercueil@analog.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * */
18 
22 #ifndef __IIO_H__
23 #define __IIO_H__
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include <stdlib.h>
32 #include <sys/types.h>
33 #include <stddef.h>
34 
35 #ifdef _MSC_BUILD
36 /* Come on Microsoft, time to get some C99... */
37 typedef long ssize_t;
38 #endif
39 
40 #ifdef __GNUC__
41 #define __cnst __attribute__((const))
42 #define __pure __attribute__((pure))
43 #define __notused __attribute__((unused))
44 #else
45 #define __cnst
46 #define __pure
47 #define __notused
48 #endif
49 
50 #ifdef _WIN32
51 # ifdef LIBIIO_EXPORTS
52 # define __api __declspec(dllexport)
53 # else
54 # define __api __declspec(dllimport)
55 # endif
56 #elif __GNUC__ >= 4
57 # define __api __attribute__((visibility ("default")))
58 #else
59 # define __api
60 #endif
61 
62 struct iio_context;
63 struct iio_device;
64 struct iio_channel;
65 struct iio_buffer;
66 
67 
68 /* ---------------------------------------------------------------------------*/
69 /* ------------------------- Top-level functions -----------------------------*/
78 __api void iio_library_get_version(unsigned int *major,
79  unsigned int *minor, char git_tag[8]);
80 
81 /* ------------------------------------------------------------------*/
83 /* ------------------------- Context functions -------------------------------*/
99 __api struct iio_context * iio_create_default_context(void);
100 
101 
105 __api struct iio_context * iio_create_local_context(void);
106 
107 
115 __api struct iio_context * iio_create_xml_context(const char *xml_file);
116 
117 
127  const char *xml, size_t len);
128 
129 
134 __api struct iio_context * iio_create_network_context(const char *host);
135 
136 
141 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
142 
143 
148 __api void iio_context_destroy(struct iio_context *ctx);
149 
150 
158 __api int iio_context_get_version(const struct iio_context *ctx,
159  unsigned int *major, unsigned int *minor, char git_tag[8]);
160 
161 
165 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
166 
167 
175 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
176 
177 
181 __api __pure unsigned int iio_context_get_devices_count(
182  const struct iio_context *ctx);
183 
184 
190 __api __pure struct iio_device * iio_context_get_device(
191  const struct iio_context *ctx, unsigned int index);
192 
193 
201 __api __pure struct iio_device * iio_context_find_device(
202  const struct iio_context *ctx, const char *name);
203 
204 
211 __api int iio_context_set_timeout(
212  struct iio_context *ctx, unsigned int timeout_ms);
213 
214 /* ------------------------------------------------------------------*/
216 /* ------------------------- Device functions --------------------------------*/
226 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
227 
228 
234 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
235 
236 
240 __api __pure unsigned int iio_device_get_channels_count(
241  const struct iio_device *dev);
242 
243 
247 __api __pure unsigned int iio_device_get_attrs_count(
248  const struct iio_device *dev);
249 
250 
256 __api __pure struct iio_channel * iio_device_get_channel(
257  const struct iio_device *dev, unsigned int index);
258 
259 
265 __api __pure const char * iio_device_get_attr(
266  const struct iio_device *dev, unsigned int index);
267 
268 
277 __api __pure struct iio_channel * iio_device_find_channel(
278  const struct iio_device *dev, const char *name, bool output);
279 
280 
292 __api __pure const char * iio_device_find_attr(
293  const struct iio_device *dev, const char *name);
294 
295 
317  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
318  const char *attr, char *dst, size_t len);
319 
320 
331 __api int iio_device_attr_read_all(struct iio_device *dev,
332  int (*cb)(struct iio_device *dev, const char *attr,
333  const char *value, size_t len, void *d),
334  void *data);
335 
336 
344 __api int iio_device_attr_read_bool(const struct iio_device *dev,
345  const char *attr, bool *val);
346 
347 
355 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
356  const char *attr, long long *val);
357 
358 
366 __api int iio_device_attr_read_double(const struct iio_device *dev,
367  const char *attr, double *val);
368 
369 
388 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
389  const char *attr, const char *src);
390 
391 
400 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
401  const char *attr, const void *src, size_t len);
402 
403 
414 __api int iio_device_attr_write_all(struct iio_device *dev,
415  ssize_t (*cb)(struct iio_device *dev,
416  const char *attr, void *buf, size_t len, void *d),
417  void *data);
418 
419 
427 __api int iio_device_attr_write_bool(const struct iio_device *dev,
428  const char *attr, bool val);
429 
430 
438 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
439  const char *attr, long long val);
440 
441 
449 __api int iio_device_attr_write_double(const struct iio_device *dev,
450  const char *attr, double val);
451 
452 
456 __api void iio_device_set_data(struct iio_device *dev, void *data);
457 
458 
462 __api void * iio_device_get_data(const struct iio_device *dev);
463 
464 
472 __api int iio_device_get_trigger(const struct iio_device *dev,
473  const struct iio_device **trigger);
474 
475 
482 __api int iio_device_set_trigger(const struct iio_device *dev,
483  const struct iio_device *trigger);
484 
485 
489 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
490 
491 /* ------------------------------------------------------------------*/
493 /* ------------------------- Channel functions -------------------------------*/
503 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
504 
505 
511 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
512 
513 
517 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
518 
519 
527 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
528 
529 
533 __api __pure unsigned int iio_channel_get_attrs_count(
534  const struct iio_channel *chn);
535 
536 
542 __api __pure const char * iio_channel_get_attr(
543  const struct iio_channel *chn, unsigned int index);
544 
545 
557 __api __pure const char * iio_channel_find_attr(
558  const struct iio_channel *chn, const char *name);
559 
560 
567 __api __pure const char * iio_channel_attr_get_filename(
568  const struct iio_channel *chn, const char *attr);
569 
570 
592 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
593  const char *attr, char *dst, size_t len);
594 
595 
606 __api int iio_channel_attr_read_all(struct iio_channel *chn,
607  int (*cb)(struct iio_channel *chn,
608  const char *attr, const char *val, size_t len, void *d),
609  void *data);
610 
611 
619 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
620  const char *attr, bool *val);
621 
622 
630 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
631  const char *attr, long long *val);
632 
633 
641 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
642  const char *attr, double *val);
643 
644 
663 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
664  const char *attr, const char *src);
665 
666 
675 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
676  const char *attr, const void *src, size_t len);
677 
678 
689 __api int iio_channel_attr_write_all(struct iio_channel *chn,
690  ssize_t (*cb)(struct iio_channel *chn,
691  const char *attr, void *buf, size_t len, void *d),
692  void *data);
693 
694 
702 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
703  const char *attr, bool val);
704 
705 
713 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
714  const char *attr, long long val);
715 
716 
724 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
725  const char *attr, double val);
726 
727 
734 __api void iio_channel_enable(struct iio_channel *chn);
735 
736 
739 __api void iio_channel_disable(struct iio_channel *chn);
740 
741 
745 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
746 
747 
755 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
756  struct iio_buffer *buffer, void *dst, size_t len);
757 
758 
766 __api size_t iio_channel_read(const struct iio_channel *chn,
767  struct iio_buffer *buffer, void *dst, size_t len);
768 
769 
777 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
778  struct iio_buffer *buffer, const void *src, size_t len);
779 
780 
788 __api size_t iio_channel_write(const struct iio_channel *chn,
789  struct iio_buffer *buffer, const void *src, size_t len);
790 
791 
795 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
796 
797 
801 __api void * iio_channel_get_data(const struct iio_channel *chn);
802 
803 /* ------------------------------------------------------------------*/
805 /* ------------------------- Buffer functions --------------------------------*/
821 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
822  size_t samples_count, bool cyclic);
823 
824 
829 __api void iio_buffer_destroy(struct iio_buffer *buf);
830 
831 
838 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
839 
840 
847 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
848 
849 
853 __api __pure void * iio_buffer_start(const struct iio_buffer *buf);
854 
855 
871 __api void * iio_buffer_first(const struct iio_buffer *buf,
872  const struct iio_channel *chn);
873 
874 
879 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
880 
881 
886 __api void * iio_buffer_end(const struct iio_buffer *buf);
887 
888 
899 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
900  ssize_t (*callback)(const struct iio_channel *chn,
901  void *src, size_t bytes, void *d), void *data);
902 
903 
907 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
908 
909 
913 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
914 
915 /* ------------------------------------------------------------------*/
917 /* ------------------------- Low-level functions -----------------------------*/
929  unsigned int length;
930 
932  unsigned int bits;
933 
935  unsigned int shift;
936 
938  bool is_signed;
939 
942 
944  bool is_be;
945 
948 
950  double scale;
951 };
952 
953 
961 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
962 
963 
968 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
969 
970 
974 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
975  const struct iio_channel *chn);
976 
977 
983 __api void iio_channel_convert(const struct iio_channel *chn,
984  void *dst, const void *src);
985 
986 
992 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
993  void *dst, const void *src);
994 
995 
999 __api __pure unsigned int iio_device_get_debug_attrs_count(
1000  const struct iio_device *dev);
1001 
1002 
1008 __api __pure const char * iio_device_get_debug_attr(
1009  const struct iio_device *dev, unsigned int index);
1010 
1011 
1024 __api __pure const char * iio_device_find_debug_attr(
1025  const struct iio_device *dev, const char *name);
1026 
1027 
1050 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1051  const char *attr, char *dst, size_t len);
1052 
1053 
1063 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1064  int (*cb)(struct iio_device *dev, const char *attr,
1065  const char *value, size_t len, void *d),
1066  void *data);
1067 
1068 
1088 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1089  const char *attr, const char *src);
1090 
1091 
1100 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1101  const char *attr, const void *src, size_t len);
1102 
1103 
1113 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1114  ssize_t (*cb)(struct iio_device *dev,
1115  const char *attr, void *buf, size_t len, void *d),
1116  void *data);
1117 
1118 
1126 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1127  const char *attr, bool *val);
1128 
1129 
1137 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1138  const char *attr, long long *val);
1139 
1140 
1148 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1149  const char *attr, double *val);
1150 
1151 
1159 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1160  const char *attr, bool val);
1161 
1162 
1170 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1171  const char *attr, long long val);
1172 
1173 
1181 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1182  const char *attr, double val);
1183 
1184 
1197 __api int iio_device_identify_filename(const struct iio_device *dev,
1198  const char *filename, struct iio_channel **chn,
1199  const char **attr);
1200 
1201 
1208 __api int iio_device_reg_write(struct iio_device *dev,
1209  uint32_t address, uint32_t value);
1210 
1211 
1218 __api int iio_device_reg_read(struct iio_device *dev,
1219  uint32_t address, uint32_t *value);
1220 
1221 
1224 #ifdef __cplusplus
1225 }
1226 #endif
1227 
1228 #endif /* __IIO_H__ */
__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.
Definition: device.c:330
__api size_t iio_channel_write_raw(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Definition: channel.c:474
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:232
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:251
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:262
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:259
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:215
__api __pure unsigned int iio_context_get_devices_count(const struct iio_context *ctx)
Enumerate the devices found in the given context.
Definition: context.c:132
__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.
Definition: device.c:506
__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.
Definition: device.c:846
__api __pure const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:187
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:207
__api __pure 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:137
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:443
__api 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:250
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:247
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:944
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:117
__api __pure void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:198
__api 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:686
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:242
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:932
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:169
__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.
Definition: channel.c:416
__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.
Definition: device.c:248
__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.
Definition: device.c:562
__api 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:378
__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.
Definition: device.c:622
__api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn)
Return True if the given channel is a scan element.
Definition: channel.c:184
__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.
Definition: device.c:227
__api __pure unsigned int iio_device_get_debug_attrs_count(const struct iio_device *dev)
Enumerate the debug attributes of the given device.
Definition: device.c:557
Represents an input or output channel of a device.
__api __cnst const struct iio_data_format * iio_channel_get_data_format(const struct iio_channel *chn)
Get a pointer to a channel&#39;s data format structure.
Definition: channel.c:256
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:929
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:237
__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.
Definition: device.c:236
Represents a device in the IIO context.
__api __pure const char * iio_channel_attr_get_filename(const struct iio_channel *chn, const char *attr)
Retrieve the filename of an attribute.
Definition: channel.c:575
__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.
Definition: device.c:350
__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.
Definition: device.c:634
__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.
Definition: channel.c:225
__api __pure unsigned int iio_channel_get_attrs_count(const struct iio_channel *chn)
Enumerate the channel-specific attributes of the given channel.
Definition: channel.c:189
__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.
Definition: device.c:541
__api void iio_buffer_destroy(struct iio_buffer *buf)
Destroy the given buffer.
Definition: buffer.c:88
__api __pure const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition: channel.c:174
__api ssize_t iio_buffer_refill(struct iio_buffer *buf)
Fetch more samples from the hardware.
Definition: buffer.c:97
__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.
Definition: channel.c:203
__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.
Definition: device.c:551
__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.
Definition: device.c:455
__api __pure 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:146
__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.
Definition: channel.c:235
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:938
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:232
bool with_scale
Contains True if the sample should be scaled when converted.
Definition: iio.h:947
__api void * iio_device_get_data(const struct iio_device *dev)
Retrieve a previously associated pointer of an iio_device structure.
Definition: device.c:361
__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.
Definition: channel.c:194
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:950
__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.
Definition: device.c:483
__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.
Definition: device.c:471
__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.
__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.
Definition: context.c:189
__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.
Definition: buffer.c:203
__api __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:182
__api ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:450
__api 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:390
__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.
Definition: device.c:610
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:246
__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.
Definition: channel.c:554
__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.
Definition: channel.c:521
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:241
__api __pure bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition: device.c:366
bool is_fully_defined
Contains True if the sample is fully defined, sign extended, etc.
Definition: iio.h:941
__api void iio_device_set_data(struct iio_device *dev, void *data)
Associate a pointer to an iio_device structure.
Definition: device.c:356
An input or output buffer, used to read or write samples.
__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.
Definition: channel.c:564
unsigned int shift
Right-shift to apply when converting sample.
Definition: iio.h:935
__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.
Definition: channel.c:533
__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.
Definition: device.c:494
__api __pure unsigned int iio_device_get_attrs_count(const struct iio_device *dev)
Enumerate the device-specific attributes of the given device.
Definition: device.c:222
__api 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:23
__api void iio_channel_enable(struct iio_channel *chn)
Enable the given channel.
Definition: channel.c:268
__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.
Definition: device.c:518
__api __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:112
__api void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:274
__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.
__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.
__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.
Definition: channel.c:627
__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.
Definition: device.c:571
__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.
Definition: device.c:531
__api __pure 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:197
__api 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:389
__api __pure const char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition: context.c:107
__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.
Definition: channel.c:544
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:458
__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:100
__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.
Definition: device.c:587
__api __pure 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:206
__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.
Definition: device.c:647
__api __pure bool iio_channel_is_output(const struct iio_channel *chn)
Return True if the given channel is an output channel.
Definition: channel.c:179
__api size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Definition: channel.c:489
__api __pure unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:192
__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.
Definition: channel.c:505
Contains the format of a data sample.
Definition: iio.h:927
__api ssize_t iio_buffer_push(struct iio_buffer *buf)
Send the samples to the hardware.
Definition: buffer.c:120
__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.
Definition: channel.c:215
__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.
Definition: device.c:599
Contains the representation of an IIO context.
__api int iio_context_set_timeout(struct iio_context *ctx, unsigned int timeout_ms)
Set a timeout for I/O operations.
Definition: context.c:199
__api 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:698
__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.
Definition: channel.c:586
__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.
Definition: device.c:340
__api struct iio_context * iio_create_network_context(const char *host)
Create a context from the network.
Definition: context.c:241
__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.
Definition: device.c:854