libiio  0.19
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 <limits.h>
30 #include <stdint.h>
31 #include <stdlib.h>
32 #include <stddef.h>
33 
34 #if (defined(_WIN32) || defined(__MBED__))
35 #ifndef _SSIZE_T_DEFINED
36 typedef ptrdiff_t ssize_t;
37 #define _SSIZE_T_DEFINED
38 #endif
39 #else
40 #include <sys/types.h>
41 #endif
42 
43 #if defined(_MSC_VER) && (_MSC_VER < 1800) && !defined(__BOOL_DEFINED)
44 #undef bool
45 #undef false
46 #undef true
47 #define bool char
48 #define false 0
49 #define true 1
50 #else
51 #include <stdbool.h>
52 #endif
53 
54 #if defined(__GNUC__) && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
55 #ifndef __cnst
56 #define __cnst __attribute__((const))
57 #endif
58 #ifndef __pure
59 #define __pure __attribute__((pure))
60 #endif
61 #define __notused __attribute__((unused))
62 #else
63 #define __cnst
64 #define __pure
65 #define __notused
66 #endif
67 
68 #ifdef _WIN32
69 # ifdef LIBIIO_EXPORTS
70 # define __api __declspec(dllexport)
71 # else
72 # define __api __declspec(dllimport)
73 # endif
74 #elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
75 # define __api __attribute__((visibility ("default")))
76 #else
77 # define __api
78 #endif
79 
80 struct iio_context;
81 struct iio_device;
82 struct iio_channel;
83 struct iio_buffer;
84 
85 struct iio_context_info;
86 struct iio_scan_context;
87 
96  IIO_VOLTAGE,
97  IIO_CURRENT,
98  IIO_POWER,
99  IIO_ACCEL,
100  IIO_ANGL_VEL,
101  IIO_MAGN,
102  IIO_LIGHT,
103  IIO_INTENSITY,
104  IIO_PROXIMITY,
105  IIO_TEMP,
106  IIO_INCLI,
107  IIO_ROT,
108  IIO_ANGL,
109  IIO_TIMESTAMP,
110  IIO_CAPACITANCE,
111  IIO_ALTVOLTAGE,
112  IIO_CCT,
113  IIO_PRESSURE,
114  IIO_HUMIDITYRELATIVE,
115  IIO_ACTIVITY,
116  IIO_STEPS,
117  IIO_ENERGY,
118  IIO_DISTANCE,
119  IIO_VELOCITY,
120  IIO_CONCENTRATION,
121  IIO_RESISTANCE,
122  IIO_PH,
123  IIO_UVINDEX,
124  IIO_ELECTRICALCONDUCTIVITY,
125  IIO_COUNT,
126  IIO_INDEX,
127  IIO_GRAVITY,
128  IIO_CHAN_TYPE_UNKNOWN = INT_MAX
129 };
130 
139  IIO_NO_MOD,
140  IIO_MOD_X,
141  IIO_MOD_Y,
142  IIO_MOD_Z,
143  IIO_MOD_X_AND_Y,
144  IIO_MOD_X_AND_Z,
145  IIO_MOD_Y_AND_Z,
146  IIO_MOD_X_AND_Y_AND_Z,
147  IIO_MOD_X_OR_Y,
148  IIO_MOD_X_OR_Z,
149  IIO_MOD_Y_OR_Z,
150  IIO_MOD_X_OR_Y_OR_Z,
151  IIO_MOD_LIGHT_BOTH,
152  IIO_MOD_LIGHT_IR,
153  IIO_MOD_ROOT_SUM_SQUARED_X_Y,
154  IIO_MOD_SUM_SQUARED_X_Y_Z,
155  IIO_MOD_LIGHT_CLEAR,
156  IIO_MOD_LIGHT_RED,
157  IIO_MOD_LIGHT_GREEN,
158  IIO_MOD_LIGHT_BLUE,
159  IIO_MOD_QUATERNION,
160  IIO_MOD_TEMP_AMBIENT,
161  IIO_MOD_TEMP_OBJECT,
162  IIO_MOD_NORTH_MAGN,
163  IIO_MOD_NORTH_TRUE,
164  IIO_MOD_NORTH_MAGN_TILT_COMP,
165  IIO_MOD_NORTH_TRUE_TILT_COMP,
166  IIO_MOD_RUNNING,
167  IIO_MOD_JOGGING,
168  IIO_MOD_WALKING,
169  IIO_MOD_STILL,
170  IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
171  IIO_MOD_I,
172  IIO_MOD_Q,
173  IIO_MOD_CO2,
174  IIO_MOD_VOC,
175  IIO_MOD_LIGHT_UV,
176 };
177 
178 /* ---------------------------------------------------------------------------*/
179 /* ------------------------- Scan functions ----------------------------------*/
196 __api struct iio_scan_context * iio_create_scan_context(
197  const char *backend, unsigned int flags);
198 
199 
204 __api void iio_scan_context_destroy(struct iio_scan_context *ctx);
205 
206 
214 __api ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx,
215  struct iio_context_info ***info);
216 
217 
221 __api void iio_context_info_list_free(struct iio_context_info **info);
222 
223 
228 __api __pure const char * iio_context_info_get_description(
229  const struct iio_context_info *info);
230 
231 
236 __api __pure const char * iio_context_info_get_uri(
237  const struct iio_context_info *info);
238 
239 /* ------------------------------------------------------------------*/
241 /* ------------------------- Top-level functions -----------------------------*/
250 __api void iio_library_get_version(unsigned int *major,
251  unsigned int *minor, char git_tag[8]);
252 
253 
259 __api void iio_strerror(int err, char *dst, size_t len);
260 
261 
267 __api __cnst bool iio_has_backend(const char *backend);
268 
269 
274 __api __cnst unsigned int iio_get_backends_count(void);
275 
276 
283 __api __cnst const char * iio_get_backend(unsigned int index);
284 
285 /* ------------------------------------------------------------------*/
287 /* ------------------------- Context functions -------------------------------*/
303 __api struct iio_context * iio_create_default_context(void);
304 
305 
309 __api struct iio_context * iio_create_local_context(void);
310 
311 
319 __api struct iio_context * iio_create_xml_context(const char *xml_file);
320 
321 
331  const char *xml, size_t len);
332 
333 
338 __api struct iio_context * iio_create_network_context(const char *host);
339 
340 
363 __api struct iio_context * iio_create_context_from_uri(const char *uri);
364 
365 
370 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
371 
372 
377 __api void iio_context_destroy(struct iio_context *ctx);
378 
379 
387 __api int iio_context_get_version(const struct iio_context *ctx,
388  unsigned int *major, unsigned int *minor, char git_tag[8]);
389 
390 
394 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
395 
396 
404 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
405 
406 
413 __api __pure const char * iio_context_get_description(
414  const struct iio_context *ctx);
415 
416 
422 __api __pure unsigned int iio_context_get_attrs_count(
423  const struct iio_context *ctx);
424 
425 
435 __api int iio_context_get_attr(
436  const struct iio_context *ctx, unsigned int index,
437  const char **name, const char **value);
438 
439 
448 __api const char * iio_context_get_attr_value(
449  const struct iio_context *ctx, const char *name);
450 
451 
455 __api __pure unsigned int iio_context_get_devices_count(
456  const struct iio_context *ctx);
457 
458 
464 __api __pure struct iio_device * iio_context_get_device(
465  const struct iio_context *ctx, unsigned int index);
466 
467 
475 __api __pure struct iio_device * iio_context_find_device(
476  const struct iio_context *ctx, const char *name);
477 
478 
486 __api int iio_context_set_timeout(
487  struct iio_context *ctx, unsigned int timeout_ms);
488 
489 /* ------------------------------------------------------------------*/
491 /* ------------------------- Device functions --------------------------------*/
501 __api __pure const struct iio_context * iio_device_get_context(
502  const struct iio_device *dev);
503 
504 
508 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
509 
510 
516 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
517 
518 
522 __api __pure unsigned int iio_device_get_channels_count(
523  const struct iio_device *dev);
524 
525 
529 __api __pure unsigned int iio_device_get_attrs_count(
530  const struct iio_device *dev);
531 
535 __api __pure unsigned int iio_device_get_buffer_attrs_count(
536  const struct iio_device *dev);
537 
543 __api __pure struct iio_channel * iio_device_get_channel(
544  const struct iio_device *dev, unsigned int index);
545 
546 
552 __api __pure const char * iio_device_get_attr(
553  const struct iio_device *dev, unsigned int index);
554 
560 __api __pure const char * iio_device_get_buffer_attr(
561  const struct iio_device *dev, unsigned int index);
562 
571 __api __pure struct iio_channel * iio_device_find_channel(
572  const struct iio_device *dev, const char *name, bool output);
573 
574 
586 __api __pure const char * iio_device_find_attr(
587  const struct iio_device *dev, const char *name);
588 
600 __api __pure const char * iio_device_find_buffer_attr(
601  const struct iio_device *dev, const char *name);
602 
624 __api ssize_t iio_device_attr_read(const struct iio_device *dev,
625  const char *attr, char *dst, size_t len);
626 
627 
638 __api int iio_device_attr_read_all(struct iio_device *dev,
639  int (*cb)(struct iio_device *dev, const char *attr,
640  const char *value, size_t len, void *d),
641  void *data);
642 
643 
651 __api int iio_device_attr_read_bool(const struct iio_device *dev,
652  const char *attr, bool *val);
653 
654 
662 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
663  const char *attr, long long *val);
664 
665 
673 __api int iio_device_attr_read_double(const struct iio_device *dev,
674  const char *attr, double *val);
675 
676 
695 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
696  const char *attr, const char *src);
697 
698 
707 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
708  const char *attr, const void *src, size_t len);
709 
710 
721 __api int iio_device_attr_write_all(struct iio_device *dev,
722  ssize_t (*cb)(struct iio_device *dev,
723  const char *attr, void *buf, size_t len, void *d),
724  void *data);
725 
726 
734 __api int iio_device_attr_write_bool(const struct iio_device *dev,
735  const char *attr, bool val);
736 
737 
745 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
746  const char *attr, long long val);
747 
748 
756 __api int iio_device_attr_write_double(const struct iio_device *dev,
757  const char *attr, double val);
758 
781 __api ssize_t iio_device_buffer_attr_read(const struct iio_device *dev,
782  const char *attr, char *dst, size_t len);
783 
794 __api int iio_device_buffer_attr_read_all(struct iio_device *dev,
795  int (*cb)(struct iio_device *dev, const char *attr,
796  const char *value, size_t len, void *d),
797  void *data);
798 
799 
807 __api int iio_device_buffer_attr_read_bool(const struct iio_device *dev,
808  const char *attr, bool *val);
809 
810 
818 __api int iio_device_buffer_attr_read_longlong(const struct iio_device *dev,
819  const char *attr, long long *val);
820 
821 
829 __api int iio_device_buffer_attr_read_double(const struct iio_device *dev,
830  const char *attr, double *val);
831 
832 
852 __api ssize_t iio_device_buffer_attr_write(const struct iio_device *dev,
853  const char *attr, const char *src);
854 
855 
864 __api ssize_t iio_device_buffer_attr_write_raw(const struct iio_device *dev,
865  const char *attr, const void *src, size_t len);
866 
867 
878 __api int iio_device_buffer_attr_write_all(struct iio_device *dev,
879  ssize_t (*cb)(struct iio_device *dev,
880  const char *attr, void *buf, size_t len, void *d),
881  void *data);
882 
883 
891 __api int iio_device_buffer_attr_write_bool(const struct iio_device *dev,
892  const char *attr, bool val);
893 
894 
902 __api int iio_device_buffer_attr_write_longlong(const struct iio_device *dev,
903  const char *attr, long long val);
904 
905 
913 __api int iio_device_buffer_attr_write_double(const struct iio_device *dev,
914  const char *attr, double val);
915 
916 
920 __api void iio_device_set_data(struct iio_device *dev, void *data);
921 
922 
926 __api void * iio_device_get_data(const struct iio_device *dev);
927 
928 
936 __api int iio_device_get_trigger(const struct iio_device *dev,
937  const struct iio_device **trigger);
938 
939 
946 __api int iio_device_set_trigger(const struct iio_device *dev,
947  const struct iio_device *trigger);
948 
949 
953 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
954 
962 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
963  unsigned int nb_buffers);
964 /* ------------------------------------------------------------------*/
966 /* ------------------------- Channel functions -------------------------------*/
976 __api __pure const struct iio_device * iio_channel_get_device(
977  const struct iio_channel *chn);
978 
979 
983 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
984 
985 
991 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
992 
993 
997 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
998 
999 
1007 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
1008 
1009 
1013 __api __pure unsigned int iio_channel_get_attrs_count(
1014  const struct iio_channel *chn);
1015 
1016 
1022 __api __pure const char * iio_channel_get_attr(
1023  const struct iio_channel *chn, unsigned int index);
1024 
1025 
1037 __api __pure const char * iio_channel_find_attr(
1038  const struct iio_channel *chn, const char *name);
1039 
1040 
1047 __api __pure const char * iio_channel_attr_get_filename(
1048  const struct iio_channel *chn, const char *attr);
1049 
1050 
1072 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
1073  const char *attr, char *dst, size_t len);
1074 
1075 
1086 __api int iio_channel_attr_read_all(struct iio_channel *chn,
1087  int (*cb)(struct iio_channel *chn,
1088  const char *attr, const char *val, size_t len, void *d),
1089  void *data);
1090 
1091 
1099 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
1100  const char *attr, bool *val);
1101 
1102 
1110 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
1111  const char *attr, long long *val);
1112 
1113 
1121 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
1122  const char *attr, double *val);
1123 
1124 
1143 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
1144  const char *attr, const char *src);
1145 
1146 
1155 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
1156  const char *attr, const void *src, size_t len);
1157 
1158 
1169 __api int iio_channel_attr_write_all(struct iio_channel *chn,
1170  ssize_t (*cb)(struct iio_channel *chn,
1171  const char *attr, void *buf, size_t len, void *d),
1172  void *data);
1173 
1174 
1182 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
1183  const char *attr, bool val);
1184 
1185 
1193 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
1194  const char *attr, long long val);
1195 
1196 
1204 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
1205  const char *attr, double val);
1206 
1207 
1214 __api void iio_channel_enable(struct iio_channel *chn);
1215 
1216 
1219 __api void iio_channel_disable(struct iio_channel *chn);
1220 
1221 
1225 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
1226 
1227 
1235 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
1236  struct iio_buffer *buffer, void *dst, size_t len);
1237 
1238 
1246 __api size_t iio_channel_read(const struct iio_channel *chn,
1247  struct iio_buffer *buffer, void *dst, size_t len);
1248 
1249 
1257 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
1258  struct iio_buffer *buffer, const void *src, size_t len);
1259 
1260 
1268 __api size_t iio_channel_write(const struct iio_channel *chn,
1269  struct iio_buffer *buffer, const void *src, size_t len);
1270 
1271 
1275 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
1276 
1277 
1281 __api void * iio_channel_get_data(const struct iio_channel *chn);
1282 
1283 
1287 __api __pure enum iio_chan_type iio_channel_get_type(
1288  const struct iio_channel *chn);
1289 
1290 
1294 __api __pure enum iio_modifier iio_channel_get_modifier(
1295  const struct iio_channel *chn);
1296 
1297 /* ------------------------------------------------------------------*/
1299 /* ------------------------- Buffer functions --------------------------------*/
1309 __api __pure const struct iio_device * iio_buffer_get_device(
1310  const struct iio_buffer *buf);
1311 
1312 
1322 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
1323  size_t samples_count, bool cyclic);
1324 
1325 
1330 __api void iio_buffer_destroy(struct iio_buffer *buf);
1331 
1340 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
1341 
1353 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
1354 
1355 
1362 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
1363 
1364 
1371 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
1372 
1373 
1381 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
1382  size_t samples_count);
1383 
1407 __api void iio_buffer_cancel(struct iio_buffer *buf);
1408 
1409 
1413 __api void * iio_buffer_start(const struct iio_buffer *buf);
1414 
1415 
1431 __api void * iio_buffer_first(const struct iio_buffer *buf,
1432  const struct iio_channel *chn);
1433 
1434 
1439 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
1440 
1441 
1446 __api void * iio_buffer_end(const struct iio_buffer *buf);
1447 
1448 
1460 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
1461  ssize_t (*callback)(const struct iio_channel *chn,
1462  void *src, size_t bytes, void *d), void *data);
1463 
1464 
1468 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1469 
1470 
1474 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
1475 
1476 /* ------------------------------------------------------------------*/
1478 /* ------------------------- Low-level functions -----------------------------*/
1490  unsigned int length;
1491 
1493  unsigned int bits;
1494 
1496  unsigned int shift;
1497 
1500 
1503 
1505  bool is_be;
1506 
1509 
1511  double scale;
1512 
1514  unsigned int repeat;
1515 };
1516 
1517 
1525 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1526 
1527 
1532 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1533 
1534 
1538 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1539  const struct iio_channel *chn);
1540 
1541 
1547 __api void iio_channel_convert(const struct iio_channel *chn,
1548  void *dst, const void *src);
1549 
1550 
1556 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1557  void *dst, const void *src);
1558 
1559 
1563 __api __pure unsigned int iio_device_get_debug_attrs_count(
1564  const struct iio_device *dev);
1565 
1566 
1572 __api __pure const char * iio_device_get_debug_attr(
1573  const struct iio_device *dev, unsigned int index);
1574 
1575 
1588 __api __pure const char * iio_device_find_debug_attr(
1589  const struct iio_device *dev, const char *name);
1590 
1591 
1614 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1615  const char *attr, char *dst, size_t len);
1616 
1617 
1627 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1628  int (*cb)(struct iio_device *dev, const char *attr,
1629  const char *value, size_t len, void *d),
1630  void *data);
1631 
1632 
1652 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1653  const char *attr, const char *src);
1654 
1655 
1664 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1665  const char *attr, const void *src, size_t len);
1666 
1667 
1677 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1678  ssize_t (*cb)(struct iio_device *dev,
1679  const char *attr, void *buf, size_t len, void *d),
1680  void *data);
1681 
1682 
1690 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1691  const char *attr, bool *val);
1692 
1693 
1701 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1702  const char *attr, long long *val);
1703 
1704 
1712 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1713  const char *attr, double *val);
1714 
1715 
1723 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1724  const char *attr, bool val);
1725 
1726 
1734 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1735  const char *attr, long long val);
1736 
1737 
1745 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1746  const char *attr, double val);
1747 
1748 
1761 __api int iio_device_identify_filename(const struct iio_device *dev,
1762  const char *filename, struct iio_channel **chn,
1763  const char **attr);
1764 
1765 
1772 __api int iio_device_reg_write(struct iio_device *dev,
1773  uint32_t address, uint32_t value);
1774 
1775 
1782 __api int iio_device_reg_read(struct iio_device *dev,
1783  uint32_t address, uint32_t *value);
1784 
1785 
1788 #ifdef __cplusplus
1789 }
1790 #endif
1791 
1792 #undef __api
1793 
1794 #endif /* __IIO_H__ */
__api __pure const char * iio_context_info_get_uri(const struct iio_context_info *info)
Get the URI of a discovered context.
Definition: scan.c:38
__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:401
__api size_t iio_channel_write_raw(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Multiplex the samples of a given channel.
Definition: channel.c:626
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:293
__api 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:680
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:388
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:399
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:363
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:309
__api 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.
__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:176
__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:627
__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:1124
__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:842
__api __pure const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:230
__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:313
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:268
__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:181
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Demultiplex the samples of a given channel.
Definition: channel.c:595
__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:353
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:308
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:1505
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:151
__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:883
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:303
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:1493
__api __cnst const char * iio_get_backend(unsigned int index)
Retrieve the name of a given backend.
Definition: backend.c:46
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:296
__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:562
__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:317
__api struct iio_scan_context * iio_create_scan_context(const char *backend, unsigned int flags)
Create a scan context.
Definition: scan.c:125
__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:759
__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:486
__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:819
__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:311
__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:270
__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:754
__api 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:447
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:393
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:1490
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:298
__api 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:691
__api __pure 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:296
__api __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:143
__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:279
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:1148
__api 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:1132
__api void iio_scan_context_destroy(struct iio_scan_context *ctx)
Destroy the given scan context.
Definition: scan.c:153
__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:729
__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:421
__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:831
__api 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:715
__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:362
__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:326
iio_modifier
IIO channel modifier.
Definition: iio.h:138
__api __pure 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:291
__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:738
__api __cnst bool iio_has_backend(const char *backend)
Check if the specified backend is available.
Definition: backend.c:75
__api void iio_buffer_destroy(struct iio_buffer *buf)
Destroy the given buffer.
Definition: buffer.c:112
__api __pure const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition: channel.c:301
__api ssize_t iio_buffer_refill(struct iio_buffer *buf)
Fetch more samples from the hardware.
Definition: buffer.c:131
__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:340
__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:748
__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:188
__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:576
__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:190
__api 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:378
__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:372
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:1499
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:333
__api 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:652
__api void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:250
unsigned int repeat
Number of times length repeats (added in v0.8)
Definition: iio.h:1514
__api __pure const char * iio_context_info_get_description(const struct iio_context_info *info)
Get a description of a discovered context.
Definition: scan.c:32
bool with_scale
Contains True if the sample should be scaled when converted.
Definition: iio.h:1508
__api void * iio_device_get_data(const struct iio_device *dev)
Retrieve a previously associated pointer of an iio_device structure.
Definition: device.c:458
__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:331
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:1511
__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:604
__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:592
__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 ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, struct iio_context_info ***info)
Enumerate available contexts.
Definition: scan.c:44
__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:250
iio_chan_type
IIO channel type.
Definition: iio.h:95
__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:255
__api 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:427
__api void iio_buffer_cancel(struct iio_buffer *buf)
Cancel all buffer operations.
Definition: buffer.c:318
__api __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:225
__api __pure 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:305
__api ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:571
__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:526
__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:807
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:383
__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:706
__api 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:703
__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:673
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:378
__api __pure bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition: device.c:463
bool is_fully_defined
Contains True if the sample is fully defined, sign extended, etc.
Definition: iio.h:1502
__api void iio_device_set_data(struct iio_device *dev, void *data)
Associate a pointer to an iio_device structure.
Definition: device.c:453
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:718
__api void iio_strerror(int err, char *dst, size_t len)
Get a string description of an error code.
Definition: utilities.c:188
unsigned int shift
Right-shift to apply when converting sample.
Definition: iio.h:1496
__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:685
__api struct iio_context * iio_create_context_from_uri(const char *uri)
Create a context from a URI description.
Definition: context.c:278
__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:126
__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:615
__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:265
The information related to a discovered context.
__api void iio_context_info_list_free(struct iio_context_info **info)
Free a context info list.
Definition: scan.c:76
__api __pure enum iio_chan_type iio_channel_get_type(const struct iio_channel *chn)
Get the type of the given channel.
Definition: channel.c:321
__api __cnst unsigned int iio_get_backends_count(void)
Get the number of available backends.
Definition: backend.c:23
__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:42
__api void iio_channel_enable(struct iio_channel *chn)
Enable the given channel.
Definition: channel.c:405
__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:639
__api __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:138
__api void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:411
__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:799
__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:768
__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:728
__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:240
__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:497
__api __pure const char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition: context.c:133
__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:696
__api __pure enum iio_modifier iio_channel_get_modifier(const struct iio_channel *chn)
Get the modifier type of the given channel.
Definition: channel.c:316
__api 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:437
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Demultiplex and convert the samples of a given channel.
Definition: channel.c:610
__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:175
__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:784
__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:249
__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:844
__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:306
__api int iio_buffer_get_poll_fd(struct iio_buffer *buf)
Get a pollable file descriptor.
Definition: buffer.c:121
__api 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:668
__api 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:391
__api size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Convert and multiplex the samples of a given channel.
Definition: channel.c:641
__api __pure unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:235
__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:657
Contains the format of a data sample.
Definition: iio.h:1488
__api ssize_t iio_buffer_push(struct iio_buffer *buf)
Send the samples to the hardware.
Definition: buffer.c:152
__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:352
__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:796
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:260
__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:896
__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:740
__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:411
__api struct iio_context * iio_create_network_context(const char *host)
Create a context from the network.
Definition: context.c:343
__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:475
__api __pure unsigned int iio_context_get_attrs_count(const struct iio_context *ctx)
Get the number of context-specific attributes.
Definition: context.c:373
__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:1140