blob: dd56a3fd786d8449f999a63bb710c7a7a53228bb [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 Cercueilbc2645b2015-12-11 11:29:21 +010038#define _SSIZE_T_DEFINED
Paul Cercueilb669f692014-04-04 13:42:24 +020039#endif
40
Paul Cercueil59f2aa32014-04-04 16:28:51 +020041#ifdef __GNUC__
42#define __cnst __attribute__((const))
43#define __pure __attribute__((pure))
Paul Cercueil83f21892014-05-19 13:00:39 +020044#define __notused __attribute__((unused))
Paul Cercueil59f2aa32014-04-04 16:28:51 +020045#else
46#define __cnst
47#define __pure
Paul Cercueil83f21892014-05-19 13:00:39 +020048#define __notused
Paul Cercueil59f2aa32014-04-04 16:28:51 +020049#endif
50
51#ifdef _WIN32
52# ifdef LIBIIO_EXPORTS
Paul Cercueil59f2aa32014-04-04 16:28:51 +020053# define __api __declspec(dllexport)
Paul Cercueil7288c332014-04-07 16:25:11 +020054# else
55# define __api __declspec(dllimport)
Paul Cercueil59f2aa32014-04-04 16:28:51 +020056# endif
57#elif __GNUC__ >= 4
58# define __api __attribute__((visibility ("default")))
59#else
60# define __api
61#endif
62
Paul Cercueil0b2ce712014-02-17 15:04:18 +010063struct iio_context;
64struct iio_device;
65struct iio_channel;
Paul Cercueila689cd92014-03-20 16:37:25 +010066struct iio_buffer;
Paul Cercueil0b2ce712014-02-17 15:04:18 +010067
Paul Cercueilb4afdd92014-04-08 12:37:21 +020068
Paul Cercueil306cb1c2014-04-11 14:46:45 +020069/* ---------------------------------------------------------------------------*/
Paul Cercueil53ed9432014-11-20 13:46:04 +010070/* ------------------------- Top-level functions -----------------------------*/
71/** @defgroup TopLevel Top-level functions
72 * @{ */
73
74
75/** @brief Get the version of the libiio library
76 * @param major A pointer to an unsigned integer (NULL accepted)
77 * @param minor A pointer to an unsigned integer (NULL accepted)
78 * @param git_tag A pointer to a 8-characters buffer (NULL accepted) */
79__api void iio_library_get_version(unsigned int *major,
80 unsigned int *minor, char git_tag[8]);
81
82
Paul Cercueil3fa34382015-05-22 10:54:28 +020083/** @brief Get a string description of an error code
84 * @param err The error code
85 * @param dst A pointer to the memory area where the NULL-terminated string
86 * corresponding to the error message will be stored
87 * @param len The available length of the memory area, in bytes */
88__api void iio_strerror(int err, char *dst, size_t len);
89
90
Paul Cercueil53ed9432014-11-20 13:46:04 +010091/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +020092/* ------------------------- Context functions -------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +020093/** @defgroup Context Context
94 * @{
95 * @struct iio_context
96 * @brief Contains the representation of an IIO context */
Paul Cercueilb4afdd92014-04-08 12:37:21 +020097
Paul Cercueil306cb1c2014-04-11 14:46:45 +020098
Paul Cercueil8f56ea72014-10-28 15:18:18 +010099/** @brief Create a context from local or remote IIO devices
100 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100101 * @return On failure, NULL is returned and errno is set appropriately
Paul Cercueil8f56ea72014-10-28 15:18:18 +0100102 *
103 * <b>NOTE:</b> This function will create a network context if the IIOD_REMOTE
104 * environment variable is set to the hostname where the IIOD server runs. If
105 * set to an empty string, the server will be discovered using ZeroConf.
106 * If the environment variable is not set, a local context will be created
107 * instead. */
108__api struct iio_context * iio_create_default_context(void);
109
110
111/** @brief Create a context from local IIO devices (Linux only)
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200112 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100113 * @return On failure, NULL is returned and errno is set appropriately */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200114__api struct iio_context * iio_create_local_context(void);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200115
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200116
117/** @brief Create a context from a XML file
118 * @param xml_file Path to the XML file to open
119 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100120 * @return On failure, NULL is returned and errno is set appropriately
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200121 *
122 * <b>NOTE:</b> The format of the XML must comply to the one returned by
123 * iio_context_get_xml. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200124__api struct iio_context * iio_create_xml_context(const char *xml_file);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200125
126
127/** @brief Create a context from XML data in memory
128 * @param xml Pointer to the XML data in memory
129 * @param len Length of the XML string in memory (excluding the final \0)
130 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100131 * @return On failure, NULL is returned and errno is set appropriately
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200132 *
133 * <b>NOTE:</b> The format of the XML must comply to the one returned by
134 * iio_context_get_xml */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200135__api struct iio_context * iio_create_xml_context_mem(
136 const char *xml, size_t len);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200137
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200138
139/** @brief Create a context from the network
140 * @param host Hostname, IPv4 or IPv6 address where the IIO Daemon is running
141 * @return On success, a pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100142 * @return On failure, NULL is returned and errno is set appropriately */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200143__api struct iio_context * iio_create_network_context(const char *host);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200144
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200145
Paul Cercueile06f4ce2015-04-20 12:59:31 +0200146/** @brief Create a context from USB devices
147 * @param vid Vendor identification number
148 * @param pid Product identification number
149 * @return On success, a pointer to an iio_context structure
150 * @return On failure, NULL is returned and errno is set appropriately */
151__api struct iio_context * iio_create_usb_context(
152 unsigned short vid, unsigned short pid);
153
154
Paul Cercueil63d5e7c2014-10-28 14:33:08 +0100155/** @brief Duplicate a pre-existing IIO context
156 * @param ctx A pointer to an iio_context structure
157 * @return On success, A pointer to an iio_context structure
Paul Cercueildfeca0d2015-03-16 17:18:00 +0100158 * @return On failure, NULL is returned and errno is set appropriately */
Paul Cercueil63d5e7c2014-10-28 14:33:08 +0100159__api struct iio_context * iio_context_clone(const struct iio_context *ctx);
160
161
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200162/** @brief Destroy the given context
163 * @param ctx A pointer to an iio_context structure
164 *
165 * <b>NOTE:</b> After that function, the iio_context pointer shall be invalid. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200166__api void iio_context_destroy(struct iio_context *ctx);
Paul Cercueil0b2ce712014-02-17 15:04:18 +0100167
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200168
Paul Cercueile45f8762014-05-02 11:19:26 +0200169/** @brief Get the version of the backend in use
170 * @param ctx A pointer to an iio_context structure
Paul Cercueild15d9952014-05-20 11:40:08 +0200171 * @param major A pointer to an unsigned integer (NULL accepted)
172 * @param minor A pointer to an unsigned integer (NULL accepted)
Paul Cercueil9de9e9d2014-05-20 13:18:19 +0200173 * @param git_tag A pointer to a 8-characters buffer (NULL accepted)
Paul Cercueile45f8762014-05-02 11:19:26 +0200174 * @return On success, 0 is returned
175 * @return On error, a negative errno code is returned */
176__api int iio_context_get_version(const struct iio_context *ctx,
Paul Cercueil9de9e9d2014-05-20 13:18:19 +0200177 unsigned int *major, unsigned int *minor, char git_tag[8]);
Paul Cercueile45f8762014-05-02 11:19:26 +0200178
179
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200180/** @brief Obtain a XML representation of the given context
181 * @param ctx A pointer to an iio_context structure
182 * @return A pointer to a static NULL-terminated string */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200183__api __pure const char * iio_context_get_xml(const struct iio_context *ctx);
184
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200185
186/** @brief Get the name of the given context
187 * @param ctx A pointer to an iio_context structure
188 * @return A pointer to a static NULL-terminated string
189 *
190 * <b>NOTE:</b>The returned string will be <b><i>local</i></b>,
191 * <b><i>xml</i></b> or <b><i>network</i></b> when the context has been
192 * created with the local, xml and network backends respectively.*/
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200193__api __pure const char * iio_context_get_name(const struct iio_context *ctx);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200194
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200195
Paul Cercueil3ac36c12015-01-08 14:44:00 +0100196/** @brief Get a description of the given context
197 * @param ctx A pointer to an iio_context structure
198 * @return A pointer to a static NULL-terminated string
199 *
200 * <b>NOTE:</b>The returned string will contain human-readable information about
201 * the current context. */
202__api __pure const char * iio_context_get_description(
203 const struct iio_context *ctx);
204
205
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200206/** @brief Enumerate the devices found in the given context
207 * @param ctx A pointer to an iio_context structure
208 * @return The number of devices found */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200209__api __pure unsigned int iio_context_get_devices_count(
210 const struct iio_context *ctx);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200211
212
213/** @brief Get the device present at the given index
214 * @param ctx A pointer to an iio_context structure
215 * @param index The index corresponding to the device
216 * @return On success, a pointer to an iio_device structure
217 * @return If the index is invalid, NULL is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200218__api __pure struct iio_device * iio_context_get_device(
219 const struct iio_context *ctx, unsigned int index);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200220
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200221
222/** @brief Try to find a device structure by its name of ID
223 * @param ctx A pointer to an iio_context structure
224 * @param name A NULL-terminated string corresponding to the name or the ID of
225 * the device to search for
226 * @return On success, a pointer to an iio_device structure
227 * @return If the name or ID does not correspond to any known device, NULL is
228 * returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200229__api __pure struct iio_device * iio_context_find_device(
230 const struct iio_context *ctx, const char *name);
Paul Cercueil0b2ce712014-02-17 15:04:18 +0100231
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200232
Paul Cercueil4ca73542014-06-10 16:23:29 +0200233/** @brief Set a timeout for I/O operations
234 * @param ctx A pointer to an iio_context structure
235 * @param timeout_ms A positive integer representing the time in milliseconds
236 * after which a timeout occurs
237 * @return On success, 0 is returned
238 * @return On error, a negative errno code is returned */
239__api int iio_context_set_timeout(
240 struct iio_context *ctx, unsigned int timeout_ms);
241
242
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200243/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200244/* ------------------------- Device functions --------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200245/** @defgroup Device Device
246 * @{
247 * @struct iio_device
248 * @brief Represents a device in the IIO context */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200249
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200250
Paul Cercueil03b6c812015-04-14 16:49:06 +0200251/** @brief Retrieve a pointer to the iio_context structure
252 * @param dev A pointer to an iio_device structure
253 * @return A pointer to an iio_context structure */
254__api __pure const struct iio_context * iio_device_get_context(
255 const struct iio_device *dev);
256
257
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200258/** @brief Retrieve the device ID (e.g. <b><i>iio:device0</i></b>)
259 * @param dev A pointer to an iio_device structure
260 * @return A pointer to a static NULL-terminated string */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200261__api __pure const char * iio_device_get_id(const struct iio_device *dev);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200262
263
264/** @brief Retrieve the device name (e.g. <b><i>xadc</i></b>)
265 * @param dev A pointer to an iio_device structure
266 * @return A pointer to a static NULL-terminated string
267 *
268 * <b>NOTE:</b> if the device has no name, NULL is returned. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200269__api __pure const char * iio_device_get_name(const struct iio_device *dev);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200270
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200271
272/** @brief Enumerate the channels of the given device
273 * @param dev A pointer to an iio_device structure
274 * @return The number of channels found */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200275__api __pure unsigned int iio_device_get_channels_count(
276 const struct iio_device *dev);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200277
278
279/** @brief Enumerate the device-specific attributes of the given device
280 * @param dev A pointer to an iio_device structure
281 * @return The number of device-specific attributes found */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200282__api __pure unsigned int iio_device_get_attrs_count(
283 const struct iio_device *dev);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200284
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200285
286/** @brief Get the channel present at the given index
287 * @param dev A pointer to an iio_device structure
288 * @param index The index corresponding to the channel
289 * @return On success, a pointer to an iio_channel structure
290 * @return If the index is invalid, NULL is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200291__api __pure struct iio_channel * iio_device_get_channel(
292 const struct iio_device *dev, unsigned int index);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200293
294
295/** @brief Get the device-specific attribute present at the given index
296 * @param dev A pointer to an iio_device structure
297 * @param index The index corresponding to the attribute
298 * @return On success, a pointer to a static NULL-terminated string
299 * @return If the index is invalid, NULL is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200300__api __pure const char * iio_device_get_attr(
301 const struct iio_device *dev, unsigned int index);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200302
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200303
304/** @brief Try to find a channel structure by its name of ID
305 * @param dev A pointer to an iio_device structure
306 * @param name A NULL-terminated string corresponding to the name or the ID of
307 * the channel to search for
308 * @param output True if the searched channel is output, False otherwise
309 * @return On success, a pointer to an iio_channel structure
310 * @return If the name or ID does not correspond to any known channel of the
311 * given device, NULL is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200312__api __pure struct iio_channel * iio_device_find_channel(
313 const struct iio_device *dev, const char *name, bool output);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200314
315
316/** @brief Try to find a device-specific attribute by its name
317 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200318 * @param name A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200319 * attribute
320 * @return On success, a pointer to a static NULL-terminated string
321 * @return If the name does not correspond to any known attribute of the given
322 * device, NULL is returned
323 *
324 * <b>NOTE:</b> This function is useful to detect the presence of an attribute.
325 * It can also be used to retrieve the name of an attribute as a pointer to a
326 * static string from a dynamically allocated string. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200327__api __pure const char * iio_device_find_attr(
328 const struct iio_device *dev, const char *name);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200329
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200330
331/** @brief Read the content of the given device-specific attribute
332 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200333 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200334 * attribute
335 * @param dst A pointer to the memory area where the NULL-terminated string
336 * corresponding to the value read will be stored
337 * @param len The available length of the memory area, in bytes
338 * @return On success, the number of bytes written to the buffer
Paul Cercueil4ca6ddc2014-05-21 14:51:50 +0200339 * @return On error, a negative errno code is returned
340 *
341 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_device_attr_read,
342 * it is now possible to read all of the attributes of a device.
343 *
344 * The buffer is filled with one block of data per attribute of the device,
345 * by the order they appear in the iio_device structure.
346 *
347 * The first four bytes of one block correspond to a 32-bit signed value in
348 * network order. If negative, it corresponds to the errno code that were
349 * returned when reading the attribute; if positive, it corresponds to the
350 * length of the data read. In that case, the rest of the block contains
351 * the data. */
352 __api ssize_t iio_device_attr_read(const struct iio_device *dev,
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200353 const char *attr, char *dst, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200354
355
Paul Cercueil1b36a012014-06-05 14:39:31 +0200356/** @brief Read the content of all device-specific attributes
357 * @param dev A pointer to an iio_device structure
358 * @param cb A pointer to a callback function
359 * @param data A pointer that will be passed to the callback function
360 * @return On success, 0 is returned
361 * @return On error, a negative errno code is returned
362 *
363 * <b>NOTE:</b> This function is especially useful when used with the network
364 * backend, as all the device-specific attributes are read in one single
365 * command. */
366__api int iio_device_attr_read_all(struct iio_device *dev,
367 int (*cb)(struct iio_device *dev, const char *attr,
368 const char *value, size_t len, void *d),
369 void *data);
370
371
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200372/** @brief Read the content of the given device-specific attribute
373 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200374 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200375 * attribute
376 * @param val A pointer to a bool variable where the value should be stored
377 * @return On success, 0 is returned
378 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200379__api int iio_device_attr_read_bool(const struct iio_device *dev,
380 const char *attr, bool *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200381
382
383/** @brief Read the content of the given device-specific attribute
384 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200385 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200386 * attribute
387 * @param val A pointer to a long long variable where the value should be stored
388 * @return On success, 0 is returned
389 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200390__api int iio_device_attr_read_longlong(const struct iio_device *dev,
391 const char *attr, long long *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200392
393
394/** @brief Read the content of the given device-specific attribute
395 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200396 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200397 * attribute
398 * @param val A pointer to a double variable where the value should be stored
399 * @return On success, 0 is returned
400 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200401__api int iio_device_attr_read_double(const struct iio_device *dev,
402 const char *attr, double *val);
403
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200404
405/** @brief Set the value of the given device-specific attribute
406 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200407 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200408 * attribute
409 * @param src A NULL-terminated string to set the attribute to
410 * @return On success, the number of bytes written
Paul Cercueil1da28122014-05-22 10:59:49 +0200411 * @return On error, a negative errno code is returned
412 *
413 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_device_attr_write,
414 * it is now possible to write all of the attributes of a device.
415 *
416 * The buffer must contain one block of data per attribute of the device,
417 * by the order they appear in the iio_device structure.
418 *
419 * The first four bytes of one block correspond to a 32-bit signed value in
420 * network order. If negative, the attribute is not written; if positive,
421 * it corresponds to the length of the data to write. In that case, the rest
422 * of the block must contain the data. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200423__api ssize_t iio_device_attr_write(const struct iio_device *dev,
424 const char *attr, const char *src);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200425
426
427/** @brief Set the value of the given device-specific attribute
428 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200429 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200430 * attribute
Paul Cercueilcecda352014-05-06 18:14:29 +0200431 * @param src A pointer to the data to be written
432 * @param len The number of bytes that should be written
433 * @return On success, the number of bytes written
434 * @return On error, a negative errno code is returned */
435__api ssize_t iio_device_attr_write_raw(const struct iio_device *dev,
436 const char *attr, const void *src, size_t len);
437
438
Paul Cercueil1b36a012014-06-05 14:39:31 +0200439/** @brief Set the values of all device-specific attributes
440 * @param dev A pointer to an iio_device structure
441 * @param cb A pointer to a callback function
442 * @param data A pointer that will be passed to the callback function
443 * @return On success, 0 is returned
444 * @return On error, a negative errno code is returned
445 *
446 * <b>NOTE:</b> This function is especially useful when used with the network
447 * backend, as all the device-specific attributes are written in one single
448 * command. */
449__api int iio_device_attr_write_all(struct iio_device *dev,
450 ssize_t (*cb)(struct iio_device *dev,
451 const char *attr, void *buf, size_t len, void *d),
452 void *data);
453
454
Paul Cercueilcecda352014-05-06 18:14:29 +0200455/** @brief Set the value of the given device-specific attribute
456 * @param dev A pointer to an iio_device structure
457 * @param attr A NULL-terminated string corresponding to the name of the
458 * attribute
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200459 * @param val A bool value to set the attribute to
460 * @return On success, 0 is returned
461 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200462__api int iio_device_attr_write_bool(const struct iio_device *dev,
463 const char *attr, bool val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200464
465
466/** @brief Set the value of the given device-specific attribute
467 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200468 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200469 * attribute
470 * @param val A long long value to set the attribute to
471 * @return On success, 0 is returned
472 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200473__api int iio_device_attr_write_longlong(const struct iio_device *dev,
474 const char *attr, long long val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200475
476
477/** @brief Set the value of the given device-specific attribute
478 * @param dev A pointer to an iio_device structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200479 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200480 * attribute
481 * @param val A double value to set the attribute to
482 * @return On success, 0 is returned
483 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200484__api int iio_device_attr_write_double(const struct iio_device *dev,
485 const char *attr, double val);
486
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200487
488/** @brief Associate a pointer to an iio_device structure
489 * @param dev A pointer to an iio_device structure
490 * @param data The pointer to be associated */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200491__api void iio_device_set_data(struct iio_device *dev, void *data);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200492
493
494/** @brief Retrieve a previously associated pointer of an iio_device structure
495 * @param dev A pointer to an iio_device structure
496 * @return The pointer previously associated if present, or NULL */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200497__api void * iio_device_get_data(const struct iio_device *dev);
498
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200499
500/** @brief Retrieve the trigger of a given device
501 * @param dev A pointer to an iio_device structure
502 * @param trigger a pointer to a pointer of an iio_device structure. The pointed
503 * pointer will be set to the address of the iio_device structure corresponding
504 * to the associated trigger device.
505 * @return On success, 0 is returned
506 * @return On error, a negative errno code is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200507__api int iio_device_get_trigger(const struct iio_device *dev,
Paul Cercueil24ffa532014-03-10 12:39:58 +0100508 const struct iio_device **trigger);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200509
510
511/** @brief Associate a trigger to a given device
512 * @param dev A pointer to an iio_device structure
513 * @param trigger a pointer to the iio_device structure corresponding to the
514 * trigger that should be associated.
515 * @return On success, 0 is returned
516 * @return On error, a negative errno code is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +0200517__api int iio_device_set_trigger(const struct iio_device *dev,
Paul Cercueil24ffa532014-03-10 12:39:58 +0100518 const struct iio_device *trigger);
Paul Cercueil0b2ce712014-02-17 15:04:18 +0100519
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200520
521/** @brief Return True if the given device is a trigger
522 * @param dev A pointer to an iio_device structure
523 * @return True if the device is a trigger, False otherwise */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200524__api __pure bool iio_device_is_trigger(const struct iio_device *dev);
525
Romain Roffé6c385d92015-06-30 13:36:05 +0200526/**
527 * @brief Configure the number of kernel buffers for a device
528 *
529 * This function allows to change the number of buffers on kernel side.
530 * @param dev A pointer to an iio_device structure
531 * @param nb_buffers The number of buffers
532 * @return On success, 0 is returned
533 * @return On error, a negative errno code is returned */
534__api int iio_device_set_kernel_buffers_count(const struct iio_device *dev,
535 unsigned int nb_buffers);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200536
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200537/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200538/* ------------------------- Channel functions -------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200539/** @defgroup Channel Channel
540 * @{
541 * @struct iio_channel
542 * @brief Represents an input or output channel of a device */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200543
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200544
Paul Cercueil03b6c812015-04-14 16:49:06 +0200545/** @brief Retrieve a pointer to the iio_device structure
546 * @param chn A pointer to an iio_channel structure
547 * @return A pointer to an iio_device structure */
548__api __pure const struct iio_device * iio_channel_get_device(
549 const struct iio_channel *chn);
550
551
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200552/** @brief Retrieve the channel ID (e.g. <b><i>voltage0</i></b>)
553 * @param chn A pointer to an iio_channel structure
554 * @return A pointer to a static NULL-terminated string */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200555__api __pure const char * iio_channel_get_id(const struct iio_channel *chn);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200556
557
558/** @brief Retrieve the channel name (e.g. <b><i>vccint</i></b>)
559 * @param chn A pointer to an iio_channel structure
560 * @return A pointer to a static NULL-terminated string
561 *
562 * <b>NOTE:</b> if the channel has no name, NULL is returned. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200563__api __pure const char * iio_channel_get_name(const struct iio_channel *chn);
564
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200565
566/** @brief Return True if the given channel is an output channel
567 * @param chn A pointer to an iio_channel structure
568 * @return True if the channel is an output channel, False otherwise */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200569__api __pure bool iio_channel_is_output(const struct iio_channel *chn);
570
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200571
Paul Cercueil85aaf482014-04-24 16:39:09 +0200572/** @brief Return True if the given channel is a scan element
573 * @param chn A pointer to an iio_channel structure
574 * @return True if the channel is a scan element, False otherwise
575 *
576 * <b>NOTE:</b> a channel that is a scan element is a channel that can
577 * generate samples (for an input channel) or receive samples (for an output
578 * channel) after being enabled. */
579__api __pure bool iio_channel_is_scan_element(const struct iio_channel *chn);
580
581
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200582/** @brief Enumerate the channel-specific attributes of the given channel
583 * @param chn A pointer to an iio_channel structure
584 * @return The number of channel-specific attributes found */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200585__api __pure unsigned int iio_channel_get_attrs_count(
586 const struct iio_channel *chn);
587
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200588
589/** @brief Get the channel-specific attribute present at the given index
590 * @param chn A pointer to an iio_channel structure
591 * @param index The index corresponding to the attribute
592 * @return On success, a pointer to a static NULL-terminated string
593 * @return If the index is invalid, NULL is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200594__api __pure const char * iio_channel_get_attr(
595 const struct iio_channel *chn, unsigned int index);
596
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200597
598/** @brief Try to find a channel-specific attribute by its name
599 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200600 * @param name A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200601 * attribute
602 * @return On success, a pointer to a static NULL-terminated string
603 * @return If the name does not correspond to any known attribute of the given
604 * channel, NULL is returned
605 *
606 * <b>NOTE:</b> This function is useful to detect the presence of an attribute.
607 * It can also be used to retrieve the name of an attribute as a pointer to a
608 * static string from a dynamically allocated string. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200609__api __pure const char * iio_channel_find_attr(
610 const struct iio_channel *chn, const char *name);
611
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200612
Paul Cercueil6f8dbd42014-05-05 17:05:59 +0200613/** @brief Retrieve the filename of an attribute
614 * @param chn A pointer to an iio_channel structure
615 * @param attr a NULL-terminated string corresponding to the name of the
616 * attribute
617 * @return On success, a pointer to a static NULL-terminated string
618 * @return If the attribute name is unknown, NULL is returned */
619__api __pure const char * iio_channel_attr_get_filename(
620 const struct iio_channel *chn, const char *attr);
621
622
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200623/** @brief Read the content of the given channel-specific attribute
624 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200625 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200626 * attribute
627 * @param dst A pointer to the memory area where the NULL-terminated string
628 * corresponding to the value read will be stored
629 * @param len The available length of the memory area, in bytes
630 * @return On success, the number of bytes written to the buffer
Paul Cercueil4ca6ddc2014-05-21 14:51:50 +0200631 * @return On error, a negative errno code is returned
632 *
633 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_channel_attr_read,
634 * it is now possible to read all of the attributes of a channel.
635 *
636 * The buffer is filled with one block of data per attribute of the channel,
637 * by the order they appear in the iio_channel structure.
638 *
639 * The first four bytes of one block correspond to a 32-bit signed value in
640 * network order. If negative, it corresponds to the errno code that were
641 * returned when reading the attribute; if positive, it corresponds to the
642 * length of the data read. In that case, the rest of the block contains
643 * the data. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200644__api ssize_t iio_channel_attr_read(const struct iio_channel *chn,
645 const char *attr, char *dst, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200646
647
Paul Cercueil47d23d02014-06-05 14:46:20 +0200648/** @brief Read the content of all channel-specific attributes
649 * @param chn A pointer to an iio_channel structure
650 * @param cb A pointer to a callback function
651 * @param data A pointer that will be passed to the callback function
652 * @return On success, 0 is returned
653 * @return On error, a negative errno code is returned
654 *
655 * <b>NOTE:</b> This function is especially useful when used with the network
656 * backend, as all the channel-specific attributes are read in one single
657 * command. */
658__api int iio_channel_attr_read_all(struct iio_channel *chn,
659 int (*cb)(struct iio_channel *chn,
660 const char *attr, const char *val, size_t len, void *d),
661 void *data);
662
663
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200664/** @brief Read the content of the given channel-specific attribute
665 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200666 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200667 * attribute
668 * @param val A pointer to a bool variable where the value should be stored
669 * @return On success, 0 is returned
670 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200671__api int iio_channel_attr_read_bool(const struct iio_channel *chn,
672 const char *attr, bool *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200673
674
675/** @brief Read the content of the given channel-specific attribute
676 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200677 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200678 * attribute
679 * @param val A pointer to a long long variable where the value should be stored
680 * @return On success, 0 is returned
681 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200682__api int iio_channel_attr_read_longlong(const struct iio_channel *chn,
683 const char *attr, long long *val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200684
685
686/** @brief Read the content of the given channel-specific attribute
687 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200688 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200689 * attribute
690 * @param val A pointer to a double variable where the value should be stored
691 * @return On success, 0 is returned
692 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200693__api int iio_channel_attr_read_double(const struct iio_channel *chn,
694 const char *attr, double *val);
695
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200696
697/** @brief Set the value of the given channel-specific attribute
698 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200699 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200700 * attribute
701 * @param src A NULL-terminated string to set the attribute to
702 * @return On success, the number of bytes written
Paul Cercueil1da28122014-05-22 10:59:49 +0200703 * @return On error, a negative errno code is returned
704 *
705 * <b>NOTE:</b>By passing NULL as the "attr" argument to iio_channel_attr_write,
706 * it is now possible to write all of the attributes of a channel.
707 *
708 * The buffer must contain one block of data per attribute of the channel,
709 * by the order they appear in the iio_channel structure.
710 *
711 * The first four bytes of one block correspond to a 32-bit signed value in
712 * network order. If negative, the attribute is not written; if positive,
713 * it corresponds to the length of the data to write. In that case, the rest
714 * of the block must contain the data. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200715__api ssize_t iio_channel_attr_write(const struct iio_channel *chn,
716 const char *attr, const char *src);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200717
718
719/** @brief Set the value of the given channel-specific attribute
720 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200721 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200722 * attribute
Paul Cercueilcecda352014-05-06 18:14:29 +0200723 * @param src A pointer to the data to be written
724 * @param len The number of bytes that should be written
725 * @return On success, the number of bytes written
726 * @return On error, a negative errno code is returned */
727__api ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
728 const char *attr, const void *src, size_t len);
729
730
Paul Cercueil47d23d02014-06-05 14:46:20 +0200731/** @brief Set the values of all channel-specific attributes
732 * @param chn A pointer to an iio_channel structure
733 * @param cb A pointer to a callback function
734 * @param data A pointer that will be passed to the callback function
735 * @return On success, 0 is returned
736 * @return On error, a negative errno code is returned
737 *
738 * <b>NOTE:</b> This function is especially useful when used with the network
739 * backend, as all the channel-specific attributes are written in one single
740 * command. */
741__api int iio_channel_attr_write_all(struct iio_channel *chn,
742 ssize_t (*cb)(struct iio_channel *chn,
743 const char *attr, void *buf, size_t len, void *d),
744 void *data);
745
746
Paul Cercueilcecda352014-05-06 18:14:29 +0200747/** @brief Set the value of the given channel-specific attribute
748 * @param chn A pointer to an iio_channel structure
749 * @param attr A NULL-terminated string corresponding to the name of the
750 * attribute
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200751 * @param val A bool value to set the attribute to
752 * @return On success, 0 is returned
753 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200754__api int iio_channel_attr_write_bool(const struct iio_channel *chn,
755 const char *attr, bool val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200756
757
758/** @brief Set the value of the given channel-specific attribute
759 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200760 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200761 * attribute
762 * @param val A long long value to set the attribute to
763 * @return On success, 0 is returned
764 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200765__api int iio_channel_attr_write_longlong(const struct iio_channel *chn,
766 const char *attr, long long val);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200767
768
769/** @brief Set the value of the given channel-specific attribute
770 * @param chn A pointer to an iio_channel structure
Paul Cercueil30606d52014-04-14 16:04:15 +0200771 * @param attr A NULL-terminated string corresponding to the name of the
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200772 * attribute
773 * @param val A double value to set the attribute to
774 * @return On success, 0 is returned
775 * @return On error, a negative errno code is returned */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200776__api int iio_channel_attr_write_double(const struct iio_channel *chn,
777 const char *attr, double val);
778
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200779
780/** @brief Enable the given channel
781 * @param chn A pointer to an iio_channel structure
782 *
783 * <b>NOTE:</b>Before creating an iio_buffer structure with
784 * iio_device_create_buffer, it is required to enable at least one channel of
785 * the device to read from. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200786__api void iio_channel_enable(struct iio_channel *chn);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200787
788
789/** @brief Disable the given channel
790 * @param chn A pointer to an iio_channel structure */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200791__api void iio_channel_disable(struct iio_channel *chn);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200792
793
794/** @brief Returns True if the channel is enabled
795 * @param chn A pointer to an iio_channel structure
796 * @return True if the channel is enabled, False otherwise */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200797__api bool iio_channel_is_enabled(const struct iio_channel *chn);
798
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200799
800/** Demultiplex the samples of a given channel
801 * @param chn A pointer to an iio_channel structure
802 * @param buffer A pointer to an iio_buffer structure
803 * @param dst A pointer to the memory area where the demultiplexed data will be
804 * stored
805 * @param len The available length of the memory area, in bytes
806 * @return The size of the demultiplexed data, in bytes */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200807__api size_t iio_channel_read_raw(const struct iio_channel *chn,
808 struct iio_buffer *buffer, void *dst, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200809
810
811/** Demultiplex and convert the samples of a given channel
812 * @param chn A pointer to an iio_channel structure
813 * @param buffer A pointer to an iio_buffer structure
814 * @param dst A pointer to the memory area where the converted data will be
815 * stored
816 * @param len The available length of the memory area, in bytes
817 * @return The size of the converted data, in bytes */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200818__api size_t iio_channel_read(const struct iio_channel *chn,
819 struct iio_buffer *buffer, void *dst, size_t len);
820
821
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200822/** Multiplex the samples of a given channel
823 * @param chn A pointer to an iio_channel structure
824 * @param buffer A pointer to an iio_buffer structure
825 * @param src A pointer to the memory area where the sequential data will
826 * be read from
827 * @param len The length of the memory area, in bytes
828 * @return The number of bytes actually multiplexed */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200829__api size_t iio_channel_write_raw(const struct iio_channel *chn,
830 struct iio_buffer *buffer, const void *src, size_t len);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200831
832
833/** Convert and multiplex the samples of a given channel
834 * @param chn A pointer to an iio_channel structure
835 * @param buffer A pointer to an iio_buffer structure
836 * @param src A pointer to the memory area where the sequential data will
837 * be read from
838 * @param len The length of the memory area, in bytes
839 * @return The number of bytes actually converted and multiplexed */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200840__api size_t iio_channel_write(const struct iio_channel *chn,
841 struct iio_buffer *buffer, const void *src, size_t len);
842
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200843
844/** @brief Associate a pointer to an iio_channel structure
845 * @param chn A pointer to an iio_channel structure
846 * @param data The pointer to be associated */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200847__api void iio_channel_set_data(struct iio_channel *chn, void *data);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200848
849
850/** @brief Retrieve a previously associated pointer of an iio_channel structure
851 * @param chn A pointer to an iio_channel structure
852 * @return The pointer previously associated if present, or NULL */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200853__api void * iio_channel_get_data(const struct iio_channel *chn);
854
855
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200856/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200857/* ------------------------- Buffer functions --------------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200858/** @defgroup Buffer Buffer
859 * @{
860 * @struct iio_buffer
861 * @brief An input or output buffer, used to read or write samples */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200862
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200863
Paul Cercueil03b6c812015-04-14 16:49:06 +0200864/** @brief Retrieve a pointer to the iio_device structure
865 * @param buf A pointer to an iio_buffer structure
866 * @return A pointer to an iio_device structure */
867__api __pure const struct iio_device * iio_buffer_get_device(
868 const struct iio_buffer *buf);
869
870
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200871/** @brief Create an input or output buffer associated to the given device
872 * @param dev A pointer to an iio_device structure
873 * @param samples_count The number of samples that the buffer should contain
Paul Cercueil2004eaa2014-05-22 14:04:39 +0200874 * @param cyclic If True, enable cyclic mode
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200875 * @return On success, a pointer to an iio_buffer structure
Paul Cercueil3106e892014-04-30 11:29:51 +0200876 * @return On error, NULL is returned, and errno is set to the error code
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200877 *
878 * <b>NOTE:</b> Channels that have to be written to / read from must be enabled
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200879 * before creating the buffer. */
880__api struct iio_buffer * iio_device_create_buffer(const struct iio_device *dev,
Paul Cercueil2004eaa2014-05-22 14:04:39 +0200881 size_t samples_count, bool cyclic);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200882
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200883
884/** @brief Destroy the given buffer
885 * @param buf A pointer to an iio_buffer structure
886 *
887 * <b>NOTE:</b> After that function, the iio_buffer pointer shall be invalid. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200888__api void iio_buffer_destroy(struct iio_buffer *buf);
889
Romain Roffé6a881702015-06-30 16:25:43 +0200890/** @brief Get a pollable file descriptor
891 *
892 * Can be used to know when iio_buffer_refill() or iio_buffer_push() can be
893 * called
894 * @param buf A pointer to an iio_buffer structure
895 * @return On success, valid file descriptor
896 * @return On error, a negative errno code is returned
897 */
898__api int iio_buffer_get_poll_fd(struct iio_buffer *buf);
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200899
Romain Roffé0ea038d2015-06-30 13:35:38 +0200900/** @brief Make iio_buffer_refill() and iio_buffer_push() blocking or not
901 *
Paul Cercueil10ff7572015-11-19 17:12:34 +0100902 * After this function has been called with blocking == true,
Romain Roffé0ea038d2015-06-30 13:35:38 +0200903 * iio_buffer_refill() and iio_buffer_push() will return -EAGAIN if no data is
904 * ready.
905 * A device is blocking by default.
906 * @param buf A pointer to an iio_buffer structure
907 * @param blocking true if the buffer API should be blocking, else false
908 * @return On success, 0
909 * @return On error, a negative errno code is returned
910 */
911__api int iio_buffer_set_blocking_mode(struct iio_buffer *buf, bool blocking);
912
913
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200914/** @brief Fetch more samples from the hardware
915 * @param buf A pointer to an iio_buffer structure
916 * @return On success, the number of bytes read is returned
917 * @return On error, a negative errno code is returned
918 *
919 * <b>NOTE:</b> Only valid for input buffers */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200920__api ssize_t iio_buffer_refill(struct iio_buffer *buf);
921
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200922
923/** @brief Send the samples to the hardware
924 * @param buf A pointer to an iio_buffer structure
925 * @return On success, the number of bytes written is returned
926 * @return On error, a negative errno code is returned
927 *
928 * <b>NOTE:</b> Only valid for output buffers */
Paul Cercueil0183b6e2014-05-20 13:21:46 +0200929__api ssize_t iio_buffer_push(struct iio_buffer *buf);
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200930
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200931
Paul Cercueil8e7b4192015-08-05 13:03:35 +0200932/** @brief Send a given number of samples to the hardware
933 * @param buf A pointer to an iio_buffer structure
934 * @param samples_count The number of samples to submit
935 * @return On success, the number of bytes written is returned
936 * @return On error, a negative errno code is returned
937 *
938 * <b>NOTE:</b> Only valid for output buffers */
939__api ssize_t iio_buffer_push_partial(struct iio_buffer *buf,
940 size_t samples_count);
941
942
Paul Cercueil6d927162014-04-16 15:53:22 +0200943/** @brief Get the start address of the buffer
944 * @param buf A pointer to an iio_buffer structure
945 * @return A pointer corresponding to the start address of the buffer */
Paul Cercueil49106002015-03-04 13:19:20 +0100946__api void * iio_buffer_start(const struct iio_buffer *buf);
Paul Cercueil6d927162014-04-16 15:53:22 +0200947
948
Paul Cercueil306cb1c2014-04-11 14:46:45 +0200949/** @brief Find the first sample of a channel in a buffer
950 * @param buf A pointer to an iio_buffer structure
951 * @param chn A pointer to an iio_channel structure
952 * @return A pointer to the first sample found, or to the end of the buffer if
953 * no sample for the given channel is present in the buffer
954 *
955 * <b>NOTE:</b> This fonction, coupled with iio_buffer_step and iio_buffer_end,
956 * can be used to iterate on all the samples of a given channel present in the
957 * buffer, doing the following:
958 *
959 * @verbatim
960 for (void *ptr = iio_buffer_first(buffer, chn); ptr < iio_buffer_end(buffer); ptr += iio_buffer_step(buffer)) {
961 ....
962 }
963 @endverbatim */
964__api void * iio_buffer_first(const struct iio_buffer *buf,
965 const struct iio_channel *chn);
966
967
968/** @brief Get the step size between two samples of one channel
969 * @param buf A pointer to an iio_buffer structure
970 * @return the difference between the addresses of two consecutive samples of
971 * one same channel */
972__api ptrdiff_t iio_buffer_step(const struct iio_buffer *buf);
973
974
975/** @brief Get the address that follows the last sample in a buffer
976 * @param buf A pointer to an iio_buffer structure
977 * @return A pointer corresponding to the address that follows the last sample
978 * present in the buffer */
979__api void * iio_buffer_end(const struct iio_buffer *buf);
980
981
982/** @brief Call the supplied callback for each sample found in a buffer
983 * @param buf A pointer to an iio_buffer structure
984 * @param callback A pointer to a function to call for each sample found
985 * @param data A user-specified pointer that will be passed to the callback
986 *
987 * <b>NOTE:</b> The callback receives four arguments:
988 * * A pointer to the iio_channel structure corresponding to the sample,
989 * * A pointer to the sample itself,
990 * * The length of the sample in bytes,
991 * * The user-specified pointer passed to iio_buffer_foreach_sample. */
Paul Cercueilb4afdd92014-04-08 12:37:21 +0200992__api ssize_t iio_buffer_foreach_sample(struct iio_buffer *buf,
993 ssize_t (*callback)(const struct iio_channel *chn,
994 void *src, size_t bytes, void *d), void *data);
995
996
Paul Cercueila2d4bad2014-05-27 10:15:29 +0200997/** @brief Associate a pointer to an iio_buffer structure
998 * @param buf A pointer to an iio_buffer structure
999 * @param data The pointer to be associated */
1000__api void iio_buffer_set_data(struct iio_buffer *buf, void *data);
1001
1002
1003/** @brief Retrieve a previously associated pointer of an iio_buffer structure
1004 * @param buf A pointer to an iio_buffer structure
1005 * @return The pointer previously associated if present, or NULL */
1006__api void * iio_buffer_get_data(const struct iio_buffer *buf);
1007
1008
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001009/** @} *//* ------------------------------------------------------------------*/
Paul Cercueilb4afdd92014-04-08 12:37:21 +02001010/* ------------------------- Low-level functions -----------------------------*/
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001011/** @defgroup Debug Debug and low-level functions
1012 * @{
1013 * @struct iio_data_format
1014 * @brief Contains the format of a data sample.
1015 *
1016 * The different fields inform about the correct way to convert one sample from
1017 * its raw format (as read from / generated by the hardware) to its real-world
1018 * value.
1019 */
1020struct iio_data_format {
1021 /** @brief Total length of the sample, in bits */
1022 unsigned int length;
Paul Cercueilb4afdd92014-04-08 12:37:21 +02001023
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001024 /** @brief Length of valuable data in the sample, in bits */
1025 unsigned int bits;
1026
1027 /** @brief Right-shift to apply when converting sample */
1028 unsigned int shift;
1029
1030 /** @brief Contains True if the sample is signed */
1031 bool is_signed;
1032
Michael Hennerichfa3c6f62014-08-13 11:21:23 +02001033 /** @brief Contains True if the sample is fully defined, sign extended, etc. */
1034 bool is_fully_defined;
1035
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001036 /** @brief Contains True if the sample is in big-endian format */
1037 bool is_be;
1038
1039 /** @brief Contains True if the sample should be scaled when converted */
1040 bool with_scale;
1041
1042 /** @brief Contains the scale to apply if with_scale is set */
1043 double scale;
1044};
1045
1046
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001047/** @brief Get the current sample size
1048 * @param dev A pointer to an iio_device structure
1049 * @return On success, the sample size in bytes
1050 * @return On error, a negative errno code is returned
1051 *
1052 * <b>NOTE:</b> The sample size is not constant and will change when channels
1053 * get enabled or disabled. */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001054__api ssize_t iio_device_get_sample_size(const struct iio_device *dev);
Paul Cercueil1a474732014-03-17 11:38:34 +01001055
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001056
1057/** @brief Get the index of the given channel
1058 * @param chn A pointer to an iio_channel structure
1059 * @return On success, the index of the specified channel
1060 * @return On error, a negative errno code is returned */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001061__api __pure long iio_channel_get_index(const struct iio_channel *chn);
Paul Cercueilb4afdd92014-04-08 12:37:21 +02001062
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001063
1064/** @brief Get a pointer to a channel's data format structure
1065 * @param chn A pointer to an iio_channel structure
1066 * @return A pointer to the channel's iio_data_format structure */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001067__api __cnst const struct iio_data_format * iio_channel_get_data_format(
1068 const struct iio_channel *chn);
Paul Cercueil0b2ce712014-02-17 15:04:18 +01001069
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001070
1071/** @brief Convert the sample from hardware format to host format
1072 * @param chn A pointer to an iio_channel structure
1073 * @param dst A pointer to the destination buffer where the converted sample
1074 * should be written
1075 * @param src A pointer to the source buffer containing the sample */
Paul Cercueil59f2aa32014-04-04 16:28:51 +02001076__api void iio_channel_convert(const struct iio_channel *chn,
Paul Cercueil2917ffb2014-03-21 15:47:12 +01001077 void *dst, const void *src);
1078
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001079
1080/** @brief Convert the sample from host format to hardware format
1081 * @param chn A pointer to an iio_channel structure
1082 * @param dst A pointer to the destination buffer where the converted sample
1083 * should be written
1084 * @param src A pointer to the source buffer containing the sample */
Paul Cercueild840d4c2014-04-07 19:38:58 +02001085__api void iio_channel_convert_inverse(const struct iio_channel *chn,
1086 void *dst, const void *src);
1087
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001088
Paul Cercueil1ce35ef2014-04-15 12:28:40 +02001089/** @brief Enumerate the debug attributes of the given device
1090 * @param dev A pointer to an iio_device structure
1091 * @return The number of debug attributes found */
1092__api __pure unsigned int iio_device_get_debug_attrs_count(
1093 const struct iio_device *dev);
1094
1095
1096/** @brief Get the debug attribute present at the given index
1097 * @param dev A pointer to an iio_device structure
1098 * @param index The index corresponding to the debug attribute
1099 * @return On success, a pointer to a static NULL-terminated string
1100 * @return If the index is invalid, NULL is returned */
1101__api __pure const char * iio_device_get_debug_attr(
1102 const struct iio_device *dev, unsigned int index);
1103
1104
Paul Cercueil001d2152014-06-03 15:24:44 +02001105/** @brief Try to find a debug attribute by its name
1106 * @param dev A pointer to an iio_device structure
1107 * @param name A NULL-terminated string corresponding to the name of the
1108 * debug attribute
1109 * @return On success, a pointer to a static NULL-terminated string
1110 * @return If the name does not correspond to any known debug attribute of the
1111 * given device, NULL is returned
1112 *
1113 * <b>NOTE:</b> This function is useful to detect the presence of a debug
1114 * attribute.
1115 * It can also be used to retrieve the name of a debug attribute as a pointer
1116 * to a static string from a dynamically allocated string. */
1117__api __pure const char * iio_device_find_debug_attr(
1118 const struct iio_device *dev, const char *name);
1119
1120
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001121/** @brief Read the content of the given debug attribute
1122 * @param dev A pointer to an iio_device structure
1123 * @param attr A NULL-terminated string corresponding to the name of the
1124 * debug attribute
1125 * @param dst A pointer to the memory area where the NULL-terminated string
1126 * corresponding to the value read will be stored
1127 * @param len The available length of the memory area, in bytes
1128 * @return On success, the number of bytes written to the buffer
Paul Cercueil4ca6ddc2014-05-21 14:51:50 +02001129 * @return On error, a negative errno code is returned
1130 *
1131 * <b>NOTE:</b>By passing NULL as the "attr" argument to
1132 * iio_device_debug_attr_read, it is now possible to read all of the debug
1133 * attributes of a device.
1134 *
1135 * The buffer is filled with one block of data per debug attribute of the
1136 * device, by the order they appear in the iio_device structure.
1137 *
1138 * The first four bytes of one block correspond to a 32-bit signed value in
1139 * network order. If negative, it corresponds to the errno code that were
1140 * returned when reading the debug attribute; if positive, it corresponds
1141 * to the length of the data read. In that case, the rest of the block contains
1142 * the data. */
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001143__api ssize_t iio_device_debug_attr_read(const struct iio_device *dev,
1144 const char *attr, char *dst, size_t len);
1145
1146
Paul Cercueil1b36a012014-06-05 14:39:31 +02001147/** @brief Read the content of all debug attributes
1148 * @param dev A pointer to an iio_device structure
1149 * @param cb A pointer to a callback function
1150 * @param data A pointer that will be passed to the callback function
1151 * @return On success, 0 is returned
1152 * @return On error, a negative errno code is returned
1153 *
1154 * <b>NOTE:</b> This function is especially useful when used with the network
1155 * backend, as all the debug attributes are read in one single command. */
1156__api int iio_device_debug_attr_read_all(struct iio_device *dev,
1157 int (*cb)(struct iio_device *dev, const char *attr,
1158 const char *value, size_t len, void *d),
1159 void *data);
1160
1161
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001162/** @brief Set the value of the given debug attribute
1163 * @param dev A pointer to an iio_device structure
1164 * @param attr A NULL-terminated string corresponding to the name of the
1165 * debug attribute
1166 * @param src A NULL-terminated string to set the debug attribute to
1167 * @return On success, the number of bytes written
Paul Cercueil1da28122014-05-22 10:59:49 +02001168 * @return On error, a negative errno code is returned
1169 *
1170 * <b>NOTE:</b>By passing NULL as the "attr" argument to
1171 * iio_device_debug_attr_write, it is now possible to write all of the
1172 * debug attributes of a device.
1173 *
1174 * The buffer must contain one block of data per debug attribute of the device,
1175 * by the order they appear in the iio_device structure.
1176 *
1177 * The first four bytes of one block correspond to a 32-bit signed value in
1178 * network order. If negative, the debug attribute is not written; if positive,
1179 * it corresponds to the length of the data to write. In that case, the rest
1180 * of the block must contain the data. */
Paul Cercueil99b07cc2014-04-14 16:07:32 +02001181__api ssize_t iio_device_debug_attr_write(const struct iio_device *dev,
1182 const char *attr, const char *src);
1183
Paul Cercueile3960742014-04-15 16:00:50 +02001184
Paul Cercueilcecda352014-05-06 18:14:29 +02001185/** @brief Set the value of the given debug attribute
1186 * @param dev A pointer to an iio_device structure
1187 * @param attr A NULL-terminated string corresponding to the name of the
1188 * debug attribute
1189 * @param src A pointer to the data to be written
1190 * @param len The number of bytes that should be written
1191 * @return On success, the number of bytes written
1192 * @return On error, a negative errno code is returned */
1193__api ssize_t iio_device_debug_attr_write_raw(const struct iio_device *dev,
1194 const char *attr, const void *src, size_t len);
1195
1196
Paul Cercueil1b36a012014-06-05 14:39:31 +02001197/** @brief Set the values of all debug attributes
1198 * @param dev A pointer to an iio_device structure
1199 * @param cb A pointer to a callback function
1200 * @param data A pointer that will be passed to the callback function
1201 * @return On success, 0 is returned
1202 * @return On error, a negative errno code is returned
1203 *
1204 * <b>NOTE:</b> This function is especially useful when used with the network
1205 * backend, as all the debug attributes are written in one single command. */
1206__api int iio_device_debug_attr_write_all(struct iio_device *dev,
1207 ssize_t (*cb)(struct iio_device *dev,
1208 const char *attr, void *buf, size_t len, void *d),
1209 void *data);
1210
1211
Paul Cercueile3960742014-04-15 16:00:50 +02001212/** @brief Read the content of the given debug attribute
1213 * @param dev A pointer to an iio_device structure
1214 * @param attr A NULL-terminated string corresponding to the name of the
1215 * debug attribute
1216 * @param val A pointer to a bool variable where the value should be stored
1217 * @return On success, 0 is returned
1218 * @return On error, a negative errno code is returned */
1219__api int iio_device_debug_attr_read_bool(const struct iio_device *dev,
1220 const char *attr, bool *val);
1221
1222
1223/** @brief Read the content of the given debug attribute
1224 * @param dev A pointer to an iio_device structure
1225 * @param attr A NULL-terminated string corresponding to the name of the
1226 * debug attribute
1227 * @param val A pointer to a long long variable where the value should be stored
1228 * @return On success, 0 is returned
1229 * @return On error, a negative errno code is returned */
1230__api int iio_device_debug_attr_read_longlong(const struct iio_device *dev,
1231 const char *attr, long long *val);
1232
1233
1234/** @brief Read the content of the given debug attribute
1235 * @param dev A pointer to an iio_device structure
1236 * @param attr A NULL-terminated string corresponding to the name of the
1237 * debug attribute
1238 * @param val A pointer to a double variable where the value should be stored
1239 * @return On success, 0 is returned
1240 * @return On error, a negative errno code is returned */
1241__api int iio_device_debug_attr_read_double(const struct iio_device *dev,
1242 const char *attr, double *val);
1243
1244
1245/** @brief Set the value of the given debug attribute
1246 * @param dev A pointer to an iio_device structure
1247 * @param attr A NULL-terminated string corresponding to the name of the
1248 * debug attribute
1249 * @param val A bool value to set the debug attribute to
1250 * @return On success, 0 is returned
1251 * @return On error, a negative errno code is returned */
1252__api int iio_device_debug_attr_write_bool(const struct iio_device *dev,
1253 const char *attr, bool val);
1254
1255
1256/** @brief Set the value of the given debug attribute
1257 * @param dev A pointer to an iio_device structure
1258 * @param attr A NULL-terminated string corresponding to the name of the
1259 * debug attribute
1260 * @param val A long long value to set the debug attribute to
1261 * @return On success, 0 is returned
1262 * @return On error, a negative errno code is returned */
1263__api int iio_device_debug_attr_write_longlong(const struct iio_device *dev,
1264 const char *attr, long long val);
1265
1266
1267/** @brief Set the value of the given debug attribute
1268 * @param dev A pointer to an iio_device structure
1269 * @param attr A NULL-terminated string corresponding to the name of the
1270 * debug attribute
1271 * @param val A double value to set the debug attribute to
1272 * @return On success, 0 is returned
1273 * @return On error, a negative errno code is returned */
1274__api int iio_device_debug_attr_write_double(const struct iio_device *dev,
1275 const char *attr, double val);
1276
Paul Cercueil108e0aa2014-05-06 14:45:14 +02001277
1278/** @brief Identify the channel or debug attribute corresponding to a filename
1279 * @param dev A pointer to an iio_device structure
1280 * @param filename A NULL-terminated string corresponding to the filename
1281 * @param chn A pointer to a pointer of an iio_channel structure. The pointed
1282 * pointer will be set to the address of the iio_channel structure if the
1283 * filename correspond to the attribute of a channel, or NULL otherwise.
1284 * @param attr A pointer to a NULL-terminated string. The pointer
1285 * pointer will be set to point to the name of the attribute corresponding to
1286 * the filename.
1287 * @return On success, 0 is returned, and *chn and *attr are modified.
1288 * @return On error, a negative errno code is returned. *chn and *attr are not
1289 * modified. */
1290__api int iio_device_identify_filename(const struct iio_device *dev,
1291 const char *filename, struct iio_channel **chn,
1292 const char **attr);
1293
1294
Paul Cercueil14405872014-05-07 14:00:32 +02001295/** @brief Set the value of a hardware register
1296 * @param dev A pointer to an iio_device structure
1297 * @param address The address of the register
1298 * @param value The value to set the register to
1299 * @return On success, 0 is returned
1300 * @return On error, a negative errno code is returned */
1301__api int iio_device_reg_write(struct iio_device *dev,
1302 uint32_t address, uint32_t value);
1303
1304
1305/** @brief Get the value of a hardware register
1306 * @param dev A pointer to an iio_device structure
1307 * @param address The address of the register
1308 * @param value A pointer to the variable where the value will be written
1309 * @return On success, 0 is returned
1310 * @return On error, a negative errno code is returned */
1311__api int iio_device_reg_read(struct iio_device *dev,
1312 uint32_t address, uint32_t *value);
1313
1314
Paul Cercueil306cb1c2014-04-11 14:46:45 +02001315/** @} */
1316
Paul Cercueila167e0c2014-04-08 14:50:41 +02001317#ifdef __cplusplus
1318}
1319#endif
1320
Paul Cercueil0b2ce712014-02-17 15:04:18 +01001321#endif /* __IIO_H__ */