libiio  0.6
Library for interfacing with IIO devices
/build/libiio-4l6Jp6/libiio-0.6.40/iio.h
Go to the documentation of this file.
1 /*
2  * libiio - Library for interfacing industrial I/O (IIO) devices
3  *
4  * Copyright (C) 2014 Analog Devices, Inc.
5  * Author: Paul Cercueil <paul.cercueil@analog.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * */
18 
22 #ifndef __IIO_H__
23 #define __IIO_H__
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include <stdlib.h>
32 #include <sys/types.h>
33 #include <stddef.h>
34 
35 #ifdef _MSC_BUILD
36 /* Come on Microsoft, time to get some C99... */
37 typedef long ssize_t;
38 #define _SSIZE_T_DEFINED
39 #endif
40 
41 #ifdef __GNUC__
42 #define __cnst __attribute__((const))
43 #define __pure __attribute__((pure))
44 #define __notused __attribute__((unused))
45 #else
46 #define __cnst
47 #define __pure
48 #define __notused
49 #endif
50 
51 #ifdef _WIN32
52 # ifdef LIBIIO_EXPORTS
53 # define __api __declspec(dllexport)
54 # else
55 # define __api __declspec(dllimport)
56 # endif
57 #elif __GNUC__ >= 4
58 # define __api __attribute__((visibility ("default")))
59 #else
60 # define __api
61 #endif
62 
63 struct iio_context;
64 struct iio_device;
65 struct iio_channel;
66 struct iio_buffer;
67 
68 
69 /* ---------------------------------------------------------------------------*/
70 /* ------------------------- Top-level functions -----------------------------*/
79 __api void iio_library_get_version(unsigned int *major,
80  unsigned int *minor, char git_tag[8]);
81 
82 
88 __api void iio_strerror(int err, char *dst, size_t len);
89 
90 /* ------------------------------------------------------------------*/
92 /* ------------------------- Context functions -------------------------------*/
108 __api struct iio_context * iio_create_default_context(void);
109 
110 
114 __api struct iio_context * iio_create_local_context(void);
115 
116 
124 __api struct iio_context * iio_create_xml_context(const char *xml_file);
125 
126 
136  const char *xml, size_t len);
137 
138 
143 __api struct iio_context * iio_create_network_context(const char *host);
144 
145 
151 __api struct iio_context * iio_create_usb_context(
152  unsigned short vid, unsigned short pid);
153 
154 
159 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
160 
161 
166 __api void iio_context_destroy(struct iio_context *ctx);
167 
168 
176 __api int iio_context_get_version(const struct iio_context *ctx,
177  unsigned int *major, unsigned int *minor, char git_tag[8]);
178 
179 
183 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
184 
185 
193 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
194 
195 
202 __api __pure const char * iio_context_get_description(
203  const struct iio_context *ctx);
204 
205 
209 __api __pure unsigned int iio_context_get_devices_count(
210  const struct iio_context *ctx);
211 
212 
218 __api __pure struct iio_device * iio_context_get_device(
219  const struct iio_context *ctx, unsigned int index);
220 
221 
229 __api __pure struct iio_device * iio_context_find_device(
230  const struct iio_context *ctx, const char *name);
231 
232 
239 __api int iio_context_set_timeout(
240  struct iio_context *ctx, unsigned int timeout_ms);
241 
242 /* ------------------------------------------------------------------*/
244 /* ------------------------- Device functions --------------------------------*/
254 __api __pure const struct iio_context * iio_device_get_context(
255  const struct iio_device *dev);
256 
257 
261 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
262 
263 
269 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
270 
271 
275 __api __pure unsigned int iio_device_get_channels_count(
276  const struct iio_device *dev);
277 
278 
282 __api __pure unsigned int iio_device_get_attrs_count(
283  const struct iio_device *dev);
284 
285 
291 __api __pure struct iio_channel * iio_device_get_channel(
292  const struct iio_device *dev, unsigned int index);
293 
294 
300 __api __pure const char * iio_device_get_attr(
301  const struct iio_device *dev, unsigned int index);
302 
303 
312 __api __pure struct iio_channel * iio_device_find_channel(
313  const struct iio_device *dev, const char *name, bool output);
314 
315 
327 __api __pure const char * iio_device_find_attr(
328  const struct iio_device *dev, const char *name);
329 
330 
352  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
353  const char *attr, char *dst, size_t len);
354 
355 
366 __api int iio_device_attr_read_all(struct iio_device *dev,
367  int (*cb)(struct iio_device *dev, const char *attr,
368  const char *value, size_t len, void *d),
369  void *data);
370 
371 
379 __api int iio_device_attr_read_bool(const struct iio_device *dev,
380  const char *attr, bool *val);
381 
382 
390 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
391  const char *attr, long long *val);
392 
393 
401 __api int iio_device_attr_read_double(const struct iio_device *dev,
402  const char *attr, double *val);
403 
404 
423 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
424  const char *attr, const char *src);
425 
426 
435 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
436  const char *attr, const void *src, size_t len);
437 
438 
449 __api int iio_device_attr_write_all(struct iio_device *dev,
450  ssize_t (*cb)(struct iio_device *dev,
451  const char *attr, void *buf, size_t len, void *d),
452  void *data);
453 
454 
462 __api int iio_device_attr_write_bool(const struct iio_device *dev,
463  const char *attr, bool val);
464 
465 
473 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
474  const char *attr, long long val);
475 
476 
484 __api int iio_device_attr_write_double(const struct iio_device *dev,
485  const char *attr, double val);
486 
487 
491 __api void iio_device_set_data(struct iio_device *dev, void *data);
492 
493 
497 __api void * iio_device_get_data(const struct iio_device *dev);
498 
499 
507 __api int iio_device_get_trigger(const struct iio_device *dev,
508  const struct iio_device **trigger);
509 
510 
517 __api int iio_device_set_trigger(const struct iio_device *dev,
518  const struct iio_device *trigger);
519 
520 
524 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
525 
534 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
535  unsigned int nb_buffers);
536 /* ------------------------------------------------------------------*/
538 /* ------------------------- Channel functions -------------------------------*/
548 __api __pure const struct iio_device * iio_channel_get_device(
549  const struct iio_channel *chn);
550 
551 
555 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
556 
557 
563 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
564 
565 
569 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
570 
571 
579 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
580 
581 
585 __api __pure unsigned int iio_channel_get_attrs_count(
586  const struct iio_channel *chn);
587 
588 
594 __api __pure const char * iio_channel_get_attr(
595  const struct iio_channel *chn, unsigned int index);
596 
597 
609 __api __pure const char * iio_channel_find_attr(
610  const struct iio_channel *chn, const char *name);
611 
612 
619 __api __pure const char * iio_channel_attr_get_filename(
620  const struct iio_channel *chn, const char *attr);
621 
622 
644 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
645  const char *attr, char *dst, size_t len);
646 
647 
658 __api int iio_channel_attr_read_all(struct iio_channel *chn,
659  int (*cb)(struct iio_channel *chn,
660  const char *attr, const char *val, size_t len, void *d),
661  void *data);
662 
663 
671 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
672  const char *attr, bool *val);
673 
674 
682 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
683  const char *attr, long long *val);
684 
685 
693 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
694  const char *attr, double *val);
695 
696 
715 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
716  const char *attr, const char *src);
717 
718 
727 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
728  const char *attr, const void *src, size_t len);
729 
730 
741 __api int iio_channel_attr_write_all(struct iio_channel *chn,
742  ssize_t (*cb)(struct iio_channel *chn,
743  const char *attr, void *buf, size_t len, void *d),
744  void *data);
745 
746 
754 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
755  const char *attr, bool val);
756 
757 
765 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
766  const char *attr, long long val);
767 
768 
776 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
777  const char *attr, double val);
778 
779 
786 __api void iio_channel_enable(struct iio_channel *chn);
787 
788 
791 __api void iio_channel_disable(struct iio_channel *chn);
792 
793 
797 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
798 
799 
807 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
808  struct iio_buffer *buffer, void *dst, size_t len);
809 
810 
818 __api size_t iio_channel_read(const struct iio_channel *chn,
819  struct iio_buffer *buffer, void *dst, size_t len);
820 
821 
829 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
830  struct iio_buffer *buffer, const void *src, size_t len);
831 
832 
840 __api size_t iio_channel_write(const struct iio_channel *chn,
841  struct iio_buffer *buffer, const void *src, size_t len);
842 
843 
847 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
848 
849 
853 __api void * iio_channel_get_data(const struct iio_channel *chn);
854 
855 /* ------------------------------------------------------------------*/
857 /* ------------------------- Buffer functions --------------------------------*/
867 __api __pure const struct iio_device * iio_buffer_get_device(
868  const struct iio_buffer *buf);
869 
870 
880 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
881  size_t samples_count, bool cyclic);
882 
883 
888 __api void iio_buffer_destroy(struct iio_buffer *buf);
889 
898 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
899 
911 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
912 
913 
920 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
921 
922 
929 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
930 
931 
939 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
940  size_t samples_count);
941 
942 
946 __api void * iio_buffer_start(const struct iio_buffer *buf);
947 
948 
964 __api void * iio_buffer_first(const struct iio_buffer *buf,
965  const struct iio_channel *chn);
966 
967 
972 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
973 
974 
979 __api void * iio_buffer_end(const struct iio_buffer *buf);
980 
981 
992 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
993  ssize_t (*callback)(const struct iio_channel *chn,
994  void *src, size_t bytes, void *d), void *data);
995 
996 
1000 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1001 
1002 
1006 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
1007 
1008 /* ------------------------------------------------------------------*/
1010 /* ------------------------- Low-level functions -----------------------------*/
1022  unsigned int length;
1023 
1025  unsigned int bits;
1026 
1028  unsigned int shift;
1029 
1032 
1035 
1037  bool is_be;
1038 
1041 
1043  double scale;
1044 };
1045 
1046 
1054 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1055 
1056 
1061 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1062 
1063 
1067 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1068  const struct iio_channel *chn);
1069 
1070 
1076 __api void iio_channel_convert(const struct iio_channel *chn,
1077  void *dst, const void *src);
1078 
1079 
1085 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1086  void *dst, const void *src);
1087 
1088 
1092 __api __pure unsigned int iio_device_get_debug_attrs_count(
1093  const struct iio_device *dev);
1094 
1095 
1101 __api __pure const char * iio_device_get_debug_attr(
1102  const struct iio_device *dev, unsigned int index);
1103 
1104 
1117 __api __pure const char * iio_device_find_debug_attr(
1118  const struct iio_device *dev, const char *name);
1119 
1120 
1143 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1144  const char *attr, char *dst, size_t len);
1145 
1146 
1156 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1157  int (*cb)(struct iio_device *dev, const char *attr,
1158  const char *value, size_t len, void *d),
1159  void *data);
1160 
1161 
1181 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1182  const char *attr, const char *src);
1183 
1184 
1193 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1194  const char *attr, const void *src, size_t len);
1195 
1196 
1206 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1207  ssize_t (*cb)(struct iio_device *dev,
1208  const char *attr, void *buf, size_t len, void *d),
1209  void *data);
1210 
1211 
1219 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1220  const char *attr, bool *val);
1221 
1222 
1230 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1231  const char *attr, long long *val);
1232 
1233 
1241 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1242  const char *attr, double *val);
1243 
1244 
1252 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1253  const char *attr, bool val);
1254 
1255 
1263 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1264  const char *attr, long long val);
1265 
1266 
1274 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1275  const char *attr, double val);
1276 
1277 
1290 __api int iio_device_identify_filename(const struct iio_device *dev,
1291  const char *filename, struct iio_channel **chn,
1292  const char **attr);
1293 
1294 
1301 __api int iio_device_reg_write(struct iio_device *dev,
1302  uint32_t address, uint32_t value);
1303 
1304 
1311 __api int iio_device_reg_read(struct iio_device *dev,
1312  uint32_t address, uint32_t *value);
1313 
1314 
1317 #ifdef __cplusplus
1318 }
1319 #endif
1320 
1321 #endif /* __IIO_H__ */
__api ssize_t iio_device_attr_read(const struct iio_device *dev, const char *attr, char *dst, size_t len)
Read the content of the given device-specific attribute.
Definition: device.c:330
__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:469
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:281
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:247
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:258
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:334
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:280
__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:517
__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:857
__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:667
__api __pure const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:185
__api __pure const struct iio_device * iio_buffer_get_device(const struct iio_buffer *buf)
Retrieve a pointer to the iio_device structure.
Definition: buffer.c:301
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:255
__api __pure struct iio_device * iio_context_get_device(const struct iio_context *ctx, unsigned int index)
Get the device present at the given index.
Definition: context.c:171
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:438
__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:324
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:296
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:1037
__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:697
__api struct iio_context * iio_create_usb_context(unsigned short vid, unsigned short pid)
Create a context from USB devices.
Definition: context.c:344
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:291
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:1025
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:165
__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:411
__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:246
__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:573
__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:389
__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:633
__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:180
__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:225
__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:568
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:252
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:1022
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:286
__api __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:141
__api __pure const char * iio_device_find_attr(const struct iio_device *dev, const char *name)
Try to find a device-specific attribute by its name.
Definition: device.c:234
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:873
__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:572
__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:350
__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:645
__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:221
__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:185
__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:552
__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:170
__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:199
__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:562
__api ssize_t iio_buffer_push_partial(struct iio_buffer *buf, size_t samples_count)
Send a given number of samples to the hardware.
Definition: buffer.c:184
__api int iio_device_attr_read_longlong(const struct iio_device *dev, const char *attr, long long *val)
Read the content of the given device-specific attribute.
Definition: device.c:466
__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:231
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:1031
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:304
__api void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:243
bool with_scale
Contains True if the sample should be scaled when converted.
Definition: iio.h:1040
__api void * iio_device_get_data(const struct iio_device *dev)
Retrieve a previously associated pointer of an iio_device structure.
Definition: device.c:361
__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:190
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:1043
__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:494
__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:482
__api int iio_device_debug_attr_read_all(struct iio_device *dev, int(*cb)(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d), void *data)
Read the content of all debug attributes.
__api int iio_context_get_version(const struct iio_context *ctx, unsigned int *major, unsigned int *minor, char git_tag[8])
Get the version of the backend in use.
Definition: context.c:237
__api void * iio_buffer_first(const struct iio_buffer *buf, const struct iio_channel *chn)
Find the first sample of a channel in a buffer.
Definition: buffer.c:248
__api __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:180
__api ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:461
__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:385
__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:621
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:242
__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:549
__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:516
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:237
__api __pure bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition: device.c:366
bool is_fully_defined
Contains True if the sample is fully defined, sign extended, etc.
Definition: iio.h:1034
__api void iio_device_set_data(struct iio_device *dev, void *data)
Associate a pointer to an iio_device structure.
Definition: device.c:356
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:561
__api void iio_strerror(int err, char *dst, size_t len)
Get a string description of an error code.
Definition: utilities.c:183
unsigned int shift
Right-shift to apply when converting sample.
Definition: iio.h:1028
__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:528
__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:505
__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:220
__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:264
__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:529
__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:270
__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:624
__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:582
__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:542
__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:195
__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:400
__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:539
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:453
__api void iio_library_get_version(unsigned int *major, unsigned int *minor, char git_tag[8])
Get the version of the libiio library.
Definition: utilities.c:170
__api int iio_device_debug_attr_read_bool(const struct iio_device *dev, const char *attr, bool *val)
Read the content of the given debug attribute.
Definition: device.c:598
__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:204
__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:658
__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:175
__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:484
__api __pure unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:190
__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:500
Contains the format of a data sample.
Definition: iio.h:1020
__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:211
__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:610
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:709
__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:583
__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:340
__api struct iio_context * iio_create_network_context(const char *host)
Create a context from the network.
Definition: context.c:314
__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:378
__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:865