blob: cad43eb96b46eb80e01dc1fa8fa1e0ef96f4e106 [file] [log] [blame]
Paul Cercueilbb4401d2014-02-28 16:10:49 +01001/*
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
Paul Cercueil306cb1c2014-04-11 14:46:45 +020019/** @file iio.h
20 * @brief Public interface */
21
Paul Cercueil0b2ce712014-02-17 15:04:18 +010022#ifndef __IIO_H__
23#define __IIO_H__
24
Paul Cercueila167e0c2014-04-08 14:50:41 +020025#ifdef __cplusplus
26extern "C" {
27#endif
28
Paul Cercueil35a01312014-02-20 10:56:57 +010029#include <stdbool.h>
Paul Cercueile1311222014-03-12 15:46:16 +010030#include <stdint.h>
Paul Cercueil0b2ce712014-02-17 15:04:18 +010031#include <stdlib.h>
Paul Cercueilecbf4ed2014-03-17 15:02:43 +010032#include <sys/types.h>
Paul Cercueil95347b92014-03-21 09:50:17 +010033#include <stddef.h>
Paul Cercueil0b2ce712014-02-17 15:04:18 +010034
Paul Cercueilb669f692014-04-04 13:42:24 +020035#ifdef _MSC_BUILD
36/* Come on Microsoft, time to get some C99... */
37typedef long ssize_t;
Paul Cercueilb669f692014-04-04 13:42:24 +020038#endif
39
Paul Cercueil59f2aa32014-04-04 16:28:51 +020040#ifdef __GNUC__
41#define __cnst __attribute__((const))
42#define __pure __attribute__((pure))
Paul Cercueil83f21892014-05-19 13:00:39 +020043#define __notused __attribute__((unused))
Paul Cercueil59f2aa32014-04-04 16:28:51 +020044#else
45#define __cnst
46#define __pure
Paul Cercueil83f21892014-05-19 13:00:39 +020047#define __notused
Paul Cercueil59f2aa32014-04-04 16:28:51 +020048#endif
49
50#ifdef _WIN32
51# ifdef LIBIIO_EXPORTS
Paul Cercueil59f2aa32014-04-04 16:28:51 +020052# define __api __declspec(dllexport)
Paul Cercueil7288c332014-04-07 16:25:11 +020053# else
54# define __api __declspec(dllimport)
Paul Cercueil59f2aa32014-04-04 16:28:51 +020055# endif
56#elif __GNUC__ >= 4
57# define __api __attribute__((visibility ("default")))
58#else
59# define __api
60#endif
61
Paul Cercueil0b2ce712014-02-17 15:04:18 +010062struct iio_context;
63struct iio_device;
64struct iio_channel;
Paul Cercueila689cd92014-03-20 16:37:25 +010065struct iio_buffer;
Paul Cercueil0b2ce712014-02-17 15:04:18 +010066
Paul Cercueilb4afdd92014-04-08 12:37:21 +020067
Paul Cercueil306cb1c2014-04-11 14:46:45 +020068/* ---------------------------------------------------------------------------*/
Paul Cercueil53ed9432014-11-20 13:46:04 +010069/* ------------------------- Top-level functions -----------------------------*/
70/** @defgroup TopLevel Top-level functions
71 * @{ */
72
73
74/** @brief Get the version of the libiio library
75 * @param major A pointer to an unsigned integer (NULL accepted)
76 * @param minor A pointer to an unsigned integer (NULL accepted)
77 * @param git_tag A pointer to a 8-characters buffer (NULL accepted) */
78__api void iio_library_get_version(unsigned int *major,
79 unsigned int *minor, char git_tag[8]);
80
81
Paul Cercueil3fa34382015-05-22 10:54:28 +020082/** @brief Get a string description of an error code
83 * @param err The error code
84 * @param dst A pointer to the memory area where the NULL-terminated string
85 * corresponding to the error message will be stored
86 * @param len The available length of the memory area, in bytes */
87__api void iio_strerror(int err, char *dst, size_t len);
88
89
Paul Cercueil53ed9432014-11-20 13:46:04 +010090/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +020091/* ------------------------- Context functions -------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +020092/** @defgroup Context Context
93 * @{
94 * @struct iio_context
95 * @brief Contains the representation of an IIO context */
Paul Cercueilb4afdd92014-04-08 12:37:21 +020096
Paul Cercueil306cb1c2014-04-11 14:46:45 +020097
Paul Cercueil8f56ea72014-10-28 15:18:18 +010098/** @brief Create a context from local or remote IIO devices
99 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100100 * @return On failure, NULL is returned and errno is set appropriately
Paul Cercueil8f56ea72014-10-28 15:18:18 +0100101 *
102 * <b>NOTE:</b> This function will create a network context if the IIOD_REMOTE
103 * environment variable is set to the hostname where the IIOD server runs. If
104 * set to an empty string, the server will be discovered using ZeroConf.
105 * If the environment variable is not set, a local context will be created
106 * instead. */
107__api struct iio_context * iio_create_default_context(void);
108
109
110/** @brief Create a context from local IIO devices (Linux only)
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200111 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100112 * @return On failure, NULL is returned and errno is set appropriately */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200113__api struct iio_context * iio_create_local_context(void);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200114
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200115
116/** @brief Create a context from a XML file
117 * @param xml_file Path to the XML file to open
118 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100119 * @return On failure, NULL is returned and errno is set appropriately
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200120 *
121 * <b>NOTE:</b> The format of the XML must comply to the one returned by
122 * iio_context_get_xml. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200123__api struct iio_context * iio_create_xml_context(const char *xml_file);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200124
125
126/** @brief Create a context from XML data in memory
127 * @param xml Pointer to the XML data in memory
128 * @param len Length of the XML string in memory (excluding the final \0)
129 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100130 * @return On failure, NULL is returned and errno is set appropriately
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200131 *
132 * <b>NOTE:</b> The format of the XML must comply to the one returned by
133 * iio_context_get_xml */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200134__api struct iio_context * iio_create_xml_context_mem(
135 const char *xml, size_t len);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200136
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200137
138/** @brief Create a context from the network
139 * @param host Hostname, IPv4 or IPv6 address where the IIO Daemon is running
140 * @return On success, a pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100141 * @return On failure, NULL is returned and errno is set appropriately */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200142__api struct iio_context * iio_create_network_context(const char *host);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200143
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200144
Paul Cercueile06f4ce2015-04-20 12:59:31 +0200145/** @brief Create a context from USB devices
146 * @param vid Vendor identification number
147 * @param pid Product identification number
148 * @return On success, a pointer to an iio_context structure
149 * @return On failure, NULL is returned and errno is set appropriately */
150__api struct iio_context * iio_create_usb_context(
151 unsigned short vid, unsigned short pid);
152
153
Paul Cercueil63d5e7c2014-10-28 14:33:08 +0100154/** @brief Duplicate a pre-existing IIO context
155 * @param ctx A pointer to an iio_context structure
156 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100157 * @return On failure, NULL is returned and errno is set appropriately */
Paul Cercueil63d5e7c2014-10-28 14:33:08 +0100158__api struct iio_context * iio_context_clone(const struct iio_context *ctx);
159
160
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200161/** @brief Destroy the given context
162 * @param ctx A pointer to an iio_context structure
163 *
164 * <b>NOTE:</b> After that function, the iio_context pointer shall be invalid. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200165__api void iio_context_destroy(struct iio_context *ctx);
Paul Cercueil0b2ce712014-02-17 15:04:18 +0100166
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200167
Paul Cercueile45f8762014-05-02 11:19:26 +0200168/** @brief Get the version of the backend in use
169 * @param ctx A pointer to an iio_context structure
Paul Cercueild15d9952014-05-20 11:40:08 +0200170 * @param major A pointer to an unsigned integer (NULL accepted)
171 * @param minor A pointer to an unsigned integer (NULL accepted)
Paul Cercueil9de9e9d2014-05-20 13:18:19 +0200172 * @param git_tag A pointer to a 8-characters buffer (NULL accepted)
Paul Cercueile45f8762014-05-02 11:19:26 +0200173 * @return On success, 0 is returned
174 * @return On error, a negative errno code is returned */
175__api int iio_context_get_version(const struct iio_context *ctx,
Paul Cercueil9de9e9d2014-05-20 13:18:19 +0200176 unsigned int *major, unsigned int *minor, char git_tag[8]);
Paul Cercueile45f8762014-05-02 11:19:26 +0200177
178
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200179/** @brief Obtain a XML representation of the given context
180 * @param ctx A pointer to an iio_context structure
181 * @return A pointer to a static NULL-terminated string */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200182__api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
183
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200184
185/** @brief Get the name of the given context
186 * @param ctx A pointer to an iio_context structure
187 * @return A pointer to a static NULL-terminated string
188 *
189 * <b>NOTE:</b>The returned string will be <b><i>local</i></b>,
190 * <b><i>xml</i></b> or <b><i>network</i></b> when the context has been
191 * created with the local, xml and network backends respectively.*/
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200192__api __pure const char * iio_context_get_name(const struct iio_context *ctx);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200193
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200194
Paul Cercueil3ac36c12015-01-08 14:44:00 +0100195/** @brief Get a description of the given context
196 * @param ctx A pointer to an iio_context structure
197 * @return A pointer to a static NULL-terminated string
198 *
199 * <b>NOTE:</b>The returned string will contain human-readable information about
200 * the current context. */
201__api __pure const char * iio_context_get_description(
202 const struct iio_context *ctx);
203
204
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200205/** @brief Enumerate the devices found in the given context
206 * @param ctx A pointer to an iio_context structure
207 * @return The number of devices found */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200208__api __pure unsigned int iio_context_get_devices_count(
209 const struct iio_context *ctx);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200210
211
212/** @brief Get the device present at the given index
213 * @param ctx A pointer to an iio_context structure
214 * @param index The index corresponding to the device
215 * @return On success, a pointer to an iio_device structure
216 * @return If the index is invalid, NULL is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200217__api __pure struct iio_device * iio_context_get_device(
218 const struct iio_context *ctx, unsigned int index);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200219
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200220
221/** @brief Try to find a device structure by its name of ID
222 * @param ctx A pointer to an iio_context structure
223 * @param name A NULL-terminated string corresponding to the name or the ID of
224 * the device to search for
225 * @return On success, a pointer to an iio_device structure
226 * @return If the name or ID does not correspond to any known device, NULL is
227 * returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200228__api __pure struct iio_device * iio_context_find_device(
229 const struct iio_context *ctx, const char *name);
Paul Cercueil0b2ce712014-02-17 15:04:18 +0100230
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200231
Paul Cercueil4ca73542014-06-10 16:23:29 +0200232/** @brief Set a timeout for I/O operations
233 * @param ctx A pointer to an iio_context structure
234 * @param timeout_ms A positive integer representing the time in milliseconds
235 * after which a timeout occurs
236 * @return On success, 0 is returned
237 * @return On error, a negative errno code is returned */
238__api int iio_context_set_timeout(
239 struct iio_context *ctx, unsigned int timeout_ms);
240
241
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200242/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200243/* ------------------------- Device functions --------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200244/** @defgroup Device Device
245 * @{
246 * @struct iio_device
247 * @brief Represents a device in the IIO context */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200248
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200249
Paul Cercueil03b6c812015-04-14 16:49:06 +0200250/** @brief Retrieve a pointer to the iio_context structure
251 * @param dev A pointer to an iio_device structure
252 * @return A pointer to an iio_context structure */
253__api __pure const struct iio_context * iio_device_get_context(
254 const struct iio_device *dev);
255
256
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200257/** @brief Retrieve the device ID (e.g. <b><i>iio:device0</i></b>)
258 * @param dev A pointer to an iio_device structure
259 * @return A pointer to a static NULL-terminated string */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200260__api __pure const char * iio_device_get_id(const struct iio_device *dev);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200261
262
263/** @brief Retrieve the device name (e.g. <b><i>xadc</i></b>)
264 * @param dev A pointer to an iio_device structure
265 * @return A pointer to a static NULL-terminated string
266 *
267 * <b>NOTE:</b> if the device has no name, NULL is returned. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200268__api __pure const char * iio_device_get_name(const struct iio_device *dev);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200269
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200270
271/** @brief Enumerate the channels of the given device
272 * @param dev A pointer to an iio_device structure
273 * @return The number of channels found */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200274__api __pure unsigned int iio_device_get_channels_count(
275 const struct iio_device *dev);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200276
277
278/** @brief Enumerate the device-specific attributes of the given device
279 * @param dev A pointer to an iio_device structure
280 * @return The number of device-specific attributes found */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200281__api __pure unsigned int iio_device_get_attrs_count(
282 const struct iio_device *dev);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200283
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200284
285/** @brief Get the channel present at the given index
286 * @param dev A pointer to an iio_device structure
287 * @param index The index corresponding to the channel
288 * @return On success, a pointer to an iio_channel structure
289 * @return If the index is invalid, NULL is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200290__api __pure struct iio_channel * iio_device_get_channel(
291 const struct iio_device *dev, unsigned int index);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200292
293
294/** @brief Get the device-specific attribute present at the given index
295 * @param dev A pointer to an iio_device structure
296 * @param index The index corresponding to the attribute
297 * @return On success, a pointer to a static NULL-terminated string
298 * @return If the index is invalid, NULL is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200299__api __pure const char * iio_device_get_attr(
300 const struct iio_device *dev, unsigned int index);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200301
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200302
303/** @brief Try to find a channel structure by its name of ID
304 * @param dev A pointer to an iio_device structure
305 * @param name A NULL-terminated string corresponding to the name or the ID of
306 * the channel to search for
307 * @param output True if the searched channel is output, False otherwise
308 * @return On success, a pointer to an iio_channel structure
309 * @return If the name or ID does not correspond to any known channel of the
310 * given device, NULL is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200311__api __pure struct iio_channel * iio_device_find_channel(
312 const struct iio_device *dev, const char *name, bool output);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200313
314
315/** @brief Try to find a device-specific attribute by its name
316 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200317 * @param name A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200318 * attribute
319 * @return On success, a pointer to a static NULL-terminated string
320 * @return If the name does not correspond to any known attribute of the given
321 * device, NULL is returned
322 *
323 * <b>NOTE:</b> This function is useful to detect the presence of an attribute.
324 * It can also be used to retrieve the name of an attribute as a pointer to a
325 * static string from a dynamically allocated string. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200326__api __pure const char * iio_device_find_attr(
327 const struct iio_device *dev, const char *name);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200328
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200329
330/** @brief Read the content of the given device-specific attribute
331 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200332 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200333 * attribute
334 * @param dst A pointer to the memory area where the NULL-terminated string
335 * corresponding to the value read will be stored
336 * @param len The available length of the memory area, in bytes
337 * @return On success, the number of bytes written to the buffer
Paul Cercueil4ca6ddc2014-05-21 14:51:50 +0200338 * @return On error, a negative errno code is returned
339 *
340 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_device_attr_read,
341 * it is now possible to read all of the attributes of a device.
342 *
343 * The buffer is filled with one block of data per attribute of the device,
344 * by the order they appear in the iio_device structure.
345 *
346 * The first four bytes of one block correspond to a 32-bit signed value in
347 * network order. If negative, it corresponds to the errno code that were
348 * returned when reading the attribute; if positive, it corresponds to the
349 * length of the data read. In that case, the rest of the block contains
350 * the data. */
351 __api ssize_t iio_device_attr_read(const struct iio_device *dev,
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200352 const char *attr, char *dst, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200353
354
Paul Cercueil1b36a012014-06-05 14:39:31 +0200355/** @brief Read the content of all device-specific attributes
356 * @param dev A pointer to an iio_device structure
357 * @param cb A pointer to a callback function
358 * @param data A pointer that will be passed to the callback function
359 * @return On success, 0 is returned
360 * @return On error, a negative errno code is returned
361 *
362 * <b>NOTE:</b> This function is especially useful when used with the network
363 * backend, as all the device-specific attributes are read in one single
364 * command. */
365__api int iio_device_attr_read_all(struct iio_device *dev,
366 int (*cb)(struct iio_device *dev, const char *attr,
367 const char *value, size_t len, void *d),
368 void *data);
369
370
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200371/** @brief Read the content of the given device-specific attribute
372 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200373 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200374 * attribute
375 * @param val A pointer to a bool variable where the value should be stored
376 * @return On success, 0 is returned
377 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200378__api int iio_device_attr_read_bool(const struct iio_device *dev,
379 const char *attr, bool *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200380
381
382/** @brief Read the content of the given device-specific attribute
383 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200384 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200385 * attribute
386 * @param val A pointer to a long long variable where the value should be stored
387 * @return On success, 0 is returned
388 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200389__api int iio_device_attr_read_longlong(const struct iio_device *dev,
390 const char *attr, long long *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200391
392
393/** @brief Read the content of the given device-specific attribute
394 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200395 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200396 * attribute
397 * @param val A pointer to a double variable where the value should be stored
398 * @return On success, 0 is returned
399 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200400__api int iio_device_attr_read_double(const struct iio_device *dev,
401 const char *attr, double *val);
402
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200403
404/** @brief Set the value of the given device-specific attribute
405 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200406 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200407 * attribute
408 * @param src A NULL-terminated string to set the attribute to
409 * @return On success, the number of bytes written
Paul Cercueil1da28122014-05-22 10:59:49 +0200410 * @return On error, a negative errno code is returned
411 *
412 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_device_attr_write,
413 * it is now possible to write all of the attributes of a device.
414 *
415 * The buffer must contain one block of data per attribute of the device,
416 * by the order they appear in the iio_device structure.
417 *
418 * The first four bytes of one block correspond to a 32-bit signed value in
419 * network order. If negative, the attribute is not written; if positive,
420 * it corresponds to the length of the data to write. In that case, the rest
421 * of the block must contain the data. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200422__api ssize_t iio_device_attr_write(const struct iio_device *dev,
423 const char *attr, const char *src);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200424
425
426/** @brief Set the value of the given device-specific attribute
427 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200428 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200429 * attribute
Paul Cercueilcecda352014-05-06 18:14:29 +0200430 * @param src A pointer to the data to be written
431 * @param len The number of bytes that should be written
432 * @return On success, the number of bytes written
433 * @return On error, a negative errno code is returned */
434__api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
435 const char *attr, const void *src, size_t len);
436
437
Paul Cercueil1b36a012014-06-05 14:39:31 +0200438/** @brief Set the values of all device-specific attributes
439 * @param dev A pointer to an iio_device structure
440 * @param cb A pointer to a callback function
441 * @param data A pointer that will be passed to the callback function
442 * @return On success, 0 is returned
443 * @return On error, a negative errno code is returned
444 *
445 * <b>NOTE:</b> This function is especially useful when used with the network
446 * backend, as all the device-specific attributes are written in one single
447 * command. */
448__api int iio_device_attr_write_all(struct iio_device *dev,
449 ssize_t (*cb)(struct iio_device *dev,
450 const char *attr, void *buf, size_t len, void *d),
451 void *data);
452
453
Paul Cercueilcecda352014-05-06 18:14:29 +0200454/** @brief Set the value of the given device-specific attribute
455 * @param dev A pointer to an iio_device structure
456 * @param attr A NULL-terminated string corresponding to the name of the
457 * attribute
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200458 * @param val A bool value to set the attribute to
459 * @return On success, 0 is returned
460 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200461__api int iio_device_attr_write_bool(const struct iio_device *dev,
462 const char *attr, bool val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200463
464
465/** @brief Set the value of the given device-specific attribute
466 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200467 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200468 * attribute
469 * @param val A long long value to set the attribute to
470 * @return On success, 0 is returned
471 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200472__api int iio_device_attr_write_longlong(const struct iio_device *dev,
473 const char *attr, long long val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200474
475
476/** @brief Set the value of the given device-specific attribute
477 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200478 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200479 * attribute
480 * @param val A double value to set the attribute to
481 * @return On success, 0 is returned
482 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200483__api int iio_device_attr_write_double(const struct iio_device *dev,
484 const char *attr, double val);
485
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200486
487/** @brief Associate a pointer to an iio_device structure
488 * @param dev A pointer to an iio_device structure
489 * @param data The pointer to be associated */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200490__api void iio_device_set_data(struct iio_device *dev, void *data);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200491
492
493/** @brief Retrieve a previously associated pointer of an iio_device structure
494 * @param dev A pointer to an iio_device structure
495 * @return The pointer previously associated if present, or NULL */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200496__api void * iio_device_get_data(const struct iio_device *dev);
497
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200498
499/** @brief Retrieve the trigger of a given device
500 * @param dev A pointer to an iio_device structure
501 * @param trigger a pointer to a pointer of an iio_device structure. The pointed
502 * pointer will be set to the address of the iio_device structure corresponding
503 * to the associated trigger device.
504 * @return On success, 0 is returned
505 * @return On error, a negative errno code is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200506__api int iio_device_get_trigger(const struct iio_device *dev,
Paul Cercueil24ffa532014-03-10 12:39:58 +0100507 const struct iio_device **trigger);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200508
509
510/** @brief Associate a trigger to a given device
511 * @param dev A pointer to an iio_device structure
512 * @param trigger a pointer to the iio_device structure corresponding to the
513 * trigger that should be associated.
514 * @return On success, 0 is returned
515 * @return On error, a negative errno code is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200516__api int iio_device_set_trigger(const struct iio_device *dev,
Paul Cercueil24ffa532014-03-10 12:39:58 +0100517 const struct iio_device *trigger);
Paul Cercueil0b2ce712014-02-17 15:04:18 +0100518
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200519
520/** @brief Return True if the given device is a trigger
521 * @param dev A pointer to an iio_device structure
522 * @return True if the device is a trigger, False otherwise */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200523__api __pure bool iio_device_is_trigger(const struct iio_device *dev);
524
Romain Roffé6c385d92015-06-30 13:36:05 +0200525/**
526 * @brief Configure the number of kernel buffers for a device
527 *
528 * This function allows to change the number of buffers on kernel side.
529 * @param dev A pointer to an iio_device structure
530 * @param nb_buffers The number of buffers
531 * @return On success, 0 is returned
532 * @return On error, a negative errno code is returned */
533__api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
534 unsigned int nb_buffers);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200535
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200536/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200537/* ------------------------- Channel functions -------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200538/** @defgroup Channel Channel
539 * @{
540 * @struct iio_channel
541 * @brief Represents an input or output channel of a device */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200542
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200543
Paul Cercueil03b6c812015-04-14 16:49:06 +0200544/** @brief Retrieve a pointer to the iio_device structure
545 * @param chn A pointer to an iio_channel structure
546 * @return A pointer to an iio_device structure */
547__api __pure const struct iio_device * iio_channel_get_device(
548 const struct iio_channel *chn);
549
550
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200551/** @brief Retrieve the channel ID (e.g. <b><i>voltage0</i></b>)
552 * @param chn A pointer to an iio_channel structure
553 * @return A pointer to a static NULL-terminated string */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200554__api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200555
556
557/** @brief Retrieve the channel name (e.g. <b><i>vccint</i></b>)
558 * @param chn A pointer to an iio_channel structure
559 * @return A pointer to a static NULL-terminated string
560 *
561 * <b>NOTE:</b> if the channel has no name, NULL is returned. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200562__api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
563
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200564
565/** @brief Return True if the given channel is an output channel
566 * @param chn A pointer to an iio_channel structure
567 * @return True if the channel is an output channel, False otherwise */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200568__api __pure bool iio_channel_is_output(const struct iio_channel *chn);
569
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200570
Paul Cercueil85aaf482014-04-24 16:39:09 +0200571/** @brief Return True if the given channel is a scan element
572 * @param chn A pointer to an iio_channel structure
573 * @return True if the channel is a scan element, False otherwise
574 *
575 * <b>NOTE:</b> a channel that is a scan element is a channel that can
576 * generate samples (for an input channel) or receive samples (for an output
577 * channel) after being enabled. */
578__api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
579
580
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200581/** @brief Enumerate the channel-specific attributes of the given channel
582 * @param chn A pointer to an iio_channel structure
583 * @return The number of channel-specific attributes found */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200584__api __pure unsigned int iio_channel_get_attrs_count(
585 const struct iio_channel *chn);
586
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200587
588/** @brief Get the channel-specific attribute present at the given index
589 * @param chn A pointer to an iio_channel structure
590 * @param index The index corresponding to the attribute
591 * @return On success, a pointer to a static NULL-terminated string
592 * @return If the index is invalid, NULL is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200593__api __pure const char * iio_channel_get_attr(
594 const struct iio_channel *chn, unsigned int index);
595
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200596
597/** @brief Try to find a channel-specific attribute by its name
598 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200599 * @param name A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200600 * attribute
601 * @return On success, a pointer to a static NULL-terminated string
602 * @return If the name does not correspond to any known attribute of the given
603 * channel, NULL is returned
604 *
605 * <b>NOTE:</b> This function is useful to detect the presence of an attribute.
606 * It can also be used to retrieve the name of an attribute as a pointer to a
607 * static string from a dynamically allocated string. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200608__api __pure const char * iio_channel_find_attr(
609 const struct iio_channel *chn, const char *name);
610
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200611
Paul Cercueil6f8dbd42014-05-05 17:05:59 +0200612/** @brief Retrieve the filename of an attribute
613 * @param chn A pointer to an iio_channel structure
614 * @param attr a NULL-terminated string corresponding to the name of the
615 * attribute
616 * @return On success, a pointer to a static NULL-terminated string
617 * @return If the attribute name is unknown, NULL is returned */
618__api __pure const char * iio_channel_attr_get_filename(
619 const struct iio_channel *chn, const char *attr);
620
621
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200622/** @brief Read the content of the given channel-specific attribute
623 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200624 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200625 * attribute
626 * @param dst A pointer to the memory area where the NULL-terminated string
627 * corresponding to the value read will be stored
628 * @param len The available length of the memory area, in bytes
629 * @return On success, the number of bytes written to the buffer
Paul Cercueil4ca6ddc2014-05-21 14:51:50 +0200630 * @return On error, a negative errno code is returned
631 *
632 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_channel_attr_read,
633 * it is now possible to read all of the attributes of a channel.
634 *
635 * The buffer is filled with one block of data per attribute of the channel,
636 * by the order they appear in the iio_channel structure.
637 *
638 * The first four bytes of one block correspond to a 32-bit signed value in
639 * network order. If negative, it corresponds to the errno code that were
640 * returned when reading the attribute; if positive, it corresponds to the
641 * length of the data read. In that case, the rest of the block contains
642 * the data. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200643__api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
644 const char *attr, char *dst, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200645
646
Paul Cercueil47d23d02014-06-05 14:46:20 +0200647/** @brief Read the content of all channel-specific attributes
648 * @param chn A pointer to an iio_channel structure
649 * @param cb A pointer to a callback function
650 * @param data A pointer that will be passed to the callback function
651 * @return On success, 0 is returned
652 * @return On error, a negative errno code is returned
653 *
654 * <b>NOTE:</b> This function is especially useful when used with the network
655 * backend, as all the channel-specific attributes are read in one single
656 * command. */
657__api int iio_channel_attr_read_all(struct iio_channel *chn,
658 int (*cb)(struct iio_channel *chn,
659 const char *attr, const char *val, size_t len, void *d),
660 void *data);
661
662
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200663/** @brief Read the content of the given channel-specific attribute
664 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200665 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200666 * attribute
667 * @param val A pointer to a bool variable where the value should be stored
668 * @return On success, 0 is returned
669 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200670__api int iio_channel_attr_read_bool(const struct iio_channel *chn,
671 const char *attr, bool *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200672
673
674/** @brief Read the content of the given channel-specific attribute
675 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200676 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200677 * attribute
678 * @param val A pointer to a long long variable where the value should be stored
679 * @return On success, 0 is returned
680 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200681__api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
682 const char *attr, long long *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200683
684
685/** @brief Read the content of the given channel-specific attribute
686 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200687 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200688 * attribute
689 * @param val A pointer to a double variable where the value should be stored
690 * @return On success, 0 is returned
691 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200692__api int iio_channel_attr_read_double(const struct iio_channel *chn,
693 const char *attr, double *val);
694
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200695
696/** @brief Set the value of the given channel-specific attribute
697 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200698 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200699 * attribute
700 * @param src A NULL-terminated string to set the attribute to
701 * @return On success, the number of bytes written
Paul Cercueil1da28122014-05-22 10:59:49 +0200702 * @return On error, a negative errno code is returned
703 *
704 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_channel_attr_write,
705 * it is now possible to write all of the attributes of a channel.
706 *
707 * The buffer must contain one block of data per attribute of the channel,
708 * by the order they appear in the iio_channel structure.
709 *
710 * The first four bytes of one block correspond to a 32-bit signed value in
711 * network order. If negative, the attribute is not written; if positive,
712 * it corresponds to the length of the data to write. In that case, the rest
713 * of the block must contain the data. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200714__api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
715 const char *attr, const char *src);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200716
717
718/** @brief Set the value of the given channel-specific attribute
719 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200720 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200721 * attribute
Paul Cercueilcecda352014-05-06 18:14:29 +0200722 * @param src A pointer to the data to be written
723 * @param len The number of bytes that should be written
724 * @return On success, the number of bytes written
725 * @return On error, a negative errno code is returned */
726__api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
727 const char *attr, const void *src, size_t len);
728
729
Paul Cercueil47d23d02014-06-05 14:46:20 +0200730/** @brief Set the values of all channel-specific attributes
731 * @param chn A pointer to an iio_channel structure
732 * @param cb A pointer to a callback function
733 * @param data A pointer that will be passed to the callback function
734 * @return On success, 0 is returned
735 * @return On error, a negative errno code is returned
736 *
737 * <b>NOTE:</b> This function is especially useful when used with the network
738 * backend, as all the channel-specific attributes are written in one single
739 * command. */
740__api int iio_channel_attr_write_all(struct iio_channel *chn,
741 ssize_t (*cb)(struct iio_channel *chn,
742 const char *attr, void *buf, size_t len, void *d),
743 void *data);
744
745
Paul Cercueilcecda352014-05-06 18:14:29 +0200746/** @brief Set the value of the given channel-specific attribute
747 * @param chn A pointer to an iio_channel structure
748 * @param attr A NULL-terminated string corresponding to the name of the
749 * attribute
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200750 * @param val A bool value to set the attribute to
751 * @return On success, 0 is returned
752 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200753__api int iio_channel_attr_write_bool(const struct iio_channel *chn,
754 const char *attr, bool val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200755
756
757/** @brief Set the value of the given channel-specific attribute
758 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200759 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200760 * attribute
761 * @param val A long long value to set the attribute to
762 * @return On success, 0 is returned
763 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200764__api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
765 const char *attr, long long val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200766
767
768/** @brief Set the value of the given channel-specific attribute
769 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200770 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200771 * attribute
772 * @param val A double value to set the attribute to
773 * @return On success, 0 is returned
774 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200775__api int iio_channel_attr_write_double(const struct iio_channel *chn,
776 const char *attr, double val);
777
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200778
779/** @brief Enable the given channel
780 * @param chn A pointer to an iio_channel structure
781 *
782 * <b>NOTE:</b>Before creating an iio_buffer structure with
783 * iio_device_create_buffer, it is required to enable at least one channel of
784 * the device to read from. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200785__api void iio_channel_enable(struct iio_channel *chn);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200786
787
788/** @brief Disable the given channel
789 * @param chn A pointer to an iio_channel structure */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200790__api void iio_channel_disable(struct iio_channel *chn);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200791
792
793/** @brief Returns True if the channel is enabled
794 * @param chn A pointer to an iio_channel structure
795 * @return True if the channel is enabled, False otherwise */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200796__api bool iio_channel_is_enabled(const struct iio_channel *chn);
797
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200798
799/** Demultiplex the samples of a given channel
800 * @param chn A pointer to an iio_channel structure
801 * @param buffer A pointer to an iio_buffer structure
802 * @param dst A pointer to the memory area where the demultiplexed data will be
803 * stored
804 * @param len The available length of the memory area, in bytes
805 * @return The size of the demultiplexed data, in bytes */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200806__api size_t iio_channel_read_raw(const struct iio_channel *chn,
807 struct iio_buffer *buffer, void *dst, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200808
809
810/** Demultiplex and convert the samples of a given channel
811 * @param chn A pointer to an iio_channel structure
812 * @param buffer A pointer to an iio_buffer structure
813 * @param dst A pointer to the memory area where the converted data will be
814 * stored
815 * @param len The available length of the memory area, in bytes
816 * @return The size of the converted data, in bytes */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200817__api size_t iio_channel_read(const struct iio_channel *chn,
818 struct iio_buffer *buffer, void *dst, size_t len);
819
820
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200821/** Multiplex the samples of a given channel
822 * @param chn A pointer to an iio_channel structure
823 * @param buffer A pointer to an iio_buffer structure
824 * @param src A pointer to the memory area where the sequential data will
825 * be read from
826 * @param len The length of the memory area, in bytes
827 * @return The number of bytes actually multiplexed */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200828__api size_t iio_channel_write_raw(const struct iio_channel *chn,
829 struct iio_buffer *buffer, const void *src, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200830
831
832/** Convert and multiplex the samples of a given channel
833 * @param chn A pointer to an iio_channel structure
834 * @param buffer A pointer to an iio_buffer structure
835 * @param src A pointer to the memory area where the sequential data will
836 * be read from
837 * @param len The length of the memory area, in bytes
838 * @return The number of bytes actually converted and multiplexed */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200839__api size_t iio_channel_write(const struct iio_channel *chn,
840 struct iio_buffer *buffer, const void *src, size_t len);
841
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200842
843/** @brief Associate a pointer to an iio_channel structure
844 * @param chn A pointer to an iio_channel structure
845 * @param data The pointer to be associated */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200846__api void iio_channel_set_data(struct iio_channel *chn, void *data);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200847
848
849/** @brief Retrieve a previously associated pointer of an iio_channel structure
850 * @param chn A pointer to an iio_channel structure
851 * @return The pointer previously associated if present, or NULL */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200852__api void * iio_channel_get_data(const struct iio_channel *chn);
853
854
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200855/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200856/* ------------------------- Buffer functions --------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200857/** @defgroup Buffer Buffer
858 * @{
859 * @struct iio_buffer
860 * @brief An input or output buffer, used to read or write samples */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200861
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200862
Paul Cercueil03b6c812015-04-14 16:49:06 +0200863/** @brief Retrieve a pointer to the iio_device structure
864 * @param buf A pointer to an iio_buffer structure
865 * @return A pointer to an iio_device structure */
866__api __pure const struct iio_device * iio_buffer_get_device(
867 const struct iio_buffer *buf);
868
869
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200870/** @brief Create an input or output buffer associated to the given device
871 * @param dev A pointer to an iio_device structure
872 * @param samples_count The number of samples that the buffer should contain
Paul Cercueil2004eaa2014-05-22 14:04:39 +0200873 * @param cyclic If True, enable cyclic mode
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200874 * @return On success, a pointer to an iio_buffer structure
Paul Cercueil3106e892014-04-30 11:29:51 +0200875 * @return On error, NULL is returned, and errno is set to the error code
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200876 *
877 * <b>NOTE:</b> Channels that have to be written to / read from must be enabled
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200878 * before creating the buffer. */
879__api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
Paul Cercueil2004eaa2014-05-22 14:04:39 +0200880 size_t samples_count, bool cyclic);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200881
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200882
883/** @brief Destroy the given buffer
884 * @param buf A pointer to an iio_buffer structure
885 *
886 * <b>NOTE:</b> After that function, the iio_buffer pointer shall be invalid. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200887__api void iio_buffer_destroy(struct iio_buffer *buf);
888
Romain Roffé6a881702015-06-30 16:25:43 +0200889/** @brief Get a pollable file descriptor
890 *
891 * Can be used to know when iio_buffer_refill() or iio_buffer_push() can be
892 * called
893 * @param buf A pointer to an iio_buffer structure
894 * @return On success, valid file descriptor
895 * @return On error, a negative errno code is returned
896 */
897__api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200898
Romain Roffé0ea038d2015-06-30 13:35:38 +0200899/** @brief Make iio_buffer_refill() and iio_buffer_push() blocking or not
900 *
Paul Cercueil10ff7572015-11-19 17:12:34 +0100901 * After this function has been called with blocking == true,
Romain Roffé0ea038d2015-06-30 13:35:38 +0200902 * iio_buffer_refill() and iio_buffer_push() will return -EAGAIN if no data is
903 * ready.
904 * A device is blocking by default.
905 * @param buf A pointer to an iio_buffer structure
906 * @param blocking true if the buffer API should be blocking, else false
907 * @return On success, 0
908 * @return On error, a negative errno code is returned
909 */
910__api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
911
912
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200913/** @brief Fetch more samples from the hardware
914 * @param buf A pointer to an iio_buffer structure
915 * @return On success, the number of bytes read is returned
916 * @return On error, a negative errno code is returned
917 *
918 * <b>NOTE:</b> Only valid for input buffers */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200919__api ssize_t iio_buffer_refill(struct iio_buffer *buf);
920
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200921
922/** @brief Send the samples to the hardware
923 * @param buf A pointer to an iio_buffer structure
924 * @return On success, the number of bytes written is returned
925 * @return On error, a negative errno code is returned
926 *
927 * <b>NOTE:</b> Only valid for output buffers */
Paul Cercueil0183b6e2014-05-20 13:21:46 +0200928__api ssize_t iio_buffer_push(struct iio_buffer *buf);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200929
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200930
Paul Cercueil8e7b4192015-08-05 13:03:35 +0200931/** @brief Send a given number of samples to the hardware
932 * @param buf A pointer to an iio_buffer structure
933 * @param samples_count The number of samples to submit
934 * @return On success, the number of bytes written is returned
935 * @return On error, a negative errno code is returned
936 *
937 * <b>NOTE:</b> Only valid for output buffers */
938__api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
939 size_t samples_count);
940
941
Paul Cercueil6d927162014-04-16 15:53:22 +0200942/** @brief Get the start address of the buffer
943 * @param buf A pointer to an iio_buffer structure
944 * @return A pointer corresponding to the start address of the buffer */
Paul Cercueil49106002015-03-04 13:19:20 +0100945__api void * iio_buffer_start(const struct iio_buffer *buf);
Paul Cercueil6d927162014-04-16 15:53:22 +0200946
947
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200948/** @brief Find the first sample of a channel in a buffer
949 * @param buf A pointer to an iio_buffer structure
950 * @param chn A pointer to an iio_channel structure
951 * @return A pointer to the first sample found, or to the end of the buffer if
952 * no sample for the given channel is present in the buffer
953 *
954 * <b>NOTE:</b> This fonction, coupled with iio_buffer_step and iio_buffer_end,
955 * can be used to iterate on all the samples of a given channel present in the
956 * buffer, doing the following:
957 *
958 * @verbatim
959 for (void *ptr = iio_buffer_first(buffer, chn); ptr < iio_buffer_end(buffer); ptr += iio_buffer_step(buffer)) {
960 ....
961 }
962 @endverbatim */
963__api void * iio_buffer_first(const struct iio_buffer *buf,
964 const struct iio_channel *chn);
965
966
967/** @brief Get the step size between two samples of one channel
968 * @param buf A pointer to an iio_buffer structure
969 * @return the difference between the addresses of two consecutive samples of
970 * one same channel */
971__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
972
973
974/** @brief Get the address that follows the last sample in a buffer
975 * @param buf A pointer to an iio_buffer structure
976 * @return A pointer corresponding to the address that follows the last sample
977 * present in the buffer */
978__api void * iio_buffer_end(const struct iio_buffer *buf);
979
980
981/** @brief Call the supplied callback for each sample found in a buffer
982 * @param buf A pointer to an iio_buffer structure
983 * @param callback A pointer to a function to call for each sample found
984 * @param data A user-specified pointer that will be passed to the callback
985 *
986 * <b>NOTE:</b> The callback receives four arguments:
987 * * A pointer to the iio_channel structure corresponding to the sample,
988 * * A pointer to the sample itself,
989 * * The length of the sample in bytes,
990 * * The user-specified pointer passed to iio_buffer_foreach_sample. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200991__api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
992 ssize_t (*callback)(const struct iio_channel *chn,
993 void *src, size_t bytes, void *d), void *data);
994
995
Paul Cercueila2d4bad2014-05-27 10:15:29 +0200996/** @brief Associate a pointer to an iio_buffer structure
997 * @param buf A pointer to an iio_buffer structure
998 * @param data The pointer to be associated */
999__api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1000
1001
1002/** @brief Retrieve a previously associated pointer of an iio_buffer structure
1003 * @param buf A pointer to an iio_buffer structure
1004 * @return The pointer previously associated if present, or NULL */
1005__api void * iio_buffer_get_data(const struct iio_buffer *buf);
1006
1007
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001008/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +02001009/* ------------------------- Low-level functions -----------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001010/** @defgroup Debug Debug and low-level functions
1011 * @{
1012 * @struct iio_data_format
1013 * @brief Contains the format of a data sample.
1014 *
1015 * The different fields inform about the correct way to convert one sample from
1016 * its raw format (as read from / generated by the hardware) to its real-world
1017 * value.
1018 */
1019struct iio_data_format {
1020 /** @brief Total length of the sample, in bits */
1021 unsigned int length;
Paul Cercueilb4afdd92014-04-08 12:37:21 +02001022
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001023 /** @brief Length of valuable data in the sample, in bits */
1024 unsigned int bits;
1025
1026 /** @brief Right-shift to apply when converting sample */
1027 unsigned int shift;
1028
1029 /** @brief Contains True if the sample is signed */
1030 bool is_signed;
1031
Michael Hennerichfa3c6f62014-08-13 11:21:23 +02001032 /** @brief Contains True if the sample is fully defined, sign extended, etc. */
1033 bool is_fully_defined;
1034
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001035 /** @brief Contains True if the sample is in big-endian format */
1036 bool is_be;
1037
1038 /** @brief Contains True if the sample should be scaled when converted */
1039 bool with_scale;
1040
1041 /** @brief Contains the scale to apply if with_scale is set */
1042 double scale;
1043};
1044
1045
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001046/** @brief Get the current sample size
1047 * @param dev A pointer to an iio_device structure
1048 * @return On success, the sample size in bytes
1049 * @return On error, a negative errno code is returned
1050 *
1051 * <b>NOTE:</b> The sample size is not constant and will change when channels
1052 * get enabled or disabled. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001053__api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
Paul Cercueil1a474732014-03-17 11:38:34 +01001054
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001055
1056/** @brief Get the index of the given channel
1057 * @param chn A pointer to an iio_channel structure
1058 * @return On success, the index of the specified channel
1059 * @return On error, a negative errno code is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001060__api __pure long iio_channel_get_index(const struct iio_channel *chn);
Paul Cercueilb4afdd92014-04-08 12:37:21 +02001061
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001062
1063/** @brief Get a pointer to a channel's data format structure
1064 * @param chn A pointer to an iio_channel structure
1065 * @return A pointer to the channel's iio_data_format structure */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001066__api __cnst const struct iio_data_format * iio_channel_get_data_format(
1067 const struct iio_channel *chn);
Paul Cercueil0b2ce712014-02-17 15:04:18 +01001068
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001069
1070/** @brief Convert the sample from hardware format to host format
1071 * @param chn A pointer to an iio_channel structure
1072 * @param dst A pointer to the destination buffer where the converted sample
1073 * should be written
1074 * @param src A pointer to the source buffer containing the sample */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001075__api void iio_channel_convert(const struct iio_channel *chn,
Paul Cercueil2917ffb2014-03-21 15:47:12 +01001076 void *dst, const void *src);
1077
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001078
1079/** @brief Convert the sample from host format to hardware format
1080 * @param chn A pointer to an iio_channel structure
1081 * @param dst A pointer to the destination buffer where the converted sample
1082 * should be written
1083 * @param src A pointer to the source buffer containing the sample */
Paul Cercueild840d4c2014-04-07 19:38:58 +02001084__api void iio_channel_convert_inverse(const struct iio_channel *chn,
1085 void *dst, const void *src);
1086
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001087
Paul Cercueil1ce35ef2014-04-15 12:28:40 +02001088/** @brief Enumerate the debug attributes of the given device
1089 * @param dev A pointer to an iio_device structure
1090 * @return The number of debug attributes found */
1091__api __pure unsigned int iio_device_get_debug_attrs_count(
1092 const struct iio_device *dev);
1093
1094
1095/** @brief Get the debug attribute present at the given index
1096 * @param dev A pointer to an iio_device structure
1097 * @param index The index corresponding to the debug attribute
1098 * @return On success, a pointer to a static NULL-terminated string
1099 * @return If the index is invalid, NULL is returned */
1100__api __pure const char * iio_device_get_debug_attr(
1101 const struct iio_device *dev, unsigned int index);
1102
1103
Paul Cercueil001d2152014-06-03 15:24:44 +02001104/** @brief Try to find a debug attribute by its name
1105 * @param dev A pointer to an iio_device structure
1106 * @param name A NULL-terminated string corresponding to the name of the
1107 * debug attribute
1108 * @return On success, a pointer to a static NULL-terminated string
1109 * @return If the name does not correspond to any known debug attribute of the
1110 * given device, NULL is returned
1111 *
1112 * <b>NOTE:</b> This function is useful to detect the presence of a debug
1113 * attribute.
1114 * It can also be used to retrieve the name of a debug attribute as a pointer
1115 * to a static string from a dynamically allocated string. */
1116__api __pure const char * iio_device_find_debug_attr(
1117 const struct iio_device *dev, const char *name);
1118
1119
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001120/** @brief Read the content of the given debug attribute
1121 * @param dev A pointer to an iio_device structure
1122 * @param attr A NULL-terminated string corresponding to the name of the
1123 * debug attribute
1124 * @param dst A pointer to the memory area where the NULL-terminated string
1125 * corresponding to the value read will be stored
1126 * @param len The available length of the memory area, in bytes
1127 * @return On success, the number of bytes written to the buffer
Paul Cercueil4ca6ddc2014-05-21 14:51:50 +02001128 * @return On error, a negative errno code is returned
1129 *
1130 * <b>NOTE:</b>By passing NULL as the "attr" argument to
1131 * iio_device_debug_attr_read, it is now possible to read all of the debug
1132 * attributes of a device.
1133 *
1134 * The buffer is filled with one block of data per debug attribute of the
1135 * device, by the order they appear in the iio_device structure.
1136 *
1137 * The first four bytes of one block correspond to a 32-bit signed value in
1138 * network order. If negative, it corresponds to the errno code that were
1139 * returned when reading the debug attribute; if positive, it corresponds
1140 * to the length of the data read. In that case, the rest of the block contains
1141 * the data. */
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001142__api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1143 const char *attr, char *dst, size_t len);
1144
1145
Paul Cercueil1b36a012014-06-05 14:39:31 +02001146/** @brief Read the content of all debug attributes
1147 * @param dev A pointer to an iio_device structure
1148 * @param cb A pointer to a callback function
1149 * @param data A pointer that will be passed to the callback function
1150 * @return On success, 0 is returned
1151 * @return On error, a negative errno code is returned
1152 *
1153 * <b>NOTE:</b> This function is especially useful when used with the network
1154 * backend, as all the debug attributes are read in one single command. */
1155__api int iio_device_debug_attr_read_all(struct iio_device *dev,
1156 int (*cb)(struct iio_device *dev, const char *attr,
1157 const char *value, size_t len, void *d),
1158 void *data);
1159
1160
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001161/** @brief Set the value of the given debug attribute
1162 * @param dev A pointer to an iio_device structure
1163 * @param attr A NULL-terminated string corresponding to the name of the
1164 * debug attribute
1165 * @param src A NULL-terminated string to set the debug attribute to
1166 * @return On success, the number of bytes written
Paul Cercueil1da28122014-05-22 10:59:49 +02001167 * @return On error, a negative errno code is returned
1168 *
1169 * <b>NOTE:</b>By passing NULL as the "attr" argument to
1170 * iio_device_debug_attr_write, it is now possible to write all of the
1171 * debug attributes of a device.
1172 *
1173 * The buffer must contain one block of data per debug attribute of the device,
1174 * by the order they appear in the iio_device structure.
1175 *
1176 * The first four bytes of one block correspond to a 32-bit signed value in
1177 * network order. If negative, the debug attribute is not written; if positive,
1178 * it corresponds to the length of the data to write. In that case, the rest
1179 * of the block must contain the data. */
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001180__api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1181 const char *attr, const char *src);
1182
Paul Cercueile3960742014-04-15 16:00:50 +02001183
Paul Cercueilcecda352014-05-06 18:14:29 +02001184/** @brief Set the value of the given debug attribute
1185 * @param dev A pointer to an iio_device structure
1186 * @param attr A NULL-terminated string corresponding to the name of the
1187 * debug attribute
1188 * @param src A pointer to the data to be written
1189 * @param len The number of bytes that should be written
1190 * @return On success, the number of bytes written
1191 * @return On error, a negative errno code is returned */
1192__api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1193 const char *attr, const void *src, size_t len);
1194
1195
Paul Cercueil1b36a012014-06-05 14:39:31 +02001196/** @brief Set the values of all debug attributes
1197 * @param dev A pointer to an iio_device structure
1198 * @param cb A pointer to a callback function
1199 * @param data A pointer that will be passed to the callback function
1200 * @return On success, 0 is returned
1201 * @return On error, a negative errno code is returned
1202 *
1203 * <b>NOTE:</b> This function is especially useful when used with the network
1204 * backend, as all the debug attributes are written in one single command. */
1205__api int iio_device_debug_attr_write_all(struct iio_device *dev,
1206 ssize_t (*cb)(struct iio_device *dev,
1207 const char *attr, void *buf, size_t len, void *d),
1208 void *data);
1209
1210
Paul Cercueile3960742014-04-15 16:00:50 +02001211/** @brief Read the content of the given debug attribute
1212 * @param dev A pointer to an iio_device structure
1213 * @param attr A NULL-terminated string corresponding to the name of the
1214 * debug attribute
1215 * @param val A pointer to a bool variable where the value should be stored
1216 * @return On success, 0 is returned
1217 * @return On error, a negative errno code is returned */
1218__api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1219 const char *attr, bool *val);
1220
1221
1222/** @brief Read the content of the given debug attribute
1223 * @param dev A pointer to an iio_device structure
1224 * @param attr A NULL-terminated string corresponding to the name of the
1225 * debug attribute
1226 * @param val A pointer to a long long variable where the value should be stored
1227 * @return On success, 0 is returned
1228 * @return On error, a negative errno code is returned */
1229__api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1230 const char *attr, long long *val);
1231
1232
1233/** @brief Read the content of the given debug attribute
1234 * @param dev A pointer to an iio_device structure
1235 * @param attr A NULL-terminated string corresponding to the name of the
1236 * debug attribute
1237 * @param val A pointer to a double variable where the value should be stored
1238 * @return On success, 0 is returned
1239 * @return On error, a negative errno code is returned */
1240__api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1241 const char *attr, double *val);
1242
1243
1244/** @brief Set the value of the given debug attribute
1245 * @param dev A pointer to an iio_device structure
1246 * @param attr A NULL-terminated string corresponding to the name of the
1247 * debug attribute
1248 * @param val A bool value to set the debug attribute to
1249 * @return On success, 0 is returned
1250 * @return On error, a negative errno code is returned */
1251__api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1252 const char *attr, bool val);
1253
1254
1255/** @brief Set the value of the given debug attribute
1256 * @param dev A pointer to an iio_device structure
1257 * @param attr A NULL-terminated string corresponding to the name of the
1258 * debug attribute
1259 * @param val A long long value to set the debug attribute to
1260 * @return On success, 0 is returned
1261 * @return On error, a negative errno code is returned */
1262__api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1263 const char *attr, long long val);
1264
1265
1266/** @brief Set the value of the given debug attribute
1267 * @param dev A pointer to an iio_device structure
1268 * @param attr A NULL-terminated string corresponding to the name of the
1269 * debug attribute
1270 * @param val A double value to set the debug attribute to
1271 * @return On success, 0 is returned
1272 * @return On error, a negative errno code is returned */
1273__api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1274 const char *attr, double val);
1275
Paul Cercueil108e0aa2014-05-06 14:45:14 +02001276
1277/** @brief Identify the channel or debug attribute corresponding to a filename
1278 * @param dev A pointer to an iio_device structure
1279 * @param filename A NULL-terminated string corresponding to the filename
1280 * @param chn A pointer to a pointer of an iio_channel structure. The pointed
1281 * pointer will be set to the address of the iio_channel structure if the
1282 * filename correspond to the attribute of a channel, or NULL otherwise.
1283 * @param attr A pointer to a NULL-terminated string. The pointer
1284 * pointer will be set to point to the name of the attribute corresponding to
1285 * the filename.
1286 * @return On success, 0 is returned, and *chn and *attr are modified.
1287 * @return On error, a negative errno code is returned. *chn and *attr are not
1288 * modified. */
1289__api int iio_device_identify_filename(const struct iio_device *dev,
1290 const char *filename, struct iio_channel **chn,
1291 const char **attr);
1292
1293
Paul Cercueil14405872014-05-07 14:00:32 +02001294/** @brief Set the value of a hardware register
1295 * @param dev A pointer to an iio_device structure
1296 * @param address The address of the register
1297 * @param value The value to set the register to
1298 * @return On success, 0 is returned
1299 * @return On error, a negative errno code is returned */
1300__api int iio_device_reg_write(struct iio_device *dev,
1301 uint32_t address, uint32_t value);
1302
1303
1304/** @brief Get the value of a hardware register
1305 * @param dev A pointer to an iio_device structure
1306 * @param address The address of the register
1307 * @param value A pointer to the variable where the value will be written
1308 * @return On success, 0 is returned
1309 * @return On error, a negative errno code is returned */
1310__api int iio_device_reg_read(struct iio_device *dev,
1311 uint32_t address, uint32_t *value);
1312
1313
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001314/** @} */
1315
Paul Cercueila167e0c2014-04-08 14:50:41 +02001316#ifdef __cplusplus
1317}
1318#endif
1319
Paul Cercueil0b2ce712014-02-17 15:04:18 +01001320#endif /* __IIO_H__ */