libiio  0.6
Library for interfacing with IIO devices
/build/libiio-NRkSvq/libiio-0.6.187/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 #define _SSIZE_T_DEFINED
39 #endif
40 
41 #ifdef __GNUC__
42 #ifndef __cnst
43 #define __cnst __attribute__((const))
44 #endif
45 #ifndef __pure
46 #define __pure __attribute__((pure))
47 #endif
48 #define __notused __attribute__((unused))
49 #else
50 #define __cnst
51 #define __pure
52 #define __notused
53 #endif
54 
55 #ifdef _WIN32
56 # ifdef LIBIIO_EXPORTS
57 # define __api __declspec(dllexport)
58 # else
59 # define __api __declspec(dllimport)
60 # endif
61 #elif __GNUC__ >= 4
62 # define __api __attribute__((visibility ("default")))
63 #else
64 # define __api
65 #endif
66 
67 struct iio_context;
68 struct iio_device;
69 struct iio_channel;
70 struct iio_buffer;
71 
72 
73 /* ---------------------------------------------------------------------------*/
74 /* ------------------------- Top-level functions -----------------------------*/
83 __api void iio_library_get_version(unsigned int *major,
84  unsigned int *minor, char git_tag[8]);
85 
86 
92 __api void iio_strerror(int err, char *dst, size_t len);
93 
94 /* ------------------------------------------------------------------*/
96 /* ------------------------- Context functions -------------------------------*/
112 __api struct iio_context * iio_create_default_context(void);
113 
114 
118 __api struct iio_context * iio_create_local_context(void);
119 
120 
128 __api struct iio_context * iio_create_xml_context(const char *xml_file);
129 
130 
140  const char *xml, size_t len);
141 
142 
147 __api struct iio_context * iio_create_network_context(const char *host);
148 
149 
154 __api struct iio_context * iio_create_context_from_uri(const char *uri);
155 
156 
161 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
162 
163 
168 __api void iio_context_destroy(struct iio_context *ctx);
169 
170 
178 __api int iio_context_get_version(const struct iio_context *ctx,
179  unsigned int *major, unsigned int *minor, char git_tag[8]);
180 
181 
185 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
186 
187 
195 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
196 
197 
204 __api __pure const char * iio_context_get_description(
205  const struct iio_context *ctx);
206 
207 
211 __api __pure unsigned int iio_context_get_devices_count(
212  const struct iio_context *ctx);
213 
214 
220 __api __pure struct iio_device * iio_context_get_device(
221  const struct iio_context *ctx, unsigned int index);
222 
223 
231 __api __pure struct iio_device * iio_context_find_device(
232  const struct iio_context *ctx, const char *name);
233 
234 
242 __api int iio_context_set_timeout(
243  struct iio_context *ctx, unsigned int timeout_ms);
244 
245 /* ------------------------------------------------------------------*/
247 /* ------------------------- Device functions --------------------------------*/
257 __api __pure const struct iio_context * iio_device_get_context(
258  const struct iio_device *dev);
259 
260 
264 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
265 
266 
272 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
273 
274 
278 __api __pure unsigned int iio_device_get_channels_count(
279  const struct iio_device *dev);
280 
281 
285 __api __pure unsigned int iio_device_get_attrs_count(
286  const struct iio_device *dev);
287 
288 
294 __api __pure struct iio_channel * iio_device_get_channel(
295  const struct iio_device *dev, unsigned int index);
296 
297 
303 __api __pure const char * iio_device_get_attr(
304  const struct iio_device *dev, unsigned int index);
305 
306 
315 __api __pure struct iio_channel * iio_device_find_channel(
316  const struct iio_device *dev, const char *name, bool output);
317 
318 
330 __api __pure const char * iio_device_find_attr(
331  const struct iio_device *dev, const char *name);
332 
333 
355  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
356  const char *attr, char *dst, size_t len);
357 
358 
369 __api int iio_device_attr_read_all(struct iio_device *dev,
370  int (*cb)(struct iio_device *dev, const char *attr,
371  const char *value, size_t len, void *d),
372  void *data);
373 
374 
382 __api int iio_device_attr_read_bool(const struct iio_device *dev,
383  const char *attr, bool *val);
384 
385 
393 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
394  const char *attr, long long *val);
395 
396 
404 __api int iio_device_attr_read_double(const struct iio_device *dev,
405  const char *attr, double *val);
406 
407 
426 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
427  const char *attr, const char *src);
428 
429 
438 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
439  const char *attr, const void *src, size_t len);
440 
441 
452 __api int iio_device_attr_write_all(struct iio_device *dev,
453  ssize_t (*cb)(struct iio_device *dev,
454  const char *attr, void *buf, size_t len, void *d),
455  void *data);
456 
457 
465 __api int iio_device_attr_write_bool(const struct iio_device *dev,
466  const char *attr, bool val);
467 
468 
476 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
477  const char *attr, long long val);
478 
479 
487 __api int iio_device_attr_write_double(const struct iio_device *dev,
488  const char *attr, double val);
489 
490 
494 __api void iio_device_set_data(struct iio_device *dev, void *data);
495 
496 
500 __api void * iio_device_get_data(const struct iio_device *dev);
501 
502 
510 __api int iio_device_get_trigger(const struct iio_device *dev,
511  const struct iio_device **trigger);
512 
513 
520 __api int iio_device_set_trigger(const struct iio_device *dev,
521  const struct iio_device *trigger);
522 
523 
527 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
528 
537 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
538  unsigned int nb_buffers);
539 /* ------------------------------------------------------------------*/
541 /* ------------------------- Channel functions -------------------------------*/
551 __api __pure const struct iio_device * iio_channel_get_device(
552  const struct iio_channel *chn);
553 
554 
558 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
559 
560 
566 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
567 
568 
572 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
573 
574 
582 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
583 
584 
588 __api __pure unsigned int iio_channel_get_attrs_count(
589  const struct iio_channel *chn);
590 
591 
597 __api __pure const char * iio_channel_get_attr(
598  const struct iio_channel *chn, unsigned int index);
599 
600 
612 __api __pure const char * iio_channel_find_attr(
613  const struct iio_channel *chn, const char *name);
614 
615 
622 __api __pure const char * iio_channel_attr_get_filename(
623  const struct iio_channel *chn, const char *attr);
624 
625 
647 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
648  const char *attr, char *dst, size_t len);
649 
650 
661 __api int iio_channel_attr_read_all(struct iio_channel *chn,
662  int (*cb)(struct iio_channel *chn,
663  const char *attr, const char *val, size_t len, void *d),
664  void *data);
665 
666 
674 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
675  const char *attr, bool *val);
676 
677 
685 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
686  const char *attr, long long *val);
687 
688 
696 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
697  const char *attr, double *val);
698 
699 
718 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
719  const char *attr, const char *src);
720 
721 
730 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
731  const char *attr, const void *src, size_t len);
732 
733 
744 __api int iio_channel_attr_write_all(struct iio_channel *chn,
745  ssize_t (*cb)(struct iio_channel *chn,
746  const char *attr, void *buf, size_t len, void *d),
747  void *data);
748 
749 
757 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
758  const char *attr, bool val);
759 
760 
768 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
769  const char *attr, long long val);
770 
771 
779 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
780  const char *attr, double val);
781 
782 
789 __api void iio_channel_enable(struct iio_channel *chn);
790 
791 
794 __api void iio_channel_disable(struct iio_channel *chn);
795 
796 
800 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
801 
802 
810 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
811  struct iio_buffer *buffer, void *dst, size_t len);
812 
813 
821 __api size_t iio_channel_read(const struct iio_channel *chn,
822  struct iio_buffer *buffer, void *dst, size_t len);
823 
824 
832 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
833  struct iio_buffer *buffer, const void *src, size_t len);
834 
835 
843 __api size_t iio_channel_write(const struct iio_channel *chn,
844  struct iio_buffer *buffer, const void *src, size_t len);
845 
846 
850 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
851 
852 
856 __api void * iio_channel_get_data(const struct iio_channel *chn);
857 
858 /* ------------------------------------------------------------------*/
860 /* ------------------------- Buffer functions --------------------------------*/
870 __api __pure const struct iio_device * iio_buffer_get_device(
871  const struct iio_buffer *buf);
872 
873 
883 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
884  size_t samples_count, bool cyclic);
885 
886 
891 __api void iio_buffer_destroy(struct iio_buffer *buf);
892 
901 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
902 
914 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
915 
916 
923 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
924 
925 
932 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
933 
934 
942 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
943  size_t samples_count);
944 
945 
949 __api void * iio_buffer_start(const struct iio_buffer *buf);
950 
951 
967 __api void * iio_buffer_first(const struct iio_buffer *buf,
968  const struct iio_channel *chn);
969 
970 
975 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
976 
977 
982 __api void * iio_buffer_end(const struct iio_buffer *buf);
983 
984 
995 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
996  ssize_t (*callback)(const struct iio_channel *chn,
997  void *src, size_t bytes, void *d), void *data);
998 
999 
1003 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1004 
1005 
1009 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
1010 
1011 /* ------------------------------------------------------------------*/
1013 /* ------------------------- Low-level functions -----------------------------*/
1025  unsigned int length;
1026 
1028  unsigned int bits;
1029 
1031  unsigned int shift;
1032 
1035 
1038 
1040  bool is_be;
1041 
1044 
1046  double scale;
1047 };
1048 
1049 
1057 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1058 
1059 
1064 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1065 
1066 
1070 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1071  const struct iio_channel *chn);
1072 
1073 
1079 __api void iio_channel_convert(const struct iio_channel *chn,
1080  void *dst, const void *src);
1081 
1082 
1088 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1089  void *dst, const void *src);
1090 
1091 
1095 __api __pure unsigned int iio_device_get_debug_attrs_count(
1096  const struct iio_device *dev);
1097 
1098 
1104 __api __pure const char * iio_device_get_debug_attr(
1105  const struct iio_device *dev, unsigned int index);
1106 
1107 
1120 __api __pure const char * iio_device_find_debug_attr(
1121  const struct iio_device *dev, const char *name);
1122 
1123 
1146 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1147  const char *attr, char *dst, size_t len);
1148 
1149 
1159 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1160  int (*cb)(struct iio_device *dev, const char *attr,
1161  const char *value, size_t len, void *d),
1162  void *data);
1163 
1164 
1184 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1185  const char *attr, const char *src);
1186 
1187 
1196 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1197  const char *attr, const void *src, size_t len);
1198 
1199 
1209 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1210  ssize_t (*cb)(struct iio_device *dev,
1211  const char *attr, void *buf, size_t len, void *d),
1212  void *data);
1213 
1214 
1222 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1223  const char *attr, bool *val);
1224 
1225 
1233 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1234  const char *attr, long long *val);
1235 
1236 
1244 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1245  const char *attr, double *val);
1246 
1247 
1255 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1256  const char *attr, bool val);
1257 
1258 
1266 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1267  const char *attr, long long val);
1268 
1269 
1277 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1278  const char *attr, double val);
1279 
1280 
1293 __api int iio_device_identify_filename(const struct iio_device *dev,
1294  const char *filename, struct iio_channel **chn,
1295  const char **attr);
1296 
1297 
1304 __api int iio_device_reg_write(struct iio_device *dev,
1305  uint32_t address, uint32_t value);
1306 
1307 
1314 __api int iio_device_reg_read(struct iio_device *dev,
1315  uint32_t address, uint32_t *value);
1316 
1317 
1320 #ifdef __cplusplus
1321 }
1322 #endif
1323 
1324 #undef __api
1325 
1326 #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:320
__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:454
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:281
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:232
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:243
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:350
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:296
__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:166
__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:507
__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:847
__api __pure const struct iio_device * iio_channel_get_device(const struct iio_channel *chn)
Retrieve a pointer to the iio_device structure.
Definition: channel.c:652
__api __pure const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:175
__api __pure const struct iio_device * iio_buffer_get_device(const struct iio_buffer *buf)
Retrieve a pointer to the iio_device structure.
Definition: buffer.c:301
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:255
__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:171
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:423
__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:340
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:296
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:1040
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:149
__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:687
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:291
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:1028
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:150
__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:396
__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:236
__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:563
__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:379
__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:623
__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:165
__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:215
__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:558
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:237
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:1025
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:286
__api __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:141
__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:224
Represents a device in the IIO context.
__api __pure const struct iio_context * iio_device_get_context(const struct iio_device *dev)
Retrieve a pointer to the iio_context structure.
Definition: device.c:863
__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:557
__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:340
__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:635
__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:206
__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:170
__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:542
__api void iio_buffer_destroy(struct iio_buffer *buf)
Destroy the given buffer.
Definition: buffer.c:110
__api __pure const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition: channel.c:155
__api ssize_t iio_buffer_refill(struct iio_buffer *buf)
Fetch more samples from the hardware.
Definition: buffer.c:129
__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:184
__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:552
__api ssize_t iio_buffer_push_partial(struct iio_buffer *buf, size_t samples_count)
Send a given number of samples to the hardware.
Definition: buffer.c:184
__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:456
__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:180
__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:216
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:1034
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:320
__api void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:243
bool with_scale
Contains True if the sample should be scaled when converted.
Definition: iio.h:1043
__api void * iio_device_get_data(const struct iio_device *dev)
Retrieve a previously associated pointer of an iio_device structure.
Definition: device.c:351
__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:175
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:1046
__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:484
__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:472
__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:237
__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:248
__api __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:170
__api ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:451
__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:370
__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:611
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:227
__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:534
__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:501
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:222
__api __pure bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition: device.c:356
bool is_fully_defined
Contains True if the sample is fully defined, sign extended, etc.
Definition: iio.h:1037
__api void iio_device_set_data(struct iio_device *dev, void *data)
Associate a pointer to an iio_device structure.
Definition: device.c:346
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:546
__api void iio_strerror(int err, char *dst, size_t len)
Get a string description of an error code.
Definition: utilities.c:183
unsigned int shift
Right-shift to apply when converting sample.
Definition: iio.h:1031
__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:513
__api struct iio_context * iio_create_context_from_uri(const char *uri)
Create a context from a URI description.
Definition: context.c:265
__api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking)
Make iio_buffer_refill() and iio_buffer_push() blocking or not.
Definition: buffer.c:124
__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:495
__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:210
__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:41
__api void iio_channel_enable(struct iio_channel *chn)
Enable the given channel.
Definition: channel.c:249
__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:519
__api __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:136
__api void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:255
__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:609
__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:572
__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:532
__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:185
__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:390
__api __pure const char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition: context.c:131
__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:524
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:438
__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:170
__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:588
__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:194
__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:648
__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:160
__api int iio_buffer_get_poll_fd(struct iio_buffer *buf)
Get a pollable file descriptor.
Definition: buffer.c:119
__api size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Definition: channel.c:469
__api __pure unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:180
__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:485
Contains the format of a data sample.
Definition: iio.h:1023
__api ssize_t iio_buffer_push(struct iio_buffer *buf)
Send the samples to the hardware.
Definition: buffer.c:150
__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:196
__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:600
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:247
__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:699
__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:568
__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:330
__api struct iio_context * iio_create_network_context(const char *host)
Create a context from the network.
Definition: context.c:330
__api 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:368
__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:855