libiio  0.6
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 <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 #endif
39 
40 #ifdef __GNUC__
41 #define __cnst __attribute__((const))
42 #define __pure __attribute__((pure))
43 #define __notused __attribute__((unused))
44 #else
45 #define __cnst
46 #define __pure
47 #define __notused
48 #endif
49 
50 #ifdef _WIN32
51 # ifdef LIBIIO_EXPORTS
52 # define __api __declspec(dllexport)
53 # else
54 # define __api __declspec(dllimport)
55 # endif
56 #elif __GNUC__ >= 4
57 # define __api __attribute__((visibility ("default")))
58 #else
59 # define __api
60 #endif
61 
62 struct iio_context;
63 struct iio_device;
64 struct iio_channel;
65 struct iio_buffer;
66 
67 
68 /* ---------------------------------------------------------------------------*/
69 /* ------------------------- Top-level functions -----------------------------*/
78 __api void iio_library_get_version(unsigned int *major,
79  unsigned int *minor, char git_tag[8]);
80 
81 
87 __api void iio_strerror(int err, char *dst, size_t len);
88 
89 /* ------------------------------------------------------------------*/
91 /* ------------------------- Context functions -------------------------------*/
107 __api struct iio_context * iio_create_default_context(void);
108 
109 
113 __api struct iio_context * iio_create_local_context(void);
114 
115 
123 __api struct iio_context * iio_create_xml_context(const char *xml_file);
124 
125 
135  const char *xml, size_t len);
136 
137 
142 __api struct iio_context * iio_create_network_context(const char *host);
143 
144 
149 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
150 
151 
156 __api void iio_context_destroy(struct iio_context *ctx);
157 
158 
166 __api int iio_context_get_version(const struct iio_context *ctx,
167  unsigned int *major, unsigned int *minor, char git_tag[8]);
168 
169 
173 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
174 
175 
183 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
184 
185 
192 __api __pure const char * iio_context_get_description(
193  const struct iio_context *ctx);
194 
195 
199 __api __pure unsigned int iio_context_get_devices_count(
200  const struct iio_context *ctx);
201 
202 
208 __api __pure struct iio_device * iio_context_get_device(
209  const struct iio_context *ctx, unsigned int index);
210 
211 
219 __api __pure struct iio_device * iio_context_find_device(
220  const struct iio_context *ctx, const char *name);
221 
222 
229 __api int iio_context_set_timeout(
230  struct iio_context *ctx, unsigned int timeout_ms);
231 
232 /* ------------------------------------------------------------------*/
234 /* ------------------------- Device functions --------------------------------*/
244 __api __pure const struct iio_context * iio_device_get_context(
245  const struct iio_device *dev);
246 
247 
251 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
252 
253 
259 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
260 
261 
265 __api __pure unsigned int iio_device_get_channels_count(
266  const struct iio_device *dev);
267 
268 
272 __api __pure unsigned int iio_device_get_attrs_count(
273  const struct iio_device *dev);
274 
275 
281 __api __pure struct iio_channel * iio_device_get_channel(
282  const struct iio_device *dev, unsigned int index);
283 
284 
290 __api __pure const char * iio_device_get_attr(
291  const struct iio_device *dev, unsigned int index);
292 
293 
302 __api __pure struct iio_channel * iio_device_find_channel(
303  const struct iio_device *dev, const char *name, bool output);
304 
305 
317 __api __pure const char * iio_device_find_attr(
318  const struct iio_device *dev, const char *name);
319 
320 
342  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
343  const char *attr, char *dst, size_t len);
344 
345 
356 __api int iio_device_attr_read_all(struct iio_device *dev,
357  int (*cb)(struct iio_device *dev, const char *attr,
358  const char *value, size_t len, void *d),
359  void *data);
360 
361 
369 __api int iio_device_attr_read_bool(const struct iio_device *dev,
370  const char *attr, bool *val);
371 
372 
380 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
381  const char *attr, long long *val);
382 
383 
391 __api int iio_device_attr_read_double(const struct iio_device *dev,
392  const char *attr, double *val);
393 
394 
413 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
414  const char *attr, const char *src);
415 
416 
425 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
426  const char *attr, const void *src, size_t len);
427 
428 
439 __api int iio_device_attr_write_all(struct iio_device *dev,
440  ssize_t (*cb)(struct iio_device *dev,
441  const char *attr, void *buf, size_t len, void *d),
442  void *data);
443 
444 
452 __api int iio_device_attr_write_bool(const struct iio_device *dev,
453  const char *attr, bool val);
454 
455 
463 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
464  const char *attr, long long val);
465 
466 
474 __api int iio_device_attr_write_double(const struct iio_device *dev,
475  const char *attr, double val);
476 
477 
481 __api void iio_device_set_data(struct iio_device *dev, void *data);
482 
483 
487 __api void * iio_device_get_data(const struct iio_device *dev);
488 
489 
497 __api int iio_device_get_trigger(const struct iio_device *dev,
498  const struct iio_device **trigger);
499 
500 
507 __api int iio_device_set_trigger(const struct iio_device *dev,
508  const struct iio_device *trigger);
509 
510 
514 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
515 
524 __api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
525  unsigned int nb_buffers);
526 /* ------------------------------------------------------------------*/
528 /* ------------------------- Channel functions -------------------------------*/
538 __api __pure const struct iio_device * iio_channel_get_device(
539  const struct iio_channel *chn);
540 
541 
545 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
546 
547 
553 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
554 
555 
559 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
560 
561 
569 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
570 
571 
575 __api __pure unsigned int iio_channel_get_attrs_count(
576  const struct iio_channel *chn);
577 
578 
584 __api __pure const char * iio_channel_get_attr(
585  const struct iio_channel *chn, unsigned int index);
586 
587 
599 __api __pure const char * iio_channel_find_attr(
600  const struct iio_channel *chn, const char *name);
601 
602 
609 __api __pure const char * iio_channel_attr_get_filename(
610  const struct iio_channel *chn, const char *attr);
611 
612 
634 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
635  const char *attr, char *dst, size_t len);
636 
637 
648 __api int iio_channel_attr_read_all(struct iio_channel *chn,
649  int (*cb)(struct iio_channel *chn,
650  const char *attr, const char *val, size_t len, void *d),
651  void *data);
652 
653 
661 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
662  const char *attr, bool *val);
663 
664 
672 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
673  const char *attr, long long *val);
674 
675 
683 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
684  const char *attr, double *val);
685 
686 
705 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
706  const char *attr, const char *src);
707 
708 
717 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
718  const char *attr, const void *src, size_t len);
719 
720 
731 __api int iio_channel_attr_write_all(struct iio_channel *chn,
732  ssize_t (*cb)(struct iio_channel *chn,
733  const char *attr, void *buf, size_t len, void *d),
734  void *data);
735 
736 
744 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
745  const char *attr, bool val);
746 
747 
755 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
756  const char *attr, long long val);
757 
758 
766 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
767  const char *attr, double val);
768 
769 
776 __api void iio_channel_enable(struct iio_channel *chn);
777 
778 
781 __api void iio_channel_disable(struct iio_channel *chn);
782 
783 
787 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
788 
789 
797 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
798  struct iio_buffer *buffer, void *dst, size_t len);
799 
800 
808 __api size_t iio_channel_read(const struct iio_channel *chn,
809  struct iio_buffer *buffer, void *dst, size_t len);
810 
811 
819 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
820  struct iio_buffer *buffer, const void *src, size_t len);
821 
822 
830 __api size_t iio_channel_write(const struct iio_channel *chn,
831  struct iio_buffer *buffer, const void *src, size_t len);
832 
833 
837 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
838 
839 
843 __api void * iio_channel_get_data(const struct iio_channel *chn);
844 
845 /* ------------------------------------------------------------------*/
847 /* ------------------------- Buffer functions --------------------------------*/
857 __api __pure const struct iio_device * iio_buffer_get_device(
858  const struct iio_buffer *buf);
859 
860 
870 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
871  size_t samples_count, bool cyclic);
872 
873 
878 __api void iio_buffer_destroy(struct iio_buffer *buf);
879 
888 __api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
889 
901 __api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
902 
903 
910 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
911 
912 
919 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
920 
921 
929 __api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
930  size_t samples_count);
931 
932 
936 __api void * iio_buffer_start(const struct iio_buffer *buf);
937 
938 
954 __api void * iio_buffer_first(const struct iio_buffer *buf,
955  const struct iio_channel *chn);
956 
957 
962 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
963 
964 
969 __api void * iio_buffer_end(const struct iio_buffer *buf);
970 
971 
982 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
983  ssize_t (*callback)(const struct iio_channel *chn,
984  void *src, size_t bytes, void *d), void *data);
985 
986 
990 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
991 
992 
996 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
997 
998 /* ------------------------------------------------------------------*/
1000 /* ------------------------- Low-level functions -----------------------------*/
1012  unsigned int length;
1013 
1015  unsigned int bits;
1016 
1018  unsigned int shift;
1019 
1022 
1025 
1027  bool is_be;
1028 
1031 
1033  double scale;
1034 };
1035 
1036 
1044 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
1045 
1046 
1051 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
1052 
1053 
1057 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
1058  const struct iio_channel *chn);
1059 
1060 
1066 __api void iio_channel_convert(const struct iio_channel *chn,
1067  void *dst, const void *src);
1068 
1069 
1075 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1076  void *dst, const void *src);
1077 
1078 
1082 __api __pure unsigned int iio_device_get_debug_attrs_count(
1083  const struct iio_device *dev);
1084 
1085 
1091 __api __pure const char * iio_device_get_debug_attr(
1092  const struct iio_device *dev, unsigned int index);
1093 
1094 
1107 __api __pure const char * iio_device_find_debug_attr(
1108  const struct iio_device *dev, const char *name);
1109 
1110 
1133 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1134  const char *attr, char *dst, size_t len);
1135 
1136 
1146 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1147  int (*cb)(struct iio_device *dev, const char *attr,
1148  const char *value, size_t len, void *d),
1149  void *data);
1150 
1151 
1171 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1172  const char *attr, const char *src);
1173 
1174 
1183 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1184  const char *attr, const void *src, size_t len);
1185 
1186 
1196 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1197  ssize_t (*cb)(struct iio_device *dev,
1198  const char *attr, void *buf, size_t len, void *d),
1199  void *data);
1200 
1201 
1209 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1210  const char *attr, bool *val);
1211 
1212 
1220 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1221  const char *attr, long long *val);
1222 
1223 
1231 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1232  const char *attr, double *val);
1233 
1234 
1242 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1243  const char *attr, bool val);
1244 
1245 
1253 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1254  const char *attr, long long val);
1255 
1256 
1264 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1265  const char *attr, double val);
1266 
1267 
1280 __api int iio_device_identify_filename(const struct iio_device *dev,
1281  const char *filename, struct iio_channel **chn,
1282  const char **attr);
1283 
1284 
1291 __api int iio_device_reg_write(struct iio_device *dev,
1292  uint32_t address, uint32_t value);
1293 
1294 
1301 __api int iio_device_reg_read(struct iio_device *dev,
1302  uint32_t address, uint32_t *value);
1303 
1304 
1307 #ifdef __cplusplus
1308 }
1309 #endif
1310 
1311 #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:307
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:260
__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:250
__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:297
__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:1027
__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 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:1015
__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:1012
__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:1021
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:277
__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:1030
__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:1033
__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:232
__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:1024
__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:1018
__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:1010
__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:242
__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:287
__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