libiio  0.8
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 <stdbool.h>
31 #include <stdint.h>
32 #include <stdlib.h>
33 #include <stddef.h>
34 
35 #if (defined(_WIN32) || defined(__MBED__))
36 #ifndef _SSIZE_T_DEFINED
37 typedef ptrdiff_t ssize_t;
38 #define _SSIZE_T_DEFINED
39 #endif
40 #else
41 #include <sys/types.h>
42 #endif
43 
44 #if defined(__GNUC__) && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
45 #ifndef __cnst
46 #define __cnst __attribute__((const))
47 #endif
48 #ifndef __pure
49 #define __pure __attribute__((pure))
50 #endif
51 #define __notused __attribute__((unused))
52 #else
53 #define __cnst
54 #define __pure
55 #define __notused
56 #endif
57 
58 #ifdef _WIN32
59 # ifdef LIBIIO_EXPORTS
60 # define __api __declspec(dllexport)
61 # else
62 # define __api __declspec(dllimport)
63 # endif
64 #elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
65 # define __api __attribute__((visibility ("default")))
66 #else
67 # define __api
68 #endif
69 
70 struct iio_context;
71 struct iio_device;
72 struct iio_channel;
73 struct iio_buffer;
74 
75 struct iio_context_info;
76 struct iio_scan_context;
77 
86  IIO_VOLTAGE,
87  IIO_CURRENT,
88  IIO_POWER,
89  IIO_ACCEL,
90  IIO_ANGL_VEL,
91  IIO_MAGN,
92  IIO_LIGHT,
93  IIO_INTENSITY,
94  IIO_PROXIMITY,
95  IIO_TEMP,
96  IIO_INCLI,
97  IIO_ROT,
98  IIO_ANGL,
99  IIO_TIMESTAMP,
100  IIO_CAPACITANCE,
101  IIO_ALTVOLTAGE,
102  IIO_CCT,
103  IIO_PRESSURE,
104  IIO_HUMIDITYRELATIVE,
105  IIO_ACTIVITY,
106  IIO_STEPS,
107  IIO_ENERGY,
108  IIO_DISTANCE,
109  IIO_VELOCITY,
110  IIO_CONCENTRATION,
111  IIO_RESISTANCE,
112  IIO_PH,
113  IIO_CHAN_TYPE_UNKNOWN = INT_MAX
114 };
115 
124  IIO_NO_MOD,
125  IIO_MOD_X,
126  IIO_MOD_Y,
127  IIO_MOD_Z,
128  IIO_MOD_X_AND_Y,
129  IIO_MOD_X_AND_Z,
130  IIO_MOD_Y_AND_Z,
131  IIO_MOD_X_AND_Y_AND_Z,
132  IIO_MOD_X_OR_Y,
133  IIO_MOD_X_OR_Z,
134  IIO_MOD_Y_OR_Z,
135  IIO_MOD_X_OR_Y_OR_Z,
136  IIO_MOD_LIGHT_BOTH,
137  IIO_MOD_LIGHT_IR,
138  IIO_MOD_ROOT_SUM_SQUARED_X_Y,
139  IIO_MOD_SUM_SQUARED_X_Y_Z,
140  IIO_MOD_LIGHT_CLEAR,
141  IIO_MOD_LIGHT_RED,
142  IIO_MOD_LIGHT_GREEN,
143  IIO_MOD_LIGHT_BLUE,
144  IIO_MOD_QUATERNION,
145  IIO_MOD_TEMP_AMBIENT,
146  IIO_MOD_TEMP_OBJECT,
147  IIO_MOD_NORTH_MAGN,
148  IIO_MOD_NORTH_TRUE,
149  IIO_MOD_NORTH_MAGN_TILT_COMP,
150  IIO_MOD_NORTH_TRUE_TILT_COMP,
151  IIO_MOD_RUNNING,
152  IIO_MOD_JOGGING,
153  IIO_MOD_WALKING,
154  IIO_MOD_STILL,
155  IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
156  IIO_MOD_I,
157  IIO_MOD_Q,
158  IIO_MOD_CO2,
159  IIO_MOD_VOC,
160 };
161 
162 /* ---------------------------------------------------------------------------*/
163 /* ------------------------- Scan functions ----------------------------------*/
180 __api struct iio_scan_context * iio_create_scan_context(
181  const char *backend, unsigned int flags);
182 
183 
188 __api void iio_scan_context_destroy(struct iio_scan_context *ctx);
189 
190 
198 __api ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx,
199  struct iio_context_info ***info);
200 
201 
205 __api void iio_context_info_list_free(struct iio_context_info **info);
206 
207 
212 __api __pure const char * iio_context_info_get_description(
213  const struct iio_context_info *info);
214 
215 
220 __api __pure const char * iio_context_info_get_uri(
221  const struct iio_context_info *info);
222 
223 /* ------------------------------------------------------------------*/
225 /* ------------------------- Top-level functions -----------------------------*/
234 __api void iio_library_get_version(unsigned int *major,
235  unsigned int *minor, char git_tag[8]);
236 
237 
243 __api void iio_strerror(int err, char *dst, size_t len);
244 
245 /* ------------------------------------------------------------------*/
247 /* ------------------------- Context functions -------------------------------*/
263 __api struct iio_context * iio_create_default_context(void);
264 
265 
269 __api struct iio_context * iio_create_local_context(void);
270 
271 
279 __api struct iio_context * iio_create_xml_context(const char *xml_file);
280 
281 
291  const char *xml, size_t len);
292 
293 
298 __api struct iio_context * iio_create_network_context(const char *host);
299 
300 
305 __api struct iio_context * iio_create_context_from_uri(const char *uri);
306 
307 
312 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
313 
314 
319 __api void iio_context_destroy(struct iio_context *ctx);
320 
321 
329 __api int iio_context_get_version(const struct iio_context *ctx,
330  unsigned int *major, unsigned int *minor, char git_tag[8]);
331 
332 
336 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
337 
338 
346 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
347 
348 
355 __api __pure const char * iio_context_get_description(
356  const struct iio_context *ctx);
357 
358 
362 __api __pure unsigned int iio_context_get_devices_count(
363  const struct iio_context *ctx);
364 
365 
371 __api __pure struct iio_device * iio_context_get_device(
372  const struct iio_context *ctx, unsigned int index);
373 
374 
382 __api __pure struct iio_device * iio_context_find_device(
383  const struct iio_context *ctx, const char *name);
384 
385 
393 __api int iio_context_set_timeout(
394  struct iio_context *ctx, unsigned int timeout_ms);
395 
396 /* ------------------------------------------------------------------*/
398 /* ------------------------- Device functions --------------------------------*/
408 __api __pure const struct iio_context * iio_device_get_context(
409  const struct iio_device *dev);
410 
411 
415 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
416 
417 
423 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
424 
425 
429 __api __pure unsigned int iio_device_get_channels_count(
430  const struct iio_device *dev);
431 
432 
436 __api __pure unsigned int iio_device_get_attrs_count(
437  const struct iio_device *dev);
438 
439 
445 __api __pure struct iio_channel * iio_device_get_channel(
446  const struct iio_device *dev, unsigned int index);
447 
448 
454 __api __pure const char * iio_device_get_attr(
455  const struct iio_device *dev, unsigned int index);
456 
457 
466 __api __pure struct iio_channel * iio_device_find_channel(
467  const struct iio_device *dev, const char *name, bool output);
468 
469 
481 __api __pure const char * iio_device_find_attr(
482  const struct iio_device *dev, const char *name);
483 
484 
506  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
507  const char *attr, char *dst, size_t len);
508 
509 
520 __api int iio_device_attr_read_all(struct iio_device *dev,
521  int (*cb)(struct iio_device *dev, const char *attr,
522  const char *value, size_t len, void *d),
523  void *data);
524 
525 
533 __api int iio_device_attr_read_bool(const struct iio_device *dev,
534  const char *attr, bool *val);
535 
536 
544 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
545  const char *attr, long long *val);
546 
547 
555 __api int iio_device_attr_read_double(const struct iio_device *dev,
556  const char *attr, double *val);
557 
558 
577 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
578  const char *attr, const char *src);
579 
580 
589 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
590  const char *attr, const void *src, size_t len);
591 
592 
603 __api int iio_device_attr_write_all(struct iio_device *dev,
604  ssize_t (*cb)(struct iio_device *dev,
605  const char *attr, void *buf, size_t len, void *d),
606  void *data);
607 
608 
616 __api int iio_device_attr_write_bool(const struct iio_device *dev,
617  const char *attr, bool val);
618 
619 
627 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
628  const char *attr, long long val);
629 
630 
638 __api int iio_device_attr_write_double(const struct iio_device *dev,
639  const char *attr, double val);
640 
641 
645 __api void iio_device_set_data(struct iio_device *dev, void *data);
646 
647 
651 __api void * iio_device_get_data(const struct iio_device *dev);
652 
653 
661 __api int iio_device_get_trigger(const struct iio_device *dev,
662  const struct iio_device **trigger);
663 
664 
671 __api int iio_device_set_trigger(const struct iio_device *dev,
672  const struct iio_device *trigger);
673 
674 
678 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
679 
688 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
689  unsigned int nb_buffers);
690 /* ------------------------------------------------------------------*/
692 /* ------------------------- Channel functions -------------------------------*/
702 __api __pure const struct iio_device * iio_channel_get_device(
703  const struct iio_channel *chn);
704 
705 
709 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
710 
711 
717 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
718 
719 
723 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
724 
725 
733 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
734 
735 
739 __api __pure unsigned int iio_channel_get_attrs_count(
740  const struct iio_channel *chn);
741 
742 
748 __api __pure const char * iio_channel_get_attr(
749  const struct iio_channel *chn, unsigned int index);
750 
751 
763 __api __pure const char * iio_channel_find_attr(
764  const struct iio_channel *chn, const char *name);
765 
766 
773 __api __pure const char * iio_channel_attr_get_filename(
774  const struct iio_channel *chn, const char *attr);
775 
776 
798 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
799  const char *attr, char *dst, size_t len);
800 
801 
812 __api int iio_channel_attr_read_all(struct iio_channel *chn,
813  int (*cb)(struct iio_channel *chn,
814  const char *attr, const char *val, size_t len, void *d),
815  void *data);
816 
817 
825 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
826  const char *attr, bool *val);
827 
828 
836 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
837  const char *attr, long long *val);
838 
839 
847 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
848  const char *attr, double *val);
849 
850 
869 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
870  const char *attr, const char *src);
871 
872 
881 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
882  const char *attr, const void *src, size_t len);
883 
884 
895 __api int iio_channel_attr_write_all(struct iio_channel *chn,
896  ssize_t (*cb)(struct iio_channel *chn,
897  const char *attr, void *buf, size_t len, void *d),
898  void *data);
899 
900 
908 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
909  const char *attr, bool val);
910 
911 
919 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
920  const char *attr, long long val);
921 
922 
930 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
931  const char *attr, double val);
932 
933 
940 __api void iio_channel_enable(struct iio_channel *chn);
941 
942 
945 __api void iio_channel_disable(struct iio_channel *chn);
946 
947 
951 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
952 
953 
961 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
962  struct iio_buffer *buffer, void *dst, size_t len);
963 
964 
972 __api size_t iio_channel_read(const struct iio_channel *chn,
973  struct iio_buffer *buffer, void *dst, size_t len);
974 
975 
983 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
984  struct iio_buffer *buffer, const void *src, size_t len);
985 
986 
994 __api size_t iio_channel_write(const struct iio_channel *chn,
995  struct iio_buffer *buffer, const void *src, size_t len);
996 
997 
1001 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
1002 
1003 
1007 __api void * iio_channel_get_data(const struct iio_channel *chn);
1008 
1009 
1013 __api __pure enum iio_chan_type iio_channel_get_type(
1014  const struct iio_channel *chn);
1015 
1016 
1020 __api __pure enum iio_modifier iio_channel_get_modifier(
1021  const struct iio_channel *chn);
1022 
1023 /* ------------------------------------------------------------------*/
1025 /* ------------------------- Buffer functions --------------------------------*/
1035 __api __pure const struct iio_device * iio_buffer_get_device(
1036  const struct iio_buffer *buf);
1037 
1038 
1048 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
1049  size_t samples_count, bool cyclic);
1050 
1051 
1056 __api void iio_buffer_destroy(struct iio_buffer *buf);
1057 
1066 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
1067 
1079 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
1080 
1081 
1088 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
1089 
1090 
1097 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
1098 
1099 
1107 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
1108  size_t samples_count);
1109 
1133 __api void iio_buffer_cancel(struct iio_buffer *buf);
1134 
1135 
1139 __api void * iio_buffer_start(const struct iio_buffer *buf);
1140 
1141 
1157 __api void * iio_buffer_first(const struct iio_buffer *buf,
1158  const struct iio_channel *chn);
1159 
1160 
1165 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
1166 
1167 
1172 __api void * iio_buffer_end(const struct iio_buffer *buf);
1173 
1174 
1186 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
1187  ssize_t (*callback)(const struct iio_channel *chn,
1188  void *src, size_t bytes, void *d), void *data);
1189 
1190 
1194 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1195 
1196 
1200 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
1201 
1202 /* ------------------------------------------------------------------*/
1204 /* ------------------------- Low-level functions -----------------------------*/
1216  unsigned int length;
1217 
1219  unsigned int bits;
1220 
1222  unsigned int shift;
1223 
1226 
1229 
1231  bool is_be;
1232 
1235 
1237  double scale;
1238 
1240  unsigned int repeat;
1241 };
1242 
1243 
1251 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1252 
1253 
1258 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1259 
1260 
1264 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1265  const struct iio_channel *chn);
1266 
1267 
1273 __api void iio_channel_convert(const struct iio_channel *chn,
1274  void *dst, const void *src);
1275 
1276 
1282 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1283  void *dst, const void *src);
1284 
1285 
1289 __api __pure unsigned int iio_device_get_debug_attrs_count(
1290  const struct iio_device *dev);
1291 
1292 
1298 __api __pure const char * iio_device_get_debug_attr(
1299  const struct iio_device *dev, unsigned int index);
1300 
1301 
1314 __api __pure const char * iio_device_find_debug_attr(
1315  const struct iio_device *dev, const char *name);
1316 
1317 
1340 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1341  const char *attr, char *dst, size_t len);
1342 
1343 
1353 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1354  int (*cb)(struct iio_device *dev, const char *attr,
1355  const char *value, size_t len, void *d),
1356  void *data);
1357 
1358 
1378 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1379  const char *attr, const char *src);
1380 
1381 
1390 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1391  const char *attr, const void *src, size_t len);
1392 
1393 
1403 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1404  ssize_t (*cb)(struct iio_device *dev,
1405  const char *attr, void *buf, size_t len, void *d),
1406  void *data);
1407 
1408 
1416 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1417  const char *attr, bool *val);
1418 
1419 
1427 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1428  const char *attr, long long *val);
1429 
1430 
1438 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1439  const char *attr, double *val);
1440 
1441 
1449 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1450  const char *attr, bool val);
1451 
1452 
1460 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1461  const char *attr, long long val);
1462 
1463 
1471 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1472  const char *attr, double val);
1473 
1474 
1487 __api int iio_device_identify_filename(const struct iio_device *dev,
1488  const char *filename, struct iio_channel **chn,
1489  const char **attr);
1490 
1491 
1498 __api int iio_device_reg_write(struct iio_device *dev,
1499  uint32_t address, uint32_t value);
1500 
1501 
1508 __api int iio_device_reg_read(struct iio_device *dev,
1509  uint32_t address, uint32_t *value);
1510 
1511 
1514 #ifdef __cplusplus
1515 }
1516 #endif
1517 
1518 #undef __api
1519 
1520 #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: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:622
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:291
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:384
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:395
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:351
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:297
__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:167
__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:510
__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:850
__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:820
__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:311
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:256
__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:172
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:591
__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:341
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:306
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:1231
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:150
__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:690
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:301
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:1219
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:292
__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:558
__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 struct iio_scan_context * iio_create_scan_context(const char *backend, unsigned int flags)
Create a scan context.
Definition: scan.c:130
__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:566
__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:626
__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:307
__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:561
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:389
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:1216
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.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:142
__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:866
__api void iio_scan_context_destroy(struct iio_scan_context *ctx)
Destroy the given scan context.
Definition: scan.c:158
__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:725
__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:638
__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:358
__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:322
iio_modifier
IIO channel modifier.
Definition: iio.h:123
__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:545
__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:297
__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:336
__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:555
__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:459
__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:181
__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:368
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:1225
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:321
__api void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:249
unsigned int repeat
Number of times length repeats (added in v0.8)
Definition: iio.h:1240
__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:1234
__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:327
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:1237
__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:487
__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:475
__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:238
iio_chan_type
IIO channel type.
Definition: iio.h:85
__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:254
__api void iio_buffer_cancel(struct iio_buffer *buf)
Cancel all buffer operations.
Definition: buffer.c:316
__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:454
__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:522
__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:614
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:379
__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:702
__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:669
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:374
__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:1228
__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:714
__api void iio_strerror(int err, char *dst, size_t len)
Get a string description of an error code.
Definition: utilities.c:186
unsigned int shift
Right-shift to apply when converting sample.
Definition: iio.h:1222
__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:681
__api struct iio_context * iio_create_context_from_uri(const char *uri)
Create a context from a URI description.
Definition: context.c:266
__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:498
__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
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:317
__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:401
__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:522
__api __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:137
__api void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:407
__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:777
__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:575
__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:535
__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:132
__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:692
__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:312
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:606
__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:173
__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:591
__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:651
__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:302
__api int iio_buffer_get_poll_fd(struct iio_buffer *buf)
Get a pollable file descriptor.
Definition: buffer.c:121
__api size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Definition: channel.c:637
__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:653
Contains the format of a data sample.
Definition: iio.h:1214
__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:348
__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:603
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:248
__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:702
__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:736
__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:331
__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:858