libiio  0.4
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 /* ------------------------------------------------------------------*/
83 /* ------------------------- Context functions -------------------------------*/
99 __api struct iio_context * iio_create_default_context(void);
100 
101 
105 __api struct iio_context * iio_create_local_context(void);
106 
107 
115 __api struct iio_context * iio_create_xml_context(const char *xml_file);
116 
117 
127  const char *xml, size_t len);
128 
129 
134 __api struct iio_context * iio_create_network_context(const char *host);
135 
136 
141 __api struct iio_context * iio_context_clone(const struct iio_context *ctx);
142 
143 
148 __api void iio_context_destroy(struct iio_context *ctx);
149 
150 
158 __api int iio_context_get_version(const struct iio_context *ctx,
159  unsigned int *major, unsigned int *minor, char git_tag[8]);
160 
161 
165 __api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
166 
167 
175 __api __pure const char * iio_context_get_name(const struct iio_context *ctx);
176 
177 
184 __api __pure const char * iio_context_get_description(
185  const struct iio_context *ctx);
186 
187 
191 __api __pure unsigned int iio_context_get_devices_count(
192  const struct iio_context *ctx);
193 
194 
200 __api __pure struct iio_device * iio_context_get_device(
201  const struct iio_context *ctx, unsigned int index);
202 
203 
211 __api __pure struct iio_device * iio_context_find_device(
212  const struct iio_context *ctx, const char *name);
213 
214 
221 __api int iio_context_set_timeout(
222  struct iio_context *ctx, unsigned int timeout_ms);
223 
224 /* ------------------------------------------------------------------*/
226 /* ------------------------- Device functions --------------------------------*/
236 __api __pure const char * iio_device_get_id(const struct iio_device *dev);
237 
238 
244 __api __pure const char * iio_device_get_name(const struct iio_device *dev);
245 
246 
250 __api __pure unsigned int iio_device_get_channels_count(
251  const struct iio_device *dev);
252 
253 
257 __api __pure unsigned int iio_device_get_attrs_count(
258  const struct iio_device *dev);
259 
260 
266 __api __pure struct iio_channel * iio_device_get_channel(
267  const struct iio_device *dev, unsigned int index);
268 
269 
275 __api __pure const char * iio_device_get_attr(
276  const struct iio_device *dev, unsigned int index);
277 
278 
287 __api __pure struct iio_channel * iio_device_find_channel(
288  const struct iio_device *dev, const char *name, bool output);
289 
290 
302 __api __pure const char * iio_device_find_attr(
303  const struct iio_device *dev, const char *name);
304 
305 
327  __api ssize_t iio_device_attr_read(const struct iio_device *dev,
328  const char *attr, char *dst, size_t len);
329 
330 
341 __api int iio_device_attr_read_all(struct iio_device *dev,
342  int (*cb)(struct iio_device *dev, const char *attr,
343  const char *value, size_t len, void *d),
344  void *data);
345 
346 
354 __api int iio_device_attr_read_bool(const struct iio_device *dev,
355  const char *attr, bool *val);
356 
357 
365 __api int iio_device_attr_read_longlong(const struct iio_device *dev,
366  const char *attr, long long *val);
367 
368 
376 __api int iio_device_attr_read_double(const struct iio_device *dev,
377  const char *attr, double *val);
378 
379 
398 __api ssize_t iio_device_attr_write(const struct iio_device *dev,
399  const char *attr, const char *src);
400 
401 
410 __api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
411  const char *attr, const void *src, size_t len);
412 
413 
424 __api int iio_device_attr_write_all(struct iio_device *dev,
425  ssize_t (*cb)(struct iio_device *dev,
426  const char *attr, void *buf, size_t len, void *d),
427  void *data);
428 
429 
437 __api int iio_device_attr_write_bool(const struct iio_device *dev,
438  const char *attr, bool val);
439 
440 
448 __api int iio_device_attr_write_longlong(const struct iio_device *dev,
449  const char *attr, long long val);
450 
451 
459 __api int iio_device_attr_write_double(const struct iio_device *dev,
460  const char *attr, double val);
461 
462 
466 __api void iio_device_set_data(struct iio_device *dev, void *data);
467 
468 
472 __api void * iio_device_get_data(const struct iio_device *dev);
473 
474 
482 __api int iio_device_get_trigger(const struct iio_device *dev,
483  const struct iio_device **trigger);
484 
485 
492 __api int iio_device_set_trigger(const struct iio_device *dev,
493  const struct iio_device *trigger);
494 
495 
499 __api __pure bool iio_device_is_trigger(const struct iio_device *dev);
500 
501 /* ------------------------------------------------------------------*/
503 /* ------------------------- Channel functions -------------------------------*/
513 __api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
514 
515 
521 __api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
522 
523 
527 __api __pure bool iio_channel_is_output(const struct iio_channel *chn);
528 
529 
537 __api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
538 
539 
543 __api __pure unsigned int iio_channel_get_attrs_count(
544  const struct iio_channel *chn);
545 
546 
552 __api __pure const char * iio_channel_get_attr(
553  const struct iio_channel *chn, unsigned int index);
554 
555 
567 __api __pure const char * iio_channel_find_attr(
568  const struct iio_channel *chn, const char *name);
569 
570 
577 __api __pure const char * iio_channel_attr_get_filename(
578  const struct iio_channel *chn, const char *attr);
579 
580 
602 __api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
603  const char *attr, char *dst, size_t len);
604 
605 
616 __api int iio_channel_attr_read_all(struct iio_channel *chn,
617  int (*cb)(struct iio_channel *chn,
618  const char *attr, const char *val, size_t len, void *d),
619  void *data);
620 
621 
629 __api int iio_channel_attr_read_bool(const struct iio_channel *chn,
630  const char *attr, bool *val);
631 
632 
640 __api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
641  const char *attr, long long *val);
642 
643 
651 __api int iio_channel_attr_read_double(const struct iio_channel *chn,
652  const char *attr, double *val);
653 
654 
673 __api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
674  const char *attr, const char *src);
675 
676 
685 __api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
686  const char *attr, const void *src, size_t len);
687 
688 
699 __api int iio_channel_attr_write_all(struct iio_channel *chn,
700  ssize_t (*cb)(struct iio_channel *chn,
701  const char *attr, void *buf, size_t len, void *d),
702  void *data);
703 
704 
712 __api int iio_channel_attr_write_bool(const struct iio_channel *chn,
713  const char *attr, bool val);
714 
715 
723 __api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
724  const char *attr, long long val);
725 
726 
734 __api int iio_channel_attr_write_double(const struct iio_channel *chn,
735  const char *attr, double val);
736 
737 
744 __api void iio_channel_enable(struct iio_channel *chn);
745 
746 
749 __api void iio_channel_disable(struct iio_channel *chn);
750 
751 
755 __api bool iio_channel_is_enabled(const struct iio_channel *chn);
756 
757 
765 __api size_t iio_channel_read_raw(const struct iio_channel *chn,
766  struct iio_buffer *buffer, void *dst, size_t len);
767 
768 
776 __api size_t iio_channel_read(const struct iio_channel *chn,
777  struct iio_buffer *buffer, void *dst, size_t len);
778 
779 
787 __api size_t iio_channel_write_raw(const struct iio_channel *chn,
788  struct iio_buffer *buffer, const void *src, size_t len);
789 
790 
798 __api size_t iio_channel_write(const struct iio_channel *chn,
799  struct iio_buffer *buffer, const void *src, size_t len);
800 
801 
805 __api void iio_channel_set_data(struct iio_channel *chn, void *data);
806 
807 
811 __api void * iio_channel_get_data(const struct iio_channel *chn);
812 
813 /* ------------------------------------------------------------------*/
815 /* ------------------------- Buffer functions --------------------------------*/
831 __api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
832  size_t samples_count, bool cyclic);
833 
834 
839 __api void iio_buffer_destroy(struct iio_buffer *buf);
840 
841 
848 __api ssize_t iio_buffer_refill(struct iio_buffer *buf);
849 
850 
857 __api ssize_t iio_buffer_push(struct iio_buffer *buf);
858 
859 
863 __api __pure void * iio_buffer_start(const struct iio_buffer *buf);
864 
865 
881 __api void * iio_buffer_first(const struct iio_buffer *buf,
882  const struct iio_channel *chn);
883 
884 
889 __api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
890 
891 
896 __api void * iio_buffer_end(const struct iio_buffer *buf);
897 
898 
909 __api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
910  ssize_t (*callback)(const struct iio_channel *chn,
911  void *src, size_t bytes, void *d), void *data);
912 
913 
917 __api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
918 
919 
923 __api void * iio_buffer_get_data(const struct iio_buffer *buf);
924 
925 /* ------------------------------------------------------------------*/
927 /* ------------------------- Low-level functions -----------------------------*/
939  unsigned int length;
940 
942  unsigned int bits;
943 
945  unsigned int shift;
946 
948  bool is_signed;
949 
952 
954  bool is_be;
955 
958 
960  double scale;
961 };
962 
963 
971 __api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
972 
973 
978 __api __pure long iio_channel_get_index(const struct iio_channel *chn);
979 
980 
984 __api __cnst const struct iio_data_format * iio_channel_get_data_format(
985  const struct iio_channel *chn);
986 
987 
993 __api void iio_channel_convert(const struct iio_channel *chn,
994  void *dst, const void *src);
995 
996 
1002 __api void iio_channel_convert_inverse(const struct iio_channel *chn,
1003  void *dst, const void *src);
1004 
1005 
1009 __api __pure unsigned int iio_device_get_debug_attrs_count(
1010  const struct iio_device *dev);
1011 
1012 
1018 __api __pure const char * iio_device_get_debug_attr(
1019  const struct iio_device *dev, unsigned int index);
1020 
1021 
1034 __api __pure const char * iio_device_find_debug_attr(
1035  const struct iio_device *dev, const char *name);
1036 
1037 
1060 __api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1061  const char *attr, char *dst, size_t len);
1062 
1063 
1073 __api int iio_device_debug_attr_read_all(struct iio_device *dev,
1074  int (*cb)(struct iio_device *dev, const char *attr,
1075  const char *value, size_t len, void *d),
1076  void *data);
1077 
1078 
1098 __api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1099  const char *attr, const char *src);
1100 
1101 
1110 __api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1111  const char *attr, const void *src, size_t len);
1112 
1113 
1123 __api int iio_device_debug_attr_write_all(struct iio_device *dev,
1124  ssize_t (*cb)(struct iio_device *dev,
1125  const char *attr, void *buf, size_t len, void *d),
1126  void *data);
1127 
1128 
1136 __api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1137  const char *attr, bool *val);
1138 
1139 
1147 __api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1148  const char *attr, long long *val);
1149 
1150 
1158 __api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1159  const char *attr, double *val);
1160 
1161 
1169 __api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1170  const char *attr, bool val);
1171 
1172 
1180 __api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1181  const char *attr, long long val);
1182 
1183 
1191 __api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1192  const char *attr, double val);
1193 
1194 
1207 __api int iio_device_identify_filename(const struct iio_device *dev,
1208  const char *filename, struct iio_channel **chn,
1209  const char **attr);
1210 
1211 
1218 __api int iio_device_reg_write(struct iio_device *dev,
1219  uint32_t address, uint32_t value);
1220 
1221 
1228 __api int iio_device_reg_read(struct iio_device *dev,
1229  uint32_t address, uint32_t *value);
1230 
1231 
1234 #ifdef __cplusplus
1235 }
1236 #endif
1237 
1238 #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:474
__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf)
Get the step size between two samples of one channel.
Definition: buffer.c:232
__api __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition: channel.c:251
__api bool iio_channel_is_enabled(const struct iio_channel *chn)
Returns True if the channel is enabled.
Definition: channel.c:262
__api struct iio_context * iio_create_xml_context(const char *xml_file)
Create a context from a XML file.
Definition: context.c:269
__api struct iio_context * iio_create_default_context(void)
Create a context from local or remote IIO devices.
Definition: context.c:225
__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:142
__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:506
__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:846
__api __pure const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:187
__api struct iio_context * iio_context_clone(const struct iio_context *ctx)
Duplicate a pre-existing IIO context.
Definition: context.c:217
__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:147
__api size_t iio_channel_read_raw(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:443
__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:260
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition: buffer.c:247
bool is_be
Contains True if the sample is in big-endian format.
Definition: iio.h:954
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition: context.c:125
__api __pure void * iio_buffer_start(const struct iio_buffer *buf)
Get the start address of the buffer.
Definition: buffer.c:198
__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:686
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition: buffer.c:242
unsigned int bits
Length of valuable data in the sample, in bits.
Definition: iio.h:942
__api __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:169
__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:416
__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:248
__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:562
__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:378
__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:622
__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:184
__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:227
__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:557
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:256
unsigned int length
Total length of the sample, in bits.
Definition: iio.h:939
__api void * iio_buffer_end(const struct iio_buffer *buf)
Get the address that follows the last sample in a buffer.
Definition: buffer.c:237
__api __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition: context.c:117
__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:236
Represents a device in the IIO context.
__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:575
__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:634
__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:225
__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:189
__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:541
__api void iio_buffer_destroy(struct iio_buffer *buf)
Destroy the given buffer.
Definition: buffer.c:88
__api __pure const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition: channel.c:174
__api ssize_t iio_buffer_refill(struct iio_buffer *buf)
Fetch more samples from the hardware.
Definition: buffer.c:97
__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:203
__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:551
__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:455
__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:156
__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:235
bool is_signed
Contains True if the sample is signed.
Definition: iio.h:948
__api struct iio_context * iio_create_local_context(void)
Create a context from local IIO devices (Linux only)
Definition: context.c:242
bool with_scale
Contains True if the sample should be scaled when converted.
Definition: iio.h:957
__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:194
double scale
Contains the scale to apply if with_scale is set.
Definition: iio.h:960
__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:483
__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:471
__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:199
__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:203
__api __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:182
__api ssize_t iio_device_get_sample_size(const struct iio_device *dev)
Get the current sample size.
Definition: device.c:450
__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:390
__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:610
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition: channel.c:246
__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:554
__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:521
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition: channel.c:241
__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:951
__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:564
unsigned int shift
Right-shift to apply when converting sample.
Definition: iio.h:945
__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:533
__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:494
__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:222
__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:23
__api void iio_channel_enable(struct iio_channel *chn)
Enable the given channel.
Definition: channel.c:268
__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:518
__api __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition: context.c:112
__api void iio_channel_disable(struct iio_channel *chn)
Disable the given channel.
Definition: channel.c:274
__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:627
__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:571
__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:531
__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:197
__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:389
__api __pure const char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition: context.c:107
__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:544
__api size_t iio_channel_read(const struct iio_channel *chn, struct iio_buffer *buffer, void *dst, size_t len)
Definition: channel.c:458
__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:100
__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:587
__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:206
__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:647
__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:179
__api size_t iio_channel_write(const struct iio_channel *chn, struct iio_buffer *buffer, const void *src, size_t len)
Definition: channel.c:489
__api __pure unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:192
__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:505
Contains the format of a data sample.
Definition: iio.h:937
__api ssize_t iio_buffer_push(struct iio_buffer *buf)
Send the samples to the hardware.
Definition: buffer.c:120
__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:215
__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:599
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:209
__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:698
__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:586
__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:251
__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:854