libiio  0.7
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 <sys/types.h>
34 #include <stddef.h>
35 
36 #ifdef _MSC_BUILD
37 /* Come on Microsoft, time to get some C99... */
38 typedef long ssize_t;
39 #define _SSIZE_T_DEFINED
40 #endif
41 
42 #ifdef __GNUC__
43 #ifndef __cnst
44 #define __cnst __attribute__((const))
45 #endif
46 #ifndef __pure
47 #define __pure __attribute__((pure))
48 #endif
49 #define __notused __attribute__((unused))
50 #else
51 #define __cnst
52 #define __pure
53 #define __notused
54 #endif
55 
56 #ifdef _WIN32
57 # ifdef LIBIIO_EXPORTS
58 # define __api __declspec(dllexport)
59 # else
60 # define __api __declspec(dllimport)
61 # endif
62 #elif __GNUC__ >= 4
63 # define __api __attribute__((visibility ("default")))
64 #else
65 # define __api
66 #endif
67 
68 struct iio_context;
69 struct iio_device;
70 struct iio_channel;
71 struct iio_buffer;
72 
73 struct iio_context_info;
74 struct iio_scan_context;
75 
84  IIO_VOLTAGE,
85  IIO_CURRENT,
86  IIO_POWER,
87  IIO_ACCEL,
88  IIO_ANGL_VEL,
89  IIO_MAGN,
90  IIO_LIGHT,
91  IIO_INTENSITY,
92  IIO_PROXIMITY,
93  IIO_TEMP,
94  IIO_INCLI,
95  IIO_ROT,
96  IIO_ANGL,
97  IIO_TIMESTAMP,
98  IIO_CAPACITANCE,
99  IIO_ALTVOLTAGE,
100  IIO_CCT,
101  IIO_PRESSURE,
102  IIO_HUMIDITYRELATIVE,
103  IIO_ACTIVITY,
104  IIO_STEPS,
105  IIO_ENERGY,
106  IIO_DISTANCE,
107  IIO_VELOCITY,
108  IIO_CONCENTRATION,
109  IIO_RESISTANCE,
110  IIO_PH,
111  IIO_CHAN_TYPE_UNKNOWN = INT_MAX
112 };
113 
122  IIO_NO_MOD,
123  IIO_MOD_X,
124  IIO_MOD_Y,
125  IIO_MOD_Z,
126  IIO_MOD_X_AND_Y,
127  IIO_MOD_X_AND_Z,
128  IIO_MOD_Y_AND_Z,
129  IIO_MOD_X_AND_Y_AND_Z,
130  IIO_MOD_X_OR_Y,
131  IIO_MOD_X_OR_Z,
132  IIO_MOD_Y_OR_Z,
133  IIO_MOD_X_OR_Y_OR_Z,
134  IIO_MOD_LIGHT_BOTH,
135  IIO_MOD_LIGHT_IR,
136  IIO_MOD_ROOT_SUM_SQUARED_X_Y,
137  IIO_MOD_SUM_SQUARED_X_Y_Z,
138  IIO_MOD_LIGHT_CLEAR,
139  IIO_MOD_LIGHT_RED,
140  IIO_MOD_LIGHT_GREEN,
141  IIO_MOD_LIGHT_BLUE,
142  IIO_MOD_QUATERNION,
143  IIO_MOD_TEMP_AMBIENT,
144  IIO_MOD_TEMP_OBJECT,
145  IIO_MOD_NORTH_MAGN,
146  IIO_MOD_NORTH_TRUE,
147  IIO_MOD_NORTH_MAGN_TILT_COMP,
148  IIO_MOD_NORTH_TRUE_TILT_COMP,
149  IIO_MOD_RUNNING,
150  IIO_MOD_JOGGING,
151  IIO_MOD_WALKING,
152  IIO_MOD_STILL,
153  IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
154  IIO_MOD_I,
155  IIO_MOD_Q,
156  IIO_MOD_CO2,
157  IIO_MOD_VOC,
158 };
159 
160 /* ---------------------------------------------------------------------------*/
161 /* ------------------------- Scan functions ----------------------------------*/
178 __api struct iio_scan_context * iio_create_scan_context(
179  const char *backend, unsigned int flags);
180 
181 
186 __api void iio_scan_context_destroy(struct iio_scan_context *ctx);
187 
188 
196 __api ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx,
197  struct iio_context_info ***info);
198 
199 
203 __api void iio_context_info_list_free(struct iio_context_info **info);
204 
205 
210 __api __pure const char * iio_context_info_get_description(
211  const struct iio_context_info *info);
212 
213 
218 __api __pure const char * iio_context_info_get_uri(
219  const struct iio_context_info *info);
220 
221 /* ------------------------------------------------------------------*/
223 /* ------------------------- Top-level functions -----------------------------*/
232 __api void iio_library_get_version(unsigned int *major,
233  unsigned int *minor, char git_tag[8]);
234 
235 
241 __api void iio_strerror(int err, char *dst, size_t len);
242 
243 /* ------------------------------------------------------------------*/
245 /* ------------------------- Context functions -------------------------------*/
261 __api struct iio_context * iio_create_default_context(void);
262 
263 
267 __api struct iio_context * iio_create_local_context(void);
268 
269 
277 __api struct iio_context * iio_create_xml_context(const char *xml_file);
278 
279 
289  const char *xml, size_t len);
290 
291 
296 __api struct iio_context * iio_create_network_context(const char *host);
297 
298 
303 __api struct iio_context * iio_create_context_from_uri(const char *uri);
304 
305 
310 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
311 
312 
317 __api void iio_context_destroy(struct iio_context *ctx);
318 
319 
327 __api int iio_context_get_version(const struct iio_context *ctx,
328  unsigned int *major, unsigned int *minor, char git_tag[8]);
329 
330 
334 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
335 
336 
344 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
345 
346 
353 __api __pure const char * iio_context_get_description(
354  const struct iio_context *ctx);
355 
356 
360 __api __pure unsigned int iio_context_get_devices_count(
361  const struct iio_context *ctx);
362 
363 
369 __api __pure struct iio_device * iio_context_get_device(
370  const struct iio_context *ctx, unsigned int index);
371 
372 
380 __api __pure struct iio_device * iio_context_find_device(
381  const struct iio_context *ctx, const char *name);
382 
383 
391 __api int iio_context_set_timeout(
392  struct iio_context *ctx, unsigned int timeout_ms);
393 
394 /* ------------------------------------------------------------------*/
396 /* ------------------------- Device functions --------------------------------*/
406 __api __pure const struct iio_context * iio_device_get_context(
407  const struct iio_device *dev);
408 
409 
413 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
414 
415 
421 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
422 
423 
427 __api __pure unsigned int iio_device_get_channels_count(
428  const struct iio_device *dev);
429 
430 
434 __api __pure unsigned int iio_device_get_attrs_count(
435  const struct iio_device *dev);
436 
437 
443 __api __pure struct iio_channel * iio_device_get_channel(
444  const struct iio_device *dev, unsigned int index);
445 
446 
452 __api __pure const char * iio_device_get_attr(
453  const struct iio_device *dev, unsigned int index);
454 
455 
464 __api __pure struct iio_channel * iio_device_find_channel(
465  const struct iio_device *dev, const char *name, bool output);
466 
467 
479 __api __pure const char * iio_device_find_attr(
480  const struct iio_device *dev, const char *name);
481 
482 
504  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
505  const char *attr, char *dst, size_t len);
506 
507 
518 __api int iio_device_attr_read_all(struct iio_device *dev,
519  int (*cb)(struct iio_device *dev, const char *attr,
520  const char *value, size_t len, void *d),
521  void *data);
522 
523 
531 __api int iio_device_attr_read_bool(const struct iio_device *dev,
532  const char *attr, bool *val);
533 
534 
542 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
543  const char *attr, long long *val);
544 
545 
553 __api int iio_device_attr_read_double(const struct iio_device *dev,
554  const char *attr, double *val);
555 
556 
575 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
576  const char *attr, const char *src);
577 
578 
587 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
588  const char *attr, const void *src, size_t len);
589 
590 
601 __api int iio_device_attr_write_all(struct iio_device *dev,
602  ssize_t (*cb)(struct iio_device *dev,
603  const char *attr, void *buf, size_t len, void *d),
604  void *data);
605 
606 
614 __api int iio_device_attr_write_bool(const struct iio_device *dev,
615  const char *attr, bool val);
616 
617 
625 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
626  const char *attr, long long val);
627 
628 
636 __api int iio_device_attr_write_double(const struct iio_device *dev,
637  const char *attr, double val);
638 
639 
643 __api void iio_device_set_data(struct iio_device *dev, void *data);
644 
645 
649 __api void * iio_device_get_data(const struct iio_device *dev);
650 
651 
659 __api int iio_device_get_trigger(const struct iio_device *dev,
660  const struct iio_device **trigger);
661 
662 
669 __api int iio_device_set_trigger(const struct iio_device *dev,
670  const struct iio_device *trigger);
671 
672 
676 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
677 
686 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
687  unsigned int nb_buffers);
688 /* ------------------------------------------------------------------*/
690 /* ------------------------- Channel functions -------------------------------*/
700 __api __pure const struct iio_device * iio_channel_get_device(
701  const struct iio_channel *chn);
702 
703 
707 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
708 
709 
715 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
716 
717 
721 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
722 
723 
731 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
732 
733 
737 __api __pure unsigned int iio_channel_get_attrs_count(
738  const struct iio_channel *chn);
739 
740 
746 __api __pure const char * iio_channel_get_attr(
747  const struct iio_channel *chn, unsigned int index);
748 
749 
761 __api __pure const char * iio_channel_find_attr(
762  const struct iio_channel *chn, const char *name);
763 
764 
771 __api __pure const char * iio_channel_attr_get_filename(
772  const struct iio_channel *chn, const char *attr);
773 
774 
796 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
797  const char *attr, char *dst, size_t len);
798 
799 
810 __api int iio_channel_attr_read_all(struct iio_channel *chn,
811  int (*cb)(struct iio_channel *chn,
812  const char *attr, const char *val, size_t len, void *d),
813  void *data);
814 
815 
823 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
824  const char *attr, bool *val);
825 
826 
834 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
835  const char *attr, long long *val);
836 
837 
845 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
846  const char *attr, double *val);
847 
848 
867 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
868  const char *attr, const char *src);
869 
870 
879 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
880  const char *attr, const void *src, size_t len);
881 
882 
893 __api int iio_channel_attr_write_all(struct iio_channel *chn,
894  ssize_t (*cb)(struct iio_channel *chn,
895  const char *attr, void *buf, size_t len, void *d),
896  void *data);
897 
898 
906 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
907  const char *attr, bool val);
908 
909 
917 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
918  const char *attr, long long val);
919 
920 
928 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
929  const char *attr, double val);
930 
931 
938 __api void iio_channel_enable(struct iio_channel *chn);
939 
940 
943 __api void iio_channel_disable(struct iio_channel *chn);
944 
945 
949 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
950 
951 
959 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
960  struct iio_buffer *buffer, void *dst, size_t len);
961 
962 
970 __api size_t iio_channel_read(const struct iio_channel *chn,
971  struct iio_buffer *buffer, void *dst, size_t len);
972 
973 
981 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
982  struct iio_buffer *buffer, const void *src, size_t len);
983 
984 
992 __api size_t iio_channel_write(const struct iio_channel *chn,
993  struct iio_buffer *buffer, const void *src, size_t len);
994 
995 
999 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
1000 
1001 
1005 __api void * iio_channel_get_data(const struct iio_channel *chn);
1006 
1007 
1011 __api __pure enum iio_chan_type iio_channel_get_type(
1012  const struct iio_channel *chn);
1013 
1014 
1018 __api __pure enum iio_modifier iio_channel_get_modifier(
1019  const struct iio_channel *chn);
1020 
1021 /* ------------------------------------------------------------------*/
1023 /* ------------------------- Buffer functions --------------------------------*/
1033 __api __pure const struct iio_device * iio_buffer_get_device(
1034  const struct iio_buffer *buf);
1035 
1036 
1046 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
1047  size_t samples_count, bool cyclic);
1048 
1049 
1054 __api void iio_buffer_destroy(struct iio_buffer *buf);
1055 
1064 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
1065 
1077 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
1078 
1079 
1086 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
1087 
1088 
1095 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
1096 
1097 
1105 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
1106  size_t samples_count);
1107 
1131 __api void iio_buffer_cancel(struct iio_buffer *buf);
1132 
1133 
1137 __api void * iio_buffer_start(const struct iio_buffer *buf);
1138 
1139 
1155 __api void * iio_buffer_first(const struct iio_buffer *buf,
1156  const struct iio_channel *chn);
1157 
1158 
1163 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
1164 
1165 
1170 __api void * iio_buffer_end(const struct iio_buffer *buf);
1171 
1172 
1183 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
1184  ssize_t (*callback)(const struct iio_channel *chn,
1185  void *src, size_t bytes, void *d), void *data);
1186 
1187 
1191 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1192 
1193 
1197 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
1198 
1199 /* ------------------------------------------------------------------*/
1201 /* ------------------------- Low-level functions -----------------------------*/
1213  unsigned int length;
1214 
1216  unsigned int bits;
1217 
1219  unsigned int shift;
1220 
1223 
1226 
1228  bool is_be;
1229 
1232 
1234  double scale;
1235 };
1236 
1237 
1245 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1246 
1247 
1252 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1253 
1254 
1258 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1259  const struct iio_channel *chn);
1260 
1261 
1267 __api void iio_channel_convert(const struct iio_channel *chn,
1268  void *dst, const void *src);
1269 
1270 
1276 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1277  void *dst, const void *src);
1278 
1279 
1283 __api __pure unsigned int iio_device_get_debug_attrs_count(
1284  const struct iio_device *dev);
1285 
1286 
1292 __api __pure const char * iio_device_get_debug_attr(
1293  const struct iio_device *dev, unsigned int index);
1294 
1295 
1308 __api __pure const char * iio_device_find_debug_attr(
1309  const struct iio_device *dev, const char *name);
1310 
1311 
1334 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1335  const char *attr, char *dst, size_t len);
1336 
1337 
1347 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1348  int (*cb)(struct iio_device *dev, const char *attr,
1349  const char *value, size_t len, void *d),
1350  void *data);
1351 
1352 
1372 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1373  const char *attr, const char *src);
1374 
1375 
1384 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1385  const char *attr, const void *src, size_t len);
1386 
1387 
1397 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1398  ssize_t (*cb)(struct iio_device *dev,
1399  const char *attr, void *buf, size_t len, void *d),
1400  void *data);
1401 
1402 
1410 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1411  const char *attr, bool *val);
1412 
1413 
1421 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1422  const char *attr, long long *val);
1423 
1424 
1432 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1433  const char *attr, double *val);
1434 
1435 
1443 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1444  const char *attr, bool val);
1445 
1446 
1454 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1455  const char *attr, long long val);
1456 
1457 
1465 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1466  const char *attr, double val);
1467 
1468 
1481 __api int iio_device_identify_filename(const struct iio_device *dev,
1482  const char *filename, struct iio_channel **chn,
1483  const char **attr);
1484 
1485 
1492 __api int iio_device_reg_write(struct iio_device *dev,
1493  uint32_t address, uint32_t value);
1494 
1495 
1502 __api int iio_device_reg_read(struct iio_device *dev,
1503  uint32_t address, uint32_t *value);
1504 
1505 
1508 #ifdef __cplusplus
1509 }
1510 #endif
1511 
1512 #undef __api
1513 
1514 #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:37
__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:603
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:283
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:381
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:392
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:350
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:296
__api __pure unsigned int iio_context_get_devices_count(const struct iio_context *ctx)
Enumerate the devices found in the given context.
Definition: context.c:166
__api int iio_device_attr_write_double(const struct iio_device *dev, const char *attr, double val)
Set the value of the given device-specific attribute.
Definition: device.c:507
__api int iio_device_debug_attr_write_all(struct iio_device *dev, ssize_t(*cb)(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d), void *data)
Set the values of all debug attributes.
Definition: device.c:847
__api __pure const struct iio_device * iio_channel_get_device(const struct iio_channel *chn)
Retrieve a pointer to the iio_device structure.
Definition: channel.c:801
__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:303
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:255
__api __pure struct iio_device * iio_context_get_device(const struct iio_context *ctx, unsigned int index)
Get the device present at the given index.
Definition: context.c:171
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:572
__api struct iio_context * iio_create_xml_context_mem(const char *xml, size_t len)
Create a context from XML data in memory.
Definition: context.c:340
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:298
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:1228
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:149
__api int iio_device_reg_write(struct iio_device *dev, uint32_t address, uint32_t value)
Set the value of a hardware register.
Definition: device.c:687
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:293
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:1216
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:289
__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:545
__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:129
__api __pure const char * iio_device_get_debug_attr(const struct iio_device *dev, unsigned int index)
Get the debug attribute present at the given index.
Definition: device.c:563
__api int iio_device_get_trigger(const struct iio_device *dev, const struct iio_device **trigger)
Retrieve the trigger of a given device.
Definition: device.c:379
__api int iio_device_debug_attr_write_double(const struct iio_device *dev, const char *attr, double val)
Set the value of the given debug attribute.
Definition: device.c:623
__api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn)
Return True if the given channel is a scan element.
Definition: channel.c:304
__api __pure const char * iio_device_get_attr(const struct iio_device *dev, unsigned int index)
Get the device-specific attribute present at the given index.
Definition: device.c:215
__api __pure unsigned int iio_device_get_debug_attrs_count(const struct iio_device *dev)
Enumerate the debug attributes of the given device.
Definition: device.c:558
Represents an input or output channel of a device.
__api __cnst const struct iio_data_format * iio_channel_get_data_format(const struct iio_channel *chn)
Get a pointer to a channel&#39;s data format structure.
Definition: channel.c:386
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:1213
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:288
__api __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:141
__api __pure const char * iio_device_find_attr(const struct iio_device *dev, const char *name)
Try to find a device-specific attribute by its name.
Definition: device.c:224
Represents a device in the IIO context.
__api __pure const struct iio_context * iio_device_get_context(const struct iio_device *dev)
Retrieve a pointer to the iio_context structure.
Definition: device.c:863
__api void iio_scan_context_destroy(struct iio_scan_context *ctx)
Destroy the given scan context.
Definition: scan.c:157
__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:706
__api ssize_t iio_device_attr_write(const struct iio_device *dev, const char *attr, const char *src)
Set the value of the given device-specific attribute.
Definition: device.c:340
__api int iio_device_debug_attr_write_bool(const struct iio_device *dev, const char *attr, bool val)
Set the value of the given debug attribute.
Definition: device.c:635
__api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn, const char *attr, const void *src, size_t len)
Set the value of the given channel-specific attribute.
Definition: channel.c:355
__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:319
iio_modifier
IIO channel modifier.
Definition: iio.h:121
__api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev, const char *attr, const void *src, size_t len)
Set the value of the given debug attribute.
Definition: device.c:542
__api void iio_buffer_destroy(struct iio_buffer *buf)
Destroy the given buffer.
Definition: buffer.c:110
__api __pure const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition: channel.c:294
__api ssize_t iio_buffer_refill(struct iio_buffer *buf)
Fetch more samples from the hardware.
Definition: buffer.c:129
__api __pure const char * iio_channel_find_attr(const struct iio_channel *chn, const char *name)
Try to find a channel-specific attribute by its name.
Definition: channel.c:333
__api ssize_t iio_device_debug_attr_write(const struct iio_device *dev, const char *attr, const char *src)
Set the value of the given debug attribute.
Definition: device.c:552
__api ssize_t iio_buffer_push_partial(struct iio_buffer *buf, size_t samples_count)
Send a given number of samples to the hardware.
Definition: buffer.c:186
__api int iio_device_attr_read_longlong(const struct iio_device *dev, const char *attr, long long *val)
Read the content of the given device-specific attribute.
Definition: device.c:456
__api __pure struct iio_device * iio_context_find_device(const struct iio_context *ctx, const char *name)
Try to find a device structure by its name of ID.
Definition: context.c:180
__api ssize_t iio_channel_attr_write(const struct iio_channel *chn, const char *attr, const char *src)
Set the value of the given channel-specific attribute.
Definition: channel.c:365
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:1222
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:320
__api void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:245
__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:31
bool with_scale
Contains True if the sample should be scaled when converted.
Definition: iio.h:1231
__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:324
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:1234
__api int iio_device_attr_read_double(const struct iio_device *dev, const char *attr, double *val)
Read the content of the given device-specific attribute.
Definition: device.c:484
__api int iio_device_attr_read_bool(const struct iio_device *dev, const char *attr, bool *val)
Read the content of the given device-specific attribute.
Definition: device.c:472
__api int iio_device_debug_attr_read_all(struct iio_device *dev, int(*cb)(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d), void *data)
Read the content of all debug attributes.
__api ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, struct iio_context_info ***info)
Enumerate available contexts.
Definition: scan.c:43
__api int iio_context_get_version(const struct iio_context *ctx, unsigned int *major, unsigned int *minor, char git_tag[8])
Get the version of the backend in use.
Definition: context.c:237
iio_chan_type
IIO channel type.
Definition: iio.h:83
__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:250
__api void iio_buffer_cancel(struct iio_buffer *buf)
Cancel all buffer operations.
Definition: buffer.c:308
__api __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:170
__api ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:451
__api void iio_channel_convert(const struct iio_channel *chn, void *dst, const void *src)
Convert the sample from hardware format to host format.
Definition: channel.c:519
__api int iio_device_debug_attr_write_longlong(const struct iio_device *dev, const char *attr, long long val)
Set the value of the given debug attribute.
Definition: device.c:611
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:376
__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:683
__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:650
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:371
__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:1225
__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:695
__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:1219
__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:662
__api struct iio_context * iio_create_context_from_uri(const char *uri)
Create a context from a URI description.
Definition: context.c:265
__api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking)
Make iio_buffer_refill() and iio_buffer_push() blocking or not.
Definition: buffer.c:124
__api int iio_device_attr_write_longlong(const struct iio_device *dev, const char *attr, long long val)
Set the value of the given device-specific attribute.
Definition: device.c:495
__api __pure unsigned int iio_device_get_attrs_count(const struct iio_device *dev)
Enumerate the device-specific attributes of the given device.
Definition: device.c:210
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:75
__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:314
__api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev, size_t samples_count, bool cyclic)
Create an input or output buffer associated to the given device.
Definition: buffer.c:41
__api void iio_channel_enable(struct iio_channel *chn)
Enable the given channel.
Definition: channel.c:398
__api int iio_device_attr_write_bool(const struct iio_device *dev, const char *attr, bool val)
Set the value of the given device-specific attribute.
Definition: device.c:519
__api __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:136
__api void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:404
__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:758
__api int iio_device_debug_attr_read_longlong(const struct iio_device *dev, const char *attr, long long *val)
Read the content of the given debug attribute.
Definition: device.c:572
__api ssize_t iio_device_debug_attr_read(const struct iio_device *dev, const char *attr, char *dst, size_t len)
Read the content of the given debug attribute.
Definition: device.c:532
__api __pure struct iio_channel * iio_device_get_channel(const struct iio_device *dev, unsigned int index)
Get the channel present at the given index.
Definition: device.c:185
__api int iio_device_set_trigger(const struct iio_device *dev, const struct iio_device *trigger)
Associate a trigger to a given device.
Definition: device.c:390
__api __pure const char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition: context.c:131
__api int iio_channel_attr_write_longlong(const struct iio_channel *chn, const char *attr, long long val)
Set the value of the given channel-specific attribute.
Definition: channel.c:673
__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:309
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:587
__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:588
__api __pure struct iio_channel * iio_device_find_channel(const struct iio_device *dev, const char *name, bool output)
Try to find a channel structure by its name of ID.
Definition: device.c:194
__api int iio_device_identify_filename(const struct iio_device *dev, const char *filename, struct iio_channel **chn, const char **attr)
Identify the channel or debug attribute corresponding to a filename.
Definition: device.c:648
__api __pure bool iio_channel_is_output(const struct iio_channel *chn)
Return True if the given channel is an output channel.
Definition: channel.c:299
__api int iio_buffer_get_poll_fd(struct iio_buffer *buf)
Get a pollable file descriptor.
Definition: buffer.c:119
__api size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Definition: channel.c:618
__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:634
Contains the format of a data sample.
Definition: iio.h:1211
__api ssize_t iio_buffer_push(struct iio_buffer *buf)
Send the samples to the hardware.
Definition: buffer.c:150
__api ssize_t iio_channel_attr_read(const struct iio_channel *chn, const char *attr, char *dst, size_t len)
Read the content of the given channel-specific attribute.
Definition: channel.c:345
__api int iio_device_debug_attr_read_double(const struct iio_device *dev, const char *attr, double *val)
Read the content of the given debug attribute.
Definition: device.c:600
Contains the representation of an IIO context.
__api int iio_context_set_timeout(struct iio_context *ctx, unsigned int timeout_ms)
Set a timeout for I/O operations.
Definition: context.c:247
__api int iio_device_reg_read(struct iio_device *dev, uint32_t address, uint32_t *value)
Get the value of a hardware register.
Definition: device.c:699
__api int iio_channel_attr_read_all(struct iio_channel *chn, int(*cb)(struct iio_channel *chn, const char *attr, const char *val, size_t len, void *d), void *data)
Read the content of all channel-specific attributes.
Definition: channel.c:717
__api ssize_t iio_device_attr_write_raw(const struct iio_device *dev, const char *attr, const void *src, size_t len)
Set the value of the given device-specific attribute.
Definition: device.c:330
__api struct iio_context * iio_create_network_context(const char *host)
Create a context from the network.
Definition: context.c:330
__api int iio_device_set_kernel_buffers_count(const struct iio_device *dev, unsigned int nb_buffers)
Configure the number of kernel buffers for a device.
Definition: device.c:368
__api int iio_device_attr_write_all(struct iio_device *dev, ssize_t(*cb)(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d), void *data)
Set the values of all device-specific attributes.
Definition: device.c:855