libiio  0.9
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_CHAN_TYPE_UNKNOWN = INT_MAX
124 };
125 
134  IIO_NO_MOD,
135  IIO_MOD_X,
136  IIO_MOD_Y,
137  IIO_MOD_Z,
138  IIO_MOD_X_AND_Y,
139  IIO_MOD_X_AND_Z,
140  IIO_MOD_Y_AND_Z,
141  IIO_MOD_X_AND_Y_AND_Z,
142  IIO_MOD_X_OR_Y,
143  IIO_MOD_X_OR_Z,
144  IIO_MOD_Y_OR_Z,
145  IIO_MOD_X_OR_Y_OR_Z,
146  IIO_MOD_LIGHT_BOTH,
147  IIO_MOD_LIGHT_IR,
148  IIO_MOD_ROOT_SUM_SQUARED_X_Y,
149  IIO_MOD_SUM_SQUARED_X_Y_Z,
150  IIO_MOD_LIGHT_CLEAR,
151  IIO_MOD_LIGHT_RED,
152  IIO_MOD_LIGHT_GREEN,
153  IIO_MOD_LIGHT_BLUE,
154  IIO_MOD_QUATERNION,
155  IIO_MOD_TEMP_AMBIENT,
156  IIO_MOD_TEMP_OBJECT,
157  IIO_MOD_NORTH_MAGN,
158  IIO_MOD_NORTH_TRUE,
159  IIO_MOD_NORTH_MAGN_TILT_COMP,
160  IIO_MOD_NORTH_TRUE_TILT_COMP,
161  IIO_MOD_RUNNING,
162  IIO_MOD_JOGGING,
163  IIO_MOD_WALKING,
164  IIO_MOD_STILL,
165  IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
166  IIO_MOD_I,
167  IIO_MOD_Q,
168  IIO_MOD_CO2,
169  IIO_MOD_VOC,
170 };
171 
172 /* ---------------------------------------------------------------------------*/
173 /* ------------------------- Scan functions ----------------------------------*/
190 __api struct iio_scan_context * iio_create_scan_context(
191  const char *backend, unsigned int flags);
192 
193 
198 __api void iio_scan_context_destroy(struct iio_scan_context *ctx);
199 
200 
208 __api ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx,
209  struct iio_context_info ***info);
210 
211 
215 __api void iio_context_info_list_free(struct iio_context_info **info);
216 
217 
222 __api __pure const char * iio_context_info_get_description(
223  const struct iio_context_info *info);
224 
225 
230 __api __pure const char * iio_context_info_get_uri(
231  const struct iio_context_info *info);
232 
233 /* ------------------------------------------------------------------*/
235 /* ------------------------- Top-level functions -----------------------------*/
244 __api void iio_library_get_version(unsigned int *major,
245  unsigned int *minor, char git_tag[8]);
246 
247 
253 __api void iio_strerror(int err, char *dst, size_t len);
254 
255 
261 __api __cnst bool iio_has_backend(const char *backend);
262 
263 
268 __api __cnst unsigned int iio_get_backends_count(void);
269 
270 
277 __api __cnst const char * iio_get_backend(unsigned int index);
278 
279 /* ------------------------------------------------------------------*/
281 /* ------------------------- Context functions -------------------------------*/
297 __api struct iio_context * iio_create_default_context(void);
298 
299 
303 __api struct iio_context * iio_create_local_context(void);
304 
305 
313 __api struct iio_context * iio_create_xml_context(const char *xml_file);
314 
315 
325  const char *xml, size_t len);
326 
327 
332 __api struct iio_context * iio_create_network_context(const char *host);
333 
334 
339 __api struct iio_context * iio_create_context_from_uri(const char *uri);
340 
341 
346 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
347 
348 
353 __api void iio_context_destroy(struct iio_context *ctx);
354 
355 
363 __api int iio_context_get_version(const struct iio_context *ctx,
364  unsigned int *major, unsigned int *minor, char git_tag[8]);
365 
366 
370 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
371 
372 
380 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
381 
382 
389 __api __pure const char * iio_context_get_description(
390  const struct iio_context *ctx);
391 
392 
398 __api __pure unsigned int iio_context_get_attrs_count(
399  const struct iio_context *ctx);
400 
401 
411 __api int iio_context_get_attr(
412  const struct iio_context *ctx, unsigned int index,
413  const char **name, const char **value);
414 
415 
424 __api const char * iio_context_get_attr_value(
425  const struct iio_context *ctx, const char *name);
426 
427 
431 __api __pure unsigned int iio_context_get_devices_count(
432  const struct iio_context *ctx);
433 
434 
440 __api __pure struct iio_device * iio_context_get_device(
441  const struct iio_context *ctx, unsigned int index);
442 
443 
451 __api __pure struct iio_device * iio_context_find_device(
452  const struct iio_context *ctx, const char *name);
453 
454 
462 __api int iio_context_set_timeout(
463  struct iio_context *ctx, unsigned int timeout_ms);
464 
465 /* ------------------------------------------------------------------*/
467 /* ------------------------- Device functions --------------------------------*/
477 __api __pure const struct iio_context * iio_device_get_context(
478  const struct iio_device *dev);
479 
480 
484 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
485 
486 
492 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
493 
494 
498 __api __pure unsigned int iio_device_get_channels_count(
499  const struct iio_device *dev);
500 
501 
505 __api __pure unsigned int iio_device_get_attrs_count(
506  const struct iio_device *dev);
507 
508 
514 __api __pure struct iio_channel * iio_device_get_channel(
515  const struct iio_device *dev, unsigned int index);
516 
517 
523 __api __pure const char * iio_device_get_attr(
524  const struct iio_device *dev, unsigned int index);
525 
526 
535 __api __pure struct iio_channel * iio_device_find_channel(
536  const struct iio_device *dev, const char *name, bool output);
537 
538 
550 __api __pure const char * iio_device_find_attr(
551  const struct iio_device *dev, const char *name);
552 
553 
575  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
576  const char *attr, char *dst, size_t len);
577 
578 
589 __api int iio_device_attr_read_all(struct iio_device *dev,
590  int (*cb)(struct iio_device *dev, const char *attr,
591  const char *value, size_t len, void *d),
592  void *data);
593 
594 
602 __api int iio_device_attr_read_bool(const struct iio_device *dev,
603  const char *attr, bool *val);
604 
605 
613 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
614  const char *attr, long long *val);
615 
616 
624 __api int iio_device_attr_read_double(const struct iio_device *dev,
625  const char *attr, double *val);
626 
627 
646 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
647  const char *attr, const char *src);
648 
649 
658 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
659  const char *attr, const void *src, size_t len);
660 
661 
672 __api int iio_device_attr_write_all(struct iio_device *dev,
673  ssize_t (*cb)(struct iio_device *dev,
674  const char *attr, void *buf, size_t len, void *d),
675  void *data);
676 
677 
685 __api int iio_device_attr_write_bool(const struct iio_device *dev,
686  const char *attr, bool val);
687 
688 
696 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
697  const char *attr, long long val);
698 
699 
707 __api int iio_device_attr_write_double(const struct iio_device *dev,
708  const char *attr, double val);
709 
710 
714 __api void iio_device_set_data(struct iio_device *dev, void *data);
715 
716 
720 __api void * iio_device_get_data(const struct iio_device *dev);
721 
722 
730 __api int iio_device_get_trigger(const struct iio_device *dev,
731  const struct iio_device **trigger);
732 
733 
740 __api int iio_device_set_trigger(const struct iio_device *dev,
741  const struct iio_device *trigger);
742 
743 
747 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
748 
757 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
758  unsigned int nb_buffers);
759 /* ------------------------------------------------------------------*/
761 /* ------------------------- Channel functions -------------------------------*/
771 __api __pure const struct iio_device * iio_channel_get_device(
772  const struct iio_channel *chn);
773 
774 
778 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
779 
780 
786 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
787 
788 
792 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
793 
794 
802 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
803 
804 
808 __api __pure unsigned int iio_channel_get_attrs_count(
809  const struct iio_channel *chn);
810 
811 
817 __api __pure const char * iio_channel_get_attr(
818  const struct iio_channel *chn, unsigned int index);
819 
820 
832 __api __pure const char * iio_channel_find_attr(
833  const struct iio_channel *chn, const char *name);
834 
835 
842 __api __pure const char * iio_channel_attr_get_filename(
843  const struct iio_channel *chn, const char *attr);
844 
845 
867 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
868  const char *attr, char *dst, size_t len);
869 
870 
881 __api int iio_channel_attr_read_all(struct iio_channel *chn,
882  int (*cb)(struct iio_channel *chn,
883  const char *attr, const char *val, size_t len, void *d),
884  void *data);
885 
886 
894 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
895  const char *attr, bool *val);
896 
897 
905 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
906  const char *attr, long long *val);
907 
908 
916 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
917  const char *attr, double *val);
918 
919 
938 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
939  const char *attr, const char *src);
940 
941 
950 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
951  const char *attr, const void *src, size_t len);
952 
953 
964 __api int iio_channel_attr_write_all(struct iio_channel *chn,
965  ssize_t (*cb)(struct iio_channel *chn,
966  const char *attr, void *buf, size_t len, void *d),
967  void *data);
968 
969 
977 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
978  const char *attr, bool val);
979 
980 
988 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
989  const char *attr, long long val);
990 
991 
999 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
1000  const char *attr, double val);
1001 
1002 
1009 __api void iio_channel_enable(struct iio_channel *chn);
1010 
1011 
1014 __api void iio_channel_disable(struct iio_channel *chn);
1015 
1016 
1020 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
1021 
1022 
1030 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
1031  struct iio_buffer *buffer, void *dst, size_t len);
1032 
1033 
1041 __api size_t iio_channel_read(const struct iio_channel *chn,
1042  struct iio_buffer *buffer, void *dst, size_t len);
1043 
1044 
1052 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
1053  struct iio_buffer *buffer, const void *src, size_t len);
1054 
1055 
1063 __api size_t iio_channel_write(const struct iio_channel *chn,
1064  struct iio_buffer *buffer, const void *src, size_t len);
1065 
1066 
1070 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
1071 
1072 
1076 __api void * iio_channel_get_data(const struct iio_channel *chn);
1077 
1078 
1082 __api __pure enum iio_chan_type iio_channel_get_type(
1083  const struct iio_channel *chn);
1084 
1085 
1089 __api __pure enum iio_modifier iio_channel_get_modifier(
1090  const struct iio_channel *chn);
1091 
1092 /* ------------------------------------------------------------------*/
1094 /* ------------------------- Buffer functions --------------------------------*/
1104 __api __pure const struct iio_device * iio_buffer_get_device(
1105  const struct iio_buffer *buf);
1106 
1107 
1117 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
1118  size_t samples_count, bool cyclic);
1119 
1120 
1125 __api void iio_buffer_destroy(struct iio_buffer *buf);
1126 
1135 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
1136 
1148 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
1149 
1150 
1157 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
1158 
1159 
1166 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
1167 
1168 
1176 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
1177  size_t samples_count);
1178 
1202 __api void iio_buffer_cancel(struct iio_buffer *buf);
1203 
1204 
1208 __api void * iio_buffer_start(const struct iio_buffer *buf);
1209 
1210 
1226 __api void * iio_buffer_first(const struct iio_buffer *buf,
1227  const struct iio_channel *chn);
1228 
1229 
1234 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
1235 
1236 
1241 __api void * iio_buffer_end(const struct iio_buffer *buf);
1242 
1243 
1255 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
1256  ssize_t (*callback)(const struct iio_channel *chn,
1257  void *src, size_t bytes, void *d), void *data);
1258 
1259 
1263 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1264 
1265 
1269 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
1270 
1271 /* ------------------------------------------------------------------*/
1273 /* ------------------------- Low-level functions -----------------------------*/
1285  unsigned int length;
1286 
1288  unsigned int bits;
1289 
1291  unsigned int shift;
1292 
1295 
1298 
1300  bool is_be;
1301 
1304 
1306  double scale;
1307 
1309  unsigned int repeat;
1310 };
1311 
1312 
1320 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1321 
1322 
1327 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1328 
1329 
1333 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1334  const struct iio_channel *chn);
1335 
1336 
1342 __api void iio_channel_convert(const struct iio_channel *chn,
1343  void *dst, const void *src);
1344 
1345 
1351 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1352  void *dst, const void *src);
1353 
1354 
1358 __api __pure unsigned int iio_device_get_debug_attrs_count(
1359  const struct iio_device *dev);
1360 
1361 
1367 __api __pure const char * iio_device_get_debug_attr(
1368  const struct iio_device *dev, unsigned int index);
1369 
1370 
1383 __api __pure const char * iio_device_find_debug_attr(
1384  const struct iio_device *dev, const char *name);
1385 
1386 
1409 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1410  const char *attr, char *dst, size_t len);
1411 
1412 
1422 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1423  int (*cb)(struct iio_device *dev, const char *attr,
1424  const char *value, size_t len, void *d),
1425  void *data);
1426 
1427 
1447 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1448  const char *attr, const char *src);
1449 
1450 
1459 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1460  const char *attr, const void *src, size_t len);
1461 
1462 
1472 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1473  ssize_t (*cb)(struct iio_device *dev,
1474  const char *attr, void *buf, size_t len, void *d),
1475  void *data);
1476 
1477 
1485 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1486  const char *attr, bool *val);
1487 
1488 
1496 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1497  const char *attr, long long *val);
1498 
1499 
1507 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1508  const char *attr, double *val);
1509 
1510 
1518 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1519  const char *attr, bool val);
1520 
1521 
1529 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1530  const char *attr, long long val);
1531 
1532 
1540 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1541  const char *attr, double val);
1542 
1543 
1556 __api int iio_device_identify_filename(const struct iio_device *dev,
1557  const char *filename, struct iio_channel **chn,
1558  const char **attr);
1559 
1560 
1567 __api int iio_device_reg_write(struct iio_device *dev,
1568  uint32_t address, uint32_t value);
1569 
1570 
1577 __api int iio_device_reg_read(struct iio_device *dev,
1578  uint32_t address, uint32_t *value);
1579 
1580 
1583 #ifdef __cplusplus
1584 }
1585 #endif
1586 
1587 #undef __api
1588 
1589 #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:293
__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:357
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:303
__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:173
__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:851
__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:313
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:262
__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:178
__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:347
__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:1300
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:148
__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:303
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:1288
__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: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: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: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:1285
__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 __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:140
__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:867
__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: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:133
__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 __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: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:187
__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:372
__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:1294
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:327
__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:1309
__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:1303
__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:1306
__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:244
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 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: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:1297
__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:1291
__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:272
__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 __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: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:135
__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:130
__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 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:385
__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:1283
__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:254
__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:703
__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:337
__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 __pure unsigned int iio_context_get_attrs_count(const struct iio_context *ctx)
Get the number of context-specific attributes.
Definition: context.c:367
__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:859