libiio: iio.h Source File

libiio 1.0 Library for interfacing with IIO devices

Loading...
Searching...
No Matches
iio.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: MIT */
2/*
3 * libiio - Library for interfacing industrial I/O (IIO) devices
4 *
5 * Copyright (C) 2014 Analog Devices, Inc.
6 * Author: Paul Cercueil <paul.cercueil@analog.com>
7 *
8 * Note: This header file is released under the MIT License as specified by
9 * the SPDX identifier above. However, libiio as a whole includes components
10 * under multiple open-source licenses. The license of the final binary
11 * depends on the build configuration and may differ from that of this file.
12 * Please review the full licensing information and configuration options
13 * to ensure compliance with applicable license terms.
14 */
15
40#ifndef __IIO_H__
41#define __IIO_H__
42
43#ifndef DOXYGEN
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#include <limits.h>
50#include <stdint.h>
51#include <stdlib.h>
52#include <stddef.h>
53#include <stdio.h>
54
55#if (defined(_WIN32) || defined(__MBED__))
56#ifndef _SSIZE_T_DEFINED
57typedef ptrdiff_t ssize_t;
58#define _SSIZE_T_DEFINED
59#endif
60#else
61#include <sys/types.h>
62#endif
63
64#if defined(_MSC_VER) && (_MSC_VER < 1800) && !defined(__BOOL_DEFINED)
65#undef bool
66#undef false
67#undef true
68#define bool char
69#define false 0
70#define true 1
71#else
72#include <stdbool.h>
73#endif
74
75#if defined(__GNUC__) && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
76#ifndef __cnst
77#define __cnst __attribute__((const))
78#endif
79#ifndef __pure
80#define __pure __attribute__((pure))
81#endif
82#define __notused __attribute__((unused))
83#ifdef IIO_CHECK_RET
84#define __check_ret __attribute__((warn_unused_result))
85#else
86#define __check_ret
87#endif
88#else
89#define __cnst
90#define __pure
91#define __notused
92#define __check_ret
93#endif
94
95#if !defined(_WIN32) && __GNUC__ >= 4 && \
96 !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
97# define __iio_api_export __attribute__((visibility ("default")))
98# define __iio_api_import
99#elif defined(_WIN32) && !defined(LIBIIO_STATIC)
100# define __iio_api_export __declspec(dllexport)
101# define __iio_api_import __declspec(dllimport)
102#else
103# define __iio_api_export
104# define __iio_api_import
105#endif
106
107#ifdef LIBIIO_EXPORTS
108# define __iio_api __iio_api_export
109#else
110# define __iio_api __iio_api_import
111#endif
112
113#define __api __iio_api
114
115#endif /* DOXYGEN */
116
117struct iio_attr;
118struct iio_block;
119struct iio_context;
120struct iio_device;
121struct iio_channel;
122struct iio_channels_mask;
123struct iio_event_stream;
124struct iio_buffer;
125struct iio_scan;
126struct iio_stream;
127
132 enum iio_log_level {
133 /* @brief No log output from the library */
134 LEVEL_NOLOG = 1,
135
136 /* @brief Only print error messages */
137 LEVEL_ERROR = 2,
138
139 /* @brief Also print warnings */
140 LEVEL_WARNING = 3,
141
142 /* @brief Also print noteworthy information */
143 LEVEL_INFO = 4,
144
145 /* @brief Also print debug messages */
146 LEVEL_DEBUG = 5,
147};
148
153 enum iio_context_flags {
157 IIO_CTX_XML_INCLUDE_VALUES = 1 << 0,
158};
159
167 struct iio_context_params {
169 FILE *out;
170
172 FILE *err;
173
176 enum iio_log_level log_level;
177
182 enum iio_log_level stderr_level;
183
189 enum iio_log_level timestamp_level;
190
195 int timeout_ms;
196
199 unsigned int flags;
200
202 char __rsrv[32];
203};
204
205/*
206 * <linux/iio/types.h> header guard to protect these enums from being defined
207 * twice
208 */
209#ifndef _IIO_TYPES_H_
210#define _IIO_TYPES_H_
211
219 enum iio_chan_type {
220 IIO_VOLTAGE,
221 IIO_CURRENT,
222 IIO_POWER,
223 IIO_ACCEL,
224 IIO_ANGL_VEL,
225 IIO_MAGN,
226 IIO_LIGHT,
227 IIO_INTENSITY,
228 IIO_PROXIMITY,
229 IIO_TEMP,
230 IIO_INCLI,
231 IIO_ROT,
232 IIO_ANGL,
233 IIO_TIMESTAMP,
234 IIO_CAPACITANCE,
235 IIO_ALTVOLTAGE,
236 IIO_CCT,
237 IIO_PRESSURE,
238 IIO_HUMIDITYRELATIVE,
239 IIO_ACTIVITY,
240 IIO_STEPS,
241 IIO_ENERGY,
242 IIO_DISTANCE,
243 IIO_VELOCITY,
244 IIO_CONCENTRATION,
245 IIO_RESISTANCE,
246 IIO_PH,
247 IIO_UVINDEX,
248 IIO_ELECTRICALCONDUCTIVITY,
249 IIO_COUNT,
250 IIO_INDEX,
251 IIO_GRAVITY,
252 IIO_POSITIONRELATIVE,
253 IIO_PHASE,
254 IIO_MASSCONCENTRATION,
255 IIO_DELTA_ANGL,
256 IIO_DELTA_VELOCITY,
257 IIO_COLORTEMP,
258 IIO_CHROMATICITY,
259 IIO_ATTENTION,
260 IIO_ALTCURRENT,
261 IIO_CHAN_TYPE_UNKNOWN = INT_MAX
262};
263
271 enum iio_modifier {
272 IIO_NO_MOD,
273 IIO_MOD_X,
274 IIO_MOD_Y,
275 IIO_MOD_Z,
276 IIO_MOD_X_AND_Y,
277 IIO_MOD_X_AND_Z,
278 IIO_MOD_Y_AND_Z,
279 IIO_MOD_X_AND_Y_AND_Z,
280 IIO_MOD_X_OR_Y,
281 IIO_MOD_X_OR_Z,
282 IIO_MOD_Y_OR_Z,
283 IIO_MOD_X_OR_Y_OR_Z,
284 IIO_MOD_LIGHT_BOTH,
285 IIO_MOD_LIGHT_IR,
286 IIO_MOD_ROOT_SUM_SQUARED_X_Y,
287 IIO_MOD_SUM_SQUARED_X_Y_Z,
288 IIO_MOD_LIGHT_CLEAR,
289 IIO_MOD_LIGHT_RED,
290 IIO_MOD_LIGHT_GREEN,
291 IIO_MOD_LIGHT_BLUE,
292 IIO_MOD_QUATERNION,
293 IIO_MOD_TEMP_AMBIENT,
294 IIO_MOD_TEMP_OBJECT,
295 IIO_MOD_NORTH_MAGN,
296 IIO_MOD_NORTH_TRUE,
297 IIO_MOD_NORTH_MAGN_TILT_COMP,
298 IIO_MOD_NORTH_TRUE_TILT_COMP,
299 IIO_MOD_RUNNING,
300 IIO_MOD_JOGGING,
301 IIO_MOD_WALKING,
302 IIO_MOD_STILL,
303 IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
304 IIO_MOD_I,
305 IIO_MOD_Q,
306 IIO_MOD_CO2,
307 IIO_MOD_VOC,
308 IIO_MOD_LIGHT_UV,
309 IIO_MOD_LIGHT_DUV,
310 IIO_MOD_PM1,
311 IIO_MOD_PM2P5,
312 IIO_MOD_PM4,
313 IIO_MOD_PM10,
314 IIO_MOD_ETHANOL,
315 IIO_MOD_H2,
316 IIO_MOD_O2,
317 IIO_MOD_LINEAR_X,
318 IIO_MOD_LINEAR_Y,
319 IIO_MOD_LINEAR_Z,
320 IIO_MOD_PITCH,
321 IIO_MOD_YAW,
322 IIO_MOD_ROLL,
323 IIO_MOD_LIGHT_UVA,
324 IIO_MOD_LIGHT_UVB,
325 IIO_MOD_RMS,
326 IIO_MOD_ACTIVE,
327 IIO_MOD_REACTIVE,
328 IIO_MOD_APPARENT,
329};
330
338 enum iio_event_type {
339 IIO_EV_TYPE_THRESH,
340 IIO_EV_TYPE_MAG,
341 IIO_EV_TYPE_ROC,
342 IIO_EV_TYPE_THRESH_ADAPTIVE,
343 IIO_EV_TYPE_MAG_ADAPTIVE,
344 IIO_EV_TYPE_CHANGE,
345 IIO_EV_TYPE_MAG_REFERENCED,
346 IIO_EV_TYPE_GESTURE,
347 IIO_EV_TYPE_FAULT,
348};
349
356 enum iio_event_direction {
357 IIO_EV_DIR_EITHER,
358 IIO_EV_DIR_RISING,
359 IIO_EV_DIR_FALLING,
360 IIO_EV_DIR_NONE,
361 IIO_EV_DIR_SINGLETAP,
362 IIO_EV_DIR_DOUBLETAP,
363 IIO_EV_DIR_FAULT_OPENWIRE,
364};
365
366#endif /* _IIO_TYPES_H_ */
367
368/* ---------------------------------------------------------------------------*/
369/* ---------------------------- Error handling -------------------------------*/
376static inline __check_ret void *iio_ptr(int err)
377{
378 return (void *)(intptr_t) err;
379}
380
384static inline __check_ret int iio_err(const void *ptr)
385{
386 return (uintptr_t) ptr >= (uintptr_t) -4095 ? (int)(intptr_t) ptr : 0;
387}
388
392static inline __check_ret void *iio_err_cast(const void *ptr)
393{
394 return (void *) ptr;
395}
396
/* ------------------------------------------------------------------*/
398/* ------------------------- Attributes functions ----------------------------*/
411__api __check_ret ssize_t
412 iio_attr_read_raw(const struct iio_attr *attr, char *dst, size_t len);
413
419#ifndef __cplusplus
420#define iio_attr_read(attr, ptr) \
421 _Generic((ptr), \
422 bool *: iio_attr_read_bool, \
423 long long *: iio_attr_read_longlong, \
424 double *: iio_attr_read_double)(attr, ptr)
425#endif /* __cplusplus */
426
433__api __check_ret ssize_t
434 iio_attr_write_raw(const struct iio_attr *attr, const void *src, size_t len);
435
441#ifndef __cplusplus
442#define iio_attr_write(attr, val) \
443 _Generic((val), \
444 const char *: iio_attr_write_string, \
445 char *: iio_attr_write_string, \
446 bool: iio_attr_write_bool, \
447 long long: iio_attr_write_longlong, \
448 double: iio_attr_write_double)(attr, val)
449#endif /* __cplusplus */
450
454__api __pure const char *
455 iio_attr_get_name(const struct iio_attr *attr);
456
460__api __check_ret __pure const char *
461 iio_attr_get_filename(const struct iio_attr *attr);
462
467__api __pure const char *
468 iio_attr_get_static_value(const struct iio_attr *attr);
469
479__api int
480 iio_attr_get_range(const struct iio_attr *attr, double *min, double *step, double *max);
481
493__api int
494 iio_attr_get_available(const struct iio_attr *attr, char ***list, size_t *count);
495
518__api int
519 iio_attr_get_available_buf(const struct iio_attr *attr, char *buf,
520 size_t buflen, char **list, size_t *count);
521
526__api
527void iio_available_list_free(char **list, size_t count);
528
/* ------------------------------------------------------------------*/
530/* ------------------------- Scan functions ----------------------------------*/
552__api __check_ret struct iio_scan *
553 iio_scan(const struct iio_context_params *params, const char *backends);
554
555
560__api void iio_scan_destroy(struct iio_scan *ctx);
561
562
567__api __check_ret __pure size_t
568 iio_scan_get_results_count(const struct iio_scan *ctx);
569
570
576__api __check_ret __pure const char *
577 iio_scan_get_description(const struct iio_scan *ctx, size_t idx);
578
579
585__api __check_ret __pure const char *
586 iio_scan_get_uri(const struct iio_scan *ctx, size_t idx);
587
588
/* ------------------------------------------------------------------*/
590/* ------------------------- Top-level functions -----------------------------*/
600__api void iio_strerror(int err, char *dst, size_t len);
601
602
608__api __check_ret bool
609 iio_has_backend(const struct iio_context_params *params, const char *backend);
610
611
614__api __check_ret __cnst unsigned int
615 iio_get_builtin_backends_count(void);
616
617
622__api __check_ret __cnst const char *
623 iio_get_builtin_backend(unsigned int index);
624
625
/* ------------------------------------------------------------------*/
627/* ------------------------- Context functions -------------------------------*/
682__api __check_ret struct iio_context *
683 iio_create_context(const struct iio_context_params *params, const char *uri);
684
685
690__api void iio_context_destroy(struct iio_context *ctx);
691
692
699__api __pure unsigned int iio_context_get_version_major(const struct iio_context *ctx);
700
701
708__api __pure unsigned int iio_context_get_version_minor(const struct iio_context *ctx);
709
710
717__api __pure const char * iio_context_get_version_tag(const struct iio_context *ctx);
718
719
724__api __check_ret char * iio_context_get_xml(const struct iio_context *ctx);
725
726
734__api __check_ret __pure const char * iio_context_get_name(const struct iio_context *ctx);
735
736
743__api __check_ret __pure const char * iio_context_get_description(
744 const struct iio_context *ctx);
745
746
752__api __check_ret __pure unsigned int iio_context_get_attrs_count(
753 const struct iio_context *ctx);
754
755
761__api __check_ret __pure const struct iio_attr *
762 iio_context_get_attr(const struct iio_context *ctx, unsigned int index);
763
764
772__api __check_ret __pure const struct iio_attr *
773 iio_context_find_attr(const struct iio_context *ctx, const char *name);
774
775
779__api __check_ret __pure unsigned int iio_context_get_devices_count(
780 const struct iio_context *ctx);
781
782
788__api __check_ret __pure struct iio_device * iio_context_get_device(
789 const struct iio_context *ctx, unsigned int index);
790
791
799__api __check_ret __pure struct iio_device * iio_context_find_device(
800 const struct iio_context *ctx, const char *name);
801
802
810__api __check_ret int iio_context_set_timeout(
811 struct iio_context *ctx, unsigned int timeout_ms);
812
813
817__api __cnst const struct iio_context_params *
818 iio_context_get_params(const struct iio_context *ctx);
819
820
824__api void iio_context_set_data(struct iio_context *ctx, void *data);
825
826
830__api void * iio_context_get_data(const struct iio_context *ctx);
831
832
/* ------------------------------------------------------------------*/
834/* ------------------------- Device functions --------------------------------*/
844__api __check_ret __pure const struct iio_context * iio_device_get_context(
845 const struct iio_device *dev);
846
847
851__api __check_ret __pure const char * iio_device_get_id(const struct iio_device *dev);
852
853
859__api __check_ret __pure const char * iio_device_get_name(const struct iio_device *dev);
860
861
867__api __check_ret __pure const char * iio_device_get_label(const struct iio_device *dev);
868
869
873__api __check_ret __pure unsigned int iio_device_get_channels_count(
874 const struct iio_device *dev);
875
876
880__api __check_ret __pure unsigned int
881 iio_device_get_attrs_count(const struct iio_device *dev);
882
886__api __check_ret __pure unsigned int
887 iio_device_get_buffers_count(const struct iio_device *dev);
888
894__api __check_ret __pure struct iio_channel * iio_device_get_channel(
895 const struct iio_device *dev, unsigned int index);
896
897
903__api __check_ret __pure const struct iio_attr *
904 iio_device_get_attr(const struct iio_device *dev, unsigned int index);
905
911__api __check_ret __pure struct iio_buffer * iio_device_get_buffer(
912 const struct iio_device *dev, unsigned int index);
913
922__api __check_ret __pure struct iio_channel * iio_device_find_channel(
923 const struct iio_device *dev, const char *name, bool output);
924
925
937__api __check_ret __pure const struct iio_attr *
938 iio_device_find_attr(const struct iio_device *dev, const char *name);
939
940
944__api void iio_device_set_data(struct iio_device *dev, void *data);
945
946
950__api void * iio_device_get_data(const struct iio_device *dev);
951
952
960__api __check_ret const struct iio_device *
961 iio_device_get_trigger(const struct iio_device *dev);
962
963
970__api __check_ret int iio_device_set_trigger(const struct iio_device *dev,
971 const struct iio_device *trigger);
972
973
977__api __check_ret __pure bool iio_device_is_trigger(const struct iio_device *dev);
978
979
/* ------------------------------------------------------------------*/
981/* ------------------------- Channel functions -------------------------------*/
991__api __check_ret __pure const struct iio_device * iio_channel_get_device(
992 const struct iio_channel *chn);
993
994
998__api __check_ret __pure const char * iio_channel_get_id(const struct iio_channel *chn);
999
1000
1006__api __check_ret __pure const char * iio_channel_get_name(const struct iio_channel *chn);
1007
1013__api __check_ret __pure const char * iio_channel_get_label(const struct iio_channel *chn);
1014
1018__api __check_ret __pure bool iio_channel_is_output(const struct iio_channel *chn);
1019
1020
1028__api __check_ret __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
1029
1030
1034__api __check_ret __pure unsigned int
1035 iio_channel_get_attrs_count(const struct iio_channel *chn);
1036
1037
1043__api __check_ret __pure const struct iio_attr *
1044 iio_channel_get_attr(const struct iio_channel *chn, unsigned int index);
1045
1046
1054__api __check_ret __pure const struct iio_attr *
1055 iio_channel_find_attr(const struct iio_channel *chn, const char *name);
1056
1057
1061__api void iio_channel_enable(const struct iio_channel *chn,
1062 struct iio_channels_mask *mask);
1063
1064
1068__api void iio_channel_disable(const struct iio_channel *chn,
1069 struct iio_channels_mask *mask);
1070
1071
1076__api __check_ret bool
1077 iio_channel_is_enabled(const struct iio_channel *chn,
1078 const struct iio_channels_mask *mask);
1079
1080
1090__api __check_ret size_t iio_channel_read(const struct iio_channel *chn,
1091 const struct iio_block *block,
1092 void *dst, size_t len, bool raw);
1093
1094
1104__api __check_ret size_t iio_channel_write(const struct iio_channel *chn,
1105 struct iio_block *block,
1106 const void *src, size_t len,
1107 bool raw);
1108
1109
1113__api void iio_channel_set_data(struct iio_channel *chn, void *data);
1114
1115
1119__api void * iio_channel_get_data(const struct iio_channel *chn);
1120
1121
1127__api __check_ret __pure enum iio_chan_type iio_channel_get_type(
1128 const struct iio_channel *chn);
1129
1130
1134__api __check_ret __pure enum iio_modifier iio_channel_get_modifier(
1135 const struct iio_channel *chn);
1136
1137
/* ------------------------------------------------------------------*/
1139/* ------------------------- Buffer functions --------------------------------*/
1149__api __check_ret __pure const struct iio_device * iio_buffer_get_device(
1150 const struct iio_buffer *buf);
1151
1152
1156__api __check_ret __pure unsigned int
1157 iio_buffer_get_attrs_count(const struct iio_buffer *buf);
1158
1159
1165__api __check_ret __pure const struct iio_attr *
1166 iio_buffer_get_attr(const struct iio_buffer *buf, unsigned int index);
1167
1168
1176__api __check_ret __pure const struct iio_attr *
1177 iio_buffer_find_attr(const struct iio_buffer *buf, const char *name);
1178
1179
1183__api __check_ret __pure bool iio_buffer_is_output(const struct iio_buffer *buf);
1184
1185
1189__api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1190
1191
1195__api void * iio_buffer_get_data(const struct iio_buffer *buf);
1196
1197
1198/* ------------------------- Buffer Stream functions -------------------------*/
1211__api __check_ret struct iio_buffer_stream *
1212 iio_buffer_open(struct iio_buffer *buf, const struct iio_channels_mask *mask);
1213
1214
1217__api void iio_buffer_close(struct iio_buffer_stream *buf_stream);
1218
1219
1222__api void iio_buffer_stream_cancel(struct iio_buffer_stream *buf_stream);
1223
1224
1229__api __check_ret int iio_buffer_stream_start(struct iio_buffer_stream *buf_stream);
1230
1231
1236__api int iio_buffer_stream_stop(struct iio_buffer_stream *buf_stream);
1237
1238
1242__api const struct iio_channels_mask *
1243 iio_buffer_stream_get_channels_mask(const struct iio_buffer_stream *buf_stream);
1244
/* ------------------------------------------------------------------*/
1246/* -------------------------- Block functions --------------------------------*/
1258__api __check_ret struct iio_block *
1259 iio_buffer_stream_create_block(struct iio_buffer_stream *buf_stream, size_t size);
1260
1261
1264__api void iio_block_destroy(struct iio_block *block);
1265
1266
1272__api __check_ret int iio_block_get_dmabuf_fd(const struct iio_block *block);
1273
1274
1283__api int iio_block_disable_cpu_access(struct iio_block *block, bool disable);
1284
1285
1289__api void *iio_block_start(const struct iio_block *block);
1290
1291
1313__api void *iio_block_first(const struct iio_block *block,
1314 const struct iio_channel *chn);
1315
1316
1321__api void *iio_block_end(const struct iio_block *block);
1322
1323
1337__api __check_ret ssize_t
1338iio_block_foreach_sample(const struct iio_block *block,
1339 const struct iio_channels_mask *mask,
1340 ssize_t (*callback)(const struct iio_channel *chn,
1341 void *src, size_t bytes, void *d),
1342 void *data);
1343
1344
1356__api int iio_block_enqueue(struct iio_block *block, size_t bytes_used, bool cyclic);
1357
1358
1365__api int iio_block_dequeue(struct iio_block *block, bool nonblock);
1366
1367
1371__api struct iio_buffer_stream * iio_block_get_buffer_stream(const struct iio_block *block);
1372
/* ------------------------------------------------------------------*/
1374/* ------------------------- Stream functions --------------------------------*/
1389__api __check_ret struct iio_stream *
1390 iio_buffer_create_stream(struct iio_buffer *buffer, size_t nb_blocks,
1391 size_t samples_count, struct iio_channels_mask *mask);
1392
1395__api void
1396 iio_stream_cancel(struct iio_stream *stream);
1397
1400__api void
1401 iio_stream_destroy(struct iio_stream *stream);
1402
1403
1404
1409__api __check_ret const struct iio_block *
1410 iio_stream_get_next_block(struct iio_stream *stream);
1411
1412
/* ------------------------------------------------------------------*/
1414/* ---------------------------- HWMON support --------------------------------*/
1427 enum hwmon_chan_type {
1428 HWMON_VOLTAGE,
1429 HWMON_FAN,
1430 HWMON_PWM,
1431 HWMON_TEMP,
1432 HWMON_CURRENT,
1433 HWMON_POWER,
1434 HWMON_ENERGY,
1435 HWMON_HUMIDITY,
1436 HWMON_INTRUSION,
1437 HWMON_CHAN_TYPE_UNKNOWN = IIO_CHAN_TYPE_UNKNOWN,
1438};
1439
1446static inline enum hwmon_chan_type
1447hwmon_channel_get_type(const struct iio_channel *chn)
1448{
1449 return (enum hwmon_chan_type) iio_channel_get_type(chn);
1450}
1451
1457static inline bool iio_device_is_hwmon(const struct iio_device *dev)
1458{
1459 const char *id = iio_device_get_id(dev);
1460
1461 return id[0] == 'h';
1462}
1463
1464
/* ------------------------------------------------------------------*/
1466/* ---------------------------- IIO events support ---------------------------*/
1474 struct iio_event {
1475 uint64_t id;
1476 int64_t timestamp;
1477};
1478
1486static inline enum iio_event_type
1487iio_event_get_type(const struct iio_event *event)
1488{
1489 return (enum iio_event_type)((event->id >> 56) & 0xff);
1490}
1491
1499static inline enum iio_event_direction
1500iio_event_get_direction(const struct iio_event *event)
1501{
1502 return (enum iio_event_direction)((event->id >> 48) & 0x7f);
1503}
1504
1512__api __check_ret const struct iio_channel *
1513 iio_event_get_channel(const struct iio_event *event,
1514 const struct iio_device *dev, bool diff);
1515
1521__api __check_ret struct iio_event_stream *
1522 iio_device_create_event_stream(const struct iio_device *dev);
1523
1527__api void iio_event_stream_destroy(struct iio_event_stream *stream);
1528
1542__api int iio_event_stream_read(struct iio_event_stream *stream,
1543 struct iio_event *out_event,
1544 bool nonblock);
1545
/* ------------------------------------------------------------------*/
1547/* ------------------------- Low-level functions -----------------------------*/
1557 struct iio_data_format {
1559 unsigned int length;
1560
1562 unsigned int bits;
1563
1565 unsigned int shift;
1566
1568 bool is_signed;
1569
1571 bool is_fully_defined;
1572
1574 bool is_be;
1575
1577 bool with_scale;
1578
1580 double scale;
1581
1583 unsigned int repeat;
1584
1587 double offset;
1588};
1589
1590
1595__api struct iio_channels_mask *
1596 iio_create_channels_mask(unsigned int nb_channels);
1597
1598
1601__api void
1602 iio_channels_mask_destroy(struct iio_channels_mask *mask);
1603
1604
1613__api __check_ret ssize_t
1614 iio_device_get_sample_size(const struct iio_device *dev,
1615 const struct iio_channels_mask *mask);
1616
1617
1622__api __check_ret __pure long iio_channel_get_index(const struct iio_channel *chn);
1623
1624
1628__api __check_ret __cnst const struct iio_data_format * iio_channel_get_data_format(
1629 const struct iio_channel *chn);
1630
1631
1637__api void iio_channel_convert(const struct iio_channel *chn,
1638 void *dst, const void *src);
1639
1640
1646__api void iio_channel_convert_inverse(const struct iio_channel *chn,
1647 void *dst, const void *src);
1648
1649
1653__api __check_ret __pure unsigned int
1654 iio_device_get_debug_attrs_count(const struct iio_device *dev);
1655
1656
1662__api __check_ret __pure const struct iio_attr *
1663 iio_device_get_debug_attr(const struct iio_device *dev, unsigned int index);
1664
1665
1673__api __check_ret __pure const struct iio_attr *
1674 iio_device_find_debug_attr(const struct iio_device *dev, const char *name);
1675
1676
1683__api __check_ret int iio_device_reg_write(struct iio_device *dev,
1684 uint32_t address, uint32_t value);
1685
1686
1693__api __check_ret int iio_device_reg_read(struct iio_device *dev,
1694 uint32_t address, uint32_t *value);
1695
1696
1699#ifndef DOXYGEN
1700/* These functions can be used directly, but should be used through the generic
1701 * macros iio_attr_{read,write}() */
1702
1703__api __check_ret int
1704iio_attr_read_bool(const struct iio_attr *attr, bool *val);
1705
1706__api __check_ret int
1707iio_attr_read_longlong(const struct iio_attr *attr, long long *val);
1708
1709__api __check_ret int
1710iio_attr_read_double(const struct iio_attr *attr, double *val);
1711
1712__api __check_ret ssize_t
1713iio_attr_write_string(const struct iio_attr *attr, const char *src);
1714
1715__api __check_ret int
1716iio_attr_write_bool(const struct iio_attr *attr, bool val);
1717
1718__api __check_ret int
1719iio_attr_write_longlong(const struct iio_attr *attr, long long val);
1720
1721__api __check_ret int
1722iio_attr_write_double(const struct iio_attr *attr, double val);
1723
1724#endif /* DOXYGEN */
1725
1726#ifdef __cplusplus
1727}
1728#endif
1729
1730#undef __api
1731
1732#endif /* __IIO_H__ */
iio_attr_get_filename
__api __check_ret __pure const char * iio_attr_get_filename(const struct iio_attr *attr)
Retrieve the filename of an attribute.
Definition attr.c:165
iio_attr_write_raw
__api __check_ret ssize_t iio_attr_write_raw(const struct iio_attr *attr, const void *src, size_t len)
Set the value of the given attribute.
Definition attr.c:83
iio_attr_get_name
__api __pure const char * iio_attr_get_name(const struct iio_attr *attr)
Retrieve the name of an attribute.
Definition attr.c:159
iio_attr_get_static_value
__api __pure const char * iio_attr_get_static_value(const struct iio_attr *attr)
Retrieve the static value of an attribute.
Definition attr.c:171
iio_attr_get_available
__api int iio_attr_get_available(const struct iio_attr *attr, char ***list, size_t *count)
Extract the list of elements from an attribute with suffix '_available'.
Definition attr.c:402
iio_attr_get_available_buf
__api int iio_attr_get_available_buf(const struct iio_attr *attr, char *buf, size_t buflen, char **list, size_t *count)
A variant of iio_attr_get_available() that uses a caller-supplied, preallocated buffer....
Definition attr.c:486
iio_attr_read_raw
__api __check_ret ssize_t iio_attr_read_raw(const struct iio_attr *attr, char *dst, size_t len)
Read the content of the given attribute.
Definition attr.c:24
iio_available_list_free
__api void iio_available_list_free(char **list, size_t count)
Free the resources allocated only by iio_attr_get_available()
Definition attr.c:474
iio_attr_get_range
__api int iio_attr_get_range(const struct iio_attr *attr, double *min, double *step, double *max)
Extract the range from an attribute with suffix '_available'.
Definition attr.c:350
iio_block_start
__api void * iio_block_start(const struct iio_block *block)
Get the start address of the block.
Definition block.c:198
iio_block_disable_cpu_access
__api int iio_block_disable_cpu_access(struct iio_block *block, bool disable)
Disable CPU access of a given block.
Definition block.c:313
iio_block_get_dmabuf_fd
__api __check_ret int iio_block_get_dmabuf_fd(const struct iio_block *block)
Get the file descriptor of the underlying DMABUF object.
Definition block.c:308
iio_block_destroy
__api void iio_block_destroy(struct iio_block *block)
Destroy the given block.
Definition block.c:89
iio_buffer_stream_create_block
__api __check_ret struct iio_block * iio_buffer_stream_create_block(struct iio_buffer_stream *buf_stream, size_t size)
Create a data block for the given buffer stream.
Definition block.c:29
iio_block_first
__api void * iio_block_first(const struct iio_block *block, const struct iio_channel *chn)
Find the first sample of a channel in a block.
Definition block.c:208
iio_block_enqueue
__api int iio_block_enqueue(struct iio_block *block, size_t bytes_used, bool cyclic)
Enqueue the given iio_block to the buffer's queue.
Definition block.c:143
iio_block_foreach_sample
__api __check_ret ssize_t iio_block_foreach_sample(const struct iio_block *block, const struct iio_channels_mask *mask, 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 block.
iio_block_dequeue
__api int iio_block_dequeue(struct iio_block *block, bool nonblock)
Dequeue the given iio_block from the buffer's queue.
Definition block.c:170
iio_block_end
__api void * iio_block_end(const struct iio_block *block)
Get the address after the last sample in a block.
Definition block.c:203
iio_block_get_buffer_stream
__api struct iio_buffer_stream * iio_block_get_buffer_stream(const struct iio_block *block)
Retrieve a pointer to the iio_buffer_stream structure.
Definition block.c:303
iio_buffer_stream_get_channels_mask
__api const struct iio_channels_mask * iio_buffer_stream_get_channels_mask(const struct iio_buffer_stream *buf_stream)
Retrieve the channels mask of a buffer stream.
Definition buffer.c:202
iio_buffer_open
__api __check_ret struct iio_buffer_stream * iio_buffer_open(struct iio_buffer *buf, const struct iio_channels_mask *mask)
Open a buffer for data streaming.
Definition buffer.c:124
iio_buffer_stream_stop
__api int iio_buffer_stream_stop(struct iio_buffer_stream *buf_stream)
Stop the buffer stream.
Definition buffer.c:105
iio_buffer_stream_start
__api __check_ret int iio_buffer_stream_start(struct iio_buffer_stream *buf_stream)
Start the buffer stream.
Definition buffer.c:86
iio_buffer_stream_cancel
__api void iio_buffer_stream_cancel(struct iio_buffer_stream *buf_stream)
Cancel all buffer stream operations.
Definition buffer.c:55
iio_buffer_close
__api void iio_buffer_close(struct iio_buffer_stream *buf_stream)
Close a buffer stream.
Definition buffer.c:186
iio_buffer_set_data
__api void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Associate a pointer to an iio_buffer structure.
Definition buffer.c:18
iio_data_format::is_signed
bool is_signed
Contains True if the sample is signed.
Definition iio.h:1568
iio_buffer_find_attr
__api __check_ret __pure const struct iio_attr * iio_buffer_find_attr(const struct iio_buffer *buf, const char *name)
Try to find a buffer-specific attribute by its name.
Definition buffer.c:219
iio_data_format::is_be
bool is_be
Contains True if the sample is in big-endian format.
Definition iio.h:1574
iio_data_format::with_scale
bool with_scale
Contains True if the sample should be scaled when converted.
Definition iio.h:1577
iio_context_params::flags
unsigned int flags
Flags that control context behavior. Bitmask of values from enum iio_context_flags.
Definition iio.h:199
iio_buffer_get_attrs_count
__api __check_ret __pure unsigned int iio_buffer_get_attrs_count(const struct iio_buffer *buf)
Enumerate the attributes of the given buffer.
Definition buffer.c:207
iio_data_format::scale
double scale
Contains the scale to apply if with_scale is set.
Definition iio.h:1580
iio_context_params::err
FILE * err
Handle to the error output. If NULL, defaults to stderr.
Definition iio.h:172
iio_context_params::__rsrv
char __rsrv[32]
Reserved for future fields.
Definition iio.h:202
iio_buffer_is_output
__api __check_ret __pure bool iio_buffer_is_output(const struct iio_buffer *buf)
Returns true if the buffer is an output buffer.
Definition buffer.c:28
iio_data_format::repeat
unsigned int repeat
Number of times length repeats (added in v0.8)
Definition iio.h:1583
iio_context_params::log_level
enum iio_log_level log_level
Log level to use. Defaults to the log level that was specified at compilation.
Definition iio.h:176
iio_data_format::length
unsigned int length
Total length of the sample, in bits.
Definition iio.h:1559
iio_context_params::timestamp_level
enum iio_log_level timestamp_level
Under this log level (excluded), messages are sent without timestamp; above this log level (included)...
Definition iio.h:189
iio_data_format::is_fully_defined
bool is_fully_defined
Contains True if the sample is fully defined, sign extended, etc.
Definition iio.h:1571
iio_context_params::stderr_level
enum iio_log_level stderr_level
Under this log level (included), messages are sent to the error output ; above this log level (exclud...
Definition iio.h:182
iio_context_params::out
FILE * out
Handle to the standard output. If NULL, defaults to stdout.
Definition iio.h:169
iio_buffer_get_device
__api __check_ret __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:50
iio_buffer_get_attr
__api __check_ret __pure const struct iio_attr * iio_buffer_get_attr(const struct iio_buffer *buf, unsigned int index)
Get the buffer-specific attribute present at the given index.
Definition buffer.c:213
iio_data_format::shift
unsigned int shift
Right-shift to apply when converting sample.
Definition iio.h:1565
iio_data_format::offset
double offset
Contains a value to be added to the raw sample before applying the scale.
Definition iio.h:1587
iio_data_format::bits
unsigned int bits
Length of valuable data in the sample, in bits.
Definition iio.h:1562
IIO_CTX_XML_INCLUDE_VALUES
@ IIO_CTX_XML_INCLUDE_VALUES
Include values in XML output When set, iio_context_get_xml() will read and serialize attribute values...
Definition iio.h:157
iio_buffer_get_data
__api void * iio_buffer_get_data(const struct iio_buffer *buf)
Retrieve a previously associated pointer of an iio_buffer structure.
Definition buffer.c:23
iio_context_params::timeout_ms
int timeout_ms
Timeout for I/O operations in milliseconds.
Definition iio.h:195
iio_channel_is_scan_element
__api __check_ret __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:365
iio_channel_disable
__api void iio_channel_disable(const struct iio_channel *chn, struct iio_channels_mask *mask)
Disable the given channel.
Definition channel.c:451
iio_channel_get_attrs_count
__api __check_ret __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:380
iio_channel_get_type
__api __check_ret __pure enum iio_chan_type iio_channel_get_type(const struct iio_channel *chn)
Get the type of the given channel.
Definition channel.c:375
iio_channel_read
__api __check_ret size_t iio_channel_read(const struct iio_channel *chn, const struct iio_block *block, void *dst, size_t len, bool raw)
Demultiplex and convert the samples of a given channel.
Definition channel.c:627
iio_channel_is_output
__api __check_ret __pure bool iio_channel_is_output(const struct iio_channel *chn)
Return True if the given channel is an output channel.
Definition channel.c:360
iio_channel_get_data
__api void * iio_channel_get_data(const struct iio_channel *chn)
Retrieve a previously associated pointer of an iio_channel structure.
Definition channel.c:422
iio_channel_enable
__api void iio_channel_enable(const struct iio_channel *chn, struct iio_channels_mask *mask)
Enable the given channel.
Definition channel.c:444
iio_channel_write
__api __check_ret size_t iio_channel_write(const struct iio_channel *chn, struct iio_block *block, const void *src, size_t len, bool raw)
Convert and multiplex the samples of a given channel.
Definition channel.c:668
iio_channel_get_modifier
__api __check_ret __pure enum iio_modifier iio_channel_get_modifier(const struct iio_channel *chn)
Get the modifier type of the given channel.
Definition channel.c:370
iio_channel_get_attr
__api __check_ret __pure const struct iio_attr * 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:386
iio_channel_set_data
__api void iio_channel_set_data(struct iio_channel *chn, void *data)
Associate a pointer to an iio_channel structure.
Definition channel.c:417
iio_channel_get_device
__api __check_ret __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:708
iio_channel_get_label
__api __check_ret __pure const char * iio_channel_get_label(const struct iio_channel *chn)
Retrieve the channel label (e.g. anglY)
Definition channel.c:355
iio_channel_get_id
__api __check_ret __pure const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition channel.c:345
iio_channel_is_enabled
__api __check_ret bool iio_channel_is_enabled(const struct iio_channel *chn, const struct iio_channels_mask *mask)
Returns True if the channel is enabled.
Definition channel.c:438
iio_channel_find_attr
__api __check_ret __pure const struct iio_attr * 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:392
iio_channel_get_name
__api __check_ret __pure const char * iio_channel_get_name(const struct iio_channel *chn)
Retrieve the channel name (e.g. vccint)
Definition channel.c:350
iio_context_get_description
__api __check_ret __pure const char * iio_context_get_description(const struct iio_context *ctx)
Get a description of the given context.
Definition compat.c:686
iio_context_find_device
__api __check_ret __pure struct iio_device * iio_context_find_device(const struct iio_context *ctx, const char *name)
Try to find a device structure by its ID, label or name.
Definition compat.c:710
iio_context_get_params
__api __cnst const struct iio_context_params * iio_context_get_params(const struct iio_context *ctx)
Get a pointer to the params structure.
Definition context.c:517
iio_create_context
__api __check_ret struct iio_context * iio_create_context(const struct iio_context_params *params, const char *uri)
Create a context from a URI description.
Definition context.c:716
iio_context_get_attr
__api __check_ret __pure const struct iio_attr * iio_context_get_attr(const struct iio_context *ctx, unsigned int index)
Retrieve the context-specific attribute at the given index.
Definition context.c:788
iio_context_destroy
__api void iio_context_destroy(struct iio_context *ctx)
Destroy the given context.
Definition compat.c:434
iio_context_get_version_minor
__api __pure unsigned int iio_context_get_version_minor(const struct iio_context *ctx)
Get the minor number of the library version.
Definition context.c:626
iio_context_get_device
__api __check_ret __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 compat.c:703
iio_context_get_version_major
__api __pure unsigned int iio_context_get_version_major(const struct iio_context *ctx)
Get the major number of the library version.
Definition context.c:618
iio_context_get_data
__api void * iio_context_get_data(const struct iio_context *ctx)
Retrieve a previously associated pointer of an iio_context structure.
Definition context.c:936
iio_context_get_attrs_count
__api __check_ret __pure unsigned int iio_context_get_attrs_count(const struct iio_context *ctx)
Get the number of context-specific attributes.
Definition compat.c:720
iio_context_get_version_tag
__api __pure const char * iio_context_get_version_tag(const struct iio_context *ctx)
Get the git hash string of the library version.
Definition context.c:634
iio_context_get_devices_count
__api __check_ret __pure unsigned int iio_context_get_devices_count(const struct iio_context *ctx)
Enumerate the devices found in the given context.
Definition compat.c:698
iio_context_get_name
__api __check_ret __pure const char * iio_context_get_name(const struct iio_context *ctx)
Get the name of the given context.
Definition compat.c:681
iio_context_set_timeout
__api __check_ret int iio_context_set_timeout(struct iio_context *ctx, unsigned int timeout_ms)
Set a timeout for I/O operations.
Definition compat.c:715
iio_context_find_attr
__api __check_ret __pure const struct iio_attr * iio_context_find_attr(const struct iio_context *ctx, const char *name)
Try to find a context-specific attribute by its name.
Definition context.c:794
iio_context_set_data
__api void iio_context_set_data(struct iio_context *ctx, void *data)
Associate a pointer to an iio_context structure.
Definition context.c:931
iio_context_get_xml
__api __check_ret char * iio_context_get_xml(const struct iio_context *ctx)
Obtain a XML representation of the given context.
Definition compat.c:691
iio_device_reg_write
__api __check_ret int iio_device_reg_write(struct iio_device *dev, uint32_t address, uint32_t value)
Set the value of a hardware register.
Definition compat.c:851
iio_create_channels_mask
__api struct iio_channels_mask * iio_create_channels_mask(unsigned int nb_channels)
Create a new empty channels mask.
Definition mask.c:14
iio_device_get_sample_size
__api __check_ret ssize_t iio_device_get_sample_size(const struct iio_device *dev, const struct iio_channels_mask *mask)
Get the current sample size.
Definition device.c:359
iio_device_reg_read
__api __check_ret int iio_device_reg_read(struct iio_device *dev, uint32_t address, uint32_t *value)
Get the value of a hardware register.
Definition compat.c:845
iio_channels_mask_destroy
__api void iio_channels_mask_destroy(struct iio_channels_mask *mask)
Destroy a channels mask.
Definition mask.c:40
iio_channel_get_data_format
__api __check_ret __cnst const struct iio_data_format * iio_channel_get_data_format(const struct iio_channel *chn)
Get a pointer to a channel's data format structure.
Definition channel.c:432
iio_device_get_debug_attrs_count
__api __check_ret __pure unsigned int iio_device_get_debug_attrs_count(const struct iio_device *dev)
Enumerate the debug attributes of the given device.
Definition compat.c:934
iio_device_get_debug_attr
__api __check_ret __pure const struct iio_attr * iio_device_get_debug_attr(const struct iio_device *dev, unsigned int index)
Get the debug attribute present at the given index.
Definition compat.c:939
iio_device_find_debug_attr
__api __check_ret __pure const struct iio_attr * iio_device_find_debug_attr(const struct iio_device *dev, const char *name)
Try to find a debug attribute by its name.
Definition compat.c:951
iio_channel_convert_inverse
__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:587
iio_channel_convert
__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:555
iio_channel_get_index
__api __check_ret __pure long iio_channel_get_index(const struct iio_channel *chn)
Get the index of the given channel.
Definition channel.c:427
iio_device_get_attr
__api __check_ret __pure const struct iio_attr * iio_device_get_attr(const struct iio_device *dev, unsigned int index)
Get the device-specific attribute present at the given index.
Definition compat.c:867
iio_device_get_buffer
__api __check_ret __pure struct iio_buffer * iio_device_get_buffer(const struct iio_device *dev, unsigned int index)
Get the buffer present at the given index.
Definition device.c:254
iio_device_get_context
__api __check_ret __pure const struct iio_context * iio_device_get_context(const struct iio_device *dev)
Retrieve a pointer to the iio_context structure.
Definition compat.c:754
iio_device_get_buffers_count
__api __check_ret __pure unsigned int iio_device_get_buffers_count(const struct iio_device *dev)
Enumerate the buffers of the given device.
Definition device.c:249
iio_device_get_id
__api __check_ret __pure const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition compat.c:759
iio_device_get_trigger
__api __check_ret const struct iio_device * iio_device_get_trigger(const struct iio_device *dev)
Retrieve the trigger of a given device.
Definition device.c:319
iio_device_get_attrs_count
__api __check_ret __pure unsigned int iio_device_get_attrs_count(const struct iio_device *dev)
Enumerate the device-specific attributes of the given device.
Definition compat.c:862
iio_device_find_channel
__api __check_ret __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 ID, label or name.
Definition compat.c:969
iio_device_set_trigger
__api __check_ret int iio_device_set_trigger(const struct iio_device *dev, const struct iio_device *trigger)
Associate a trigger to a given device.
Definition compat.c:1606
iio_device_get_label
__api __check_ret __pure const char * iio_device_get_label(const struct iio_device *dev)
Retrieve the device label (e.g. lo_pll0_rx_adf4351)
Definition compat.c:769
iio_device_is_trigger
__api __check_ret __pure bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition compat.c:1613
iio_device_find_attr
__api __check_ret __pure const struct iio_attr * iio_device_find_attr(const struct iio_device *dev, const char *name)
Try to find a device-specific attribute by its name.
Definition compat.c:879
iio_device_get_data
__api void * iio_device_get_data(const struct iio_device *dev)
Retrieve a previously associated pointer of an iio_device structure.
Definition compat.c:774
iio_device_get_channel
__api __check_ret __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 compat.c:963
iio_device_set_data
__api void iio_device_set_data(struct iio_device *dev, void *data)
Associate a pointer to an iio_device structure.
Definition compat.c:781
iio_device_get_name
__api __check_ret __pure const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition compat.c:764
iio_device_get_channels_count
__api __check_ret __pure unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition compat.c:857
iio_event_stream_read
__api int iio_event_stream_read(struct iio_event_stream *stream, struct iio_event *out_event, bool nonblock)
Read an event from the event stream.
Definition events.c:133
iio_event_stream_destroy
__api void iio_event_stream_destroy(struct iio_event_stream *stream)
Destroy the given event stream.
Definition events.c:125
iio_event_get_channel
__api __check_ret const struct iio_channel * iio_event_get_channel(const struct iio_event *event, const struct iio_device *dev, bool diff)
Get a pointer to the IIO channel that corresponds to this event.
Definition events.c:52
iio_device_create_event_stream
__api __check_ret struct iio_event_stream * iio_device_create_event_stream(const struct iio_device *dev)
Create an events stream for the given IIO device.
Definition events.c:101
hwmon_chan_type
hwmon_chan_type
Hwmon channel type.
Definition iio.h:1427
iio_scan_get_results_count
__api __check_ret __pure size_t iio_scan_get_results_count(const struct iio_scan *ctx)
Get number of results of a scan operation.
Definition scan.c:148
iio_scan_get_description
__api __check_ret __pure const char * iio_scan_get_description(const struct iio_scan *ctx, size_t idx)
Get description of scanned context.
Definition scan.c:154
iio_scan
struct iio_scan * iio_scan(const struct iio_context_params *params, const char *backends)
Scan backends for IIO contexts.
Definition scan.c:21
iio_scan_destroy
__api void iio_scan_destroy(struct iio_scan *ctx)
Destroy the given scan context.
Definition scan.c:135
iio_scan_get_uri
__api __check_ret __pure const char * iio_scan_get_uri(const struct iio_scan *ctx, size_t idx)
Get URI of scanned context.
Definition scan.c:162
iio_stream_destroy
__api void iio_stream_destroy(struct iio_stream *stream)
Destroy the given stream object.
Definition stream.c:86
iio_buffer_create_stream
__api __check_ret struct iio_stream * iio_buffer_create_stream(struct iio_buffer *buffer, size_t nb_blocks, size_t samples_count, struct iio_channels_mask *mask)
Create a iio_stream object for the given iio_buffer.
Definition stream.c:26
iio_stream_cancel
__api void iio_stream_cancel(struct iio_stream *stream)
Cancel all stream operations.
Definition stream.c:81
iio_stream_get_next_block
__api __check_ret const struct iio_block * iio_stream_get_next_block(struct iio_stream *stream)
Get a pointer to the next data block.
Definition stream.c:110
iio_has_backend
__api __check_ret bool iio_has_backend(const struct iio_context_params *params, const char *backend)
Check if the specified backend is available.
Definition backend.c:40
iio_strerror
__api void iio_strerror(int err, char *dst, size_t len)
Get a string description of an error code.
Definition compat.c:1991
iio_get_builtin_backends_count
__api __check_ret __cnst unsigned int iio_get_builtin_backends_count(void)
Get the number of available built-in backends.
Definition backend.c:15
iio_get_builtin_backend
__api __check_ret __cnst const char * iio_get_builtin_backend(unsigned int index)
Retrieve the name of a given built-in backend.
Definition backend.c:25
iio_event_type
iio_event_type
IIO event type.
Definition iio.h:338
iio_chan_type
iio_chan_type
IIO channel type.
Definition iio.h:219
iio_event_direction
iio_event_direction
IIO event direction.
Definition iio.h:356
iio_modifier
iio_modifier
IIO channel modifier.
Definition iio.h:271
iio_context_flags
iio_context_flags
Flags controlling context behavior;.
Definition iio.h:153
iio_log_level
iio_log_level
Level of verbosity of libiio's log output.
Definition iio.h:132
iio_attr
Structure holding meta-data for an attribute.
Definition iio-backend.h:83
iio_buffer_stream
An opened buffer ready for data streaming.
iio_buffer
An input or output buffer, used to read or write samples.
iio_channel
Represents an input or output channel of a device.
iio_context_params
IIO context creation information.
Definition iio.h:167
iio_context
Contains the representation of an IIO context.
iio_data_format
Contains the format of a data sample.
Definition iio.h:1557
iio_device
Represents a device in the IIO context.
iio_event
Represents a IIO event.
Definition iio.h:1474