tools:iio:iio_utils: initialize count during declaration
[deliverable/linux.git] / tools / iio / iio_utils.h
1 #ifndef _IIO_UTILS_H_
2 #define _IIO_UTILS_H_
3
4 /* IIO - useful set of util functionality
5 *
6 * Copyright (c) 2008 Jonathan Cameron
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published by
10 * the Free Software Foundation.
11 */
12
13 #include <stdint.h>
14
15 /* Made up value to limit allocation sizes */
16 #define IIO_MAX_NAME_LENGTH 30
17
18 #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
19 #define FORMAT_TYPE_FILE "%s_type"
20
21 extern const char *iio_dir;
22
23 /**
24 * struct iio_channel_info - information about a given channel
25 * @name: channel name
26 * @generic_name: general name for channel type
27 * @scale: scale factor to be applied for conversion to si units
28 * @offset: offset to be applied for conversion to si units
29 * @index: the channel index in the buffer output
30 * @bytes: number of bytes occupied in buffer output
31 * @bits_used: number of valid bits of data
32 * @shift: amount of bits to shift right data before applying bit mask
33 * @mask: a bit mask for the raw output
34 * @be: flag if data is big endian
35 * @is_signed: is the raw value stored signed
36 * @location: data offset for this channel inside the buffer (in bytes)
37 **/
38 struct iio_channel_info {
39 char *name;
40 char *generic_name;
41 float scale;
42 float offset;
43 unsigned index;
44 unsigned bytes;
45 unsigned bits_used;
46 unsigned shift;
47 uint64_t mask;
48 unsigned be;
49 unsigned is_signed;
50 unsigned location;
51 };
52
53 int iioutils_break_up_name(const char *full_name, char **generic_name);
54 int iioutils_get_type(unsigned *is_signed, unsigned *bytes,
55 unsigned *bits_used, unsigned *shift,
56 uint64_t *mask, unsigned *be,
57 const char *device_dir, const char *name,
58 const char *generic_name);
59 int iioutils_get_param_float(float *output, const char *param_name,
60 const char *device_dir, const char *name,
61 const char *generic_name);
62 void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt);
63 int build_channel_array(const char *device_dir,
64 struct iio_channel_info **ci_array, int *counter);
65 int find_type_by_name(const char *name, const char *type);
66 int write_sysfs_int(char *filename, char *basedir, int val);
67 int write_sysfs_int_and_verify(char *filename, char *basedir, int val);
68 int write_sysfs_string_and_verify(char *filename, char *basedir, char *val);
69 int write_sysfs_string(char *filename, char *basedir, char *val);
70 int read_sysfs_posint(char *filename, char *basedir);
71 int read_sysfs_float(char *filename, char *basedir, float *val);
72 int read_sysfs_string(const char *filename, const char *basedir, char *str);
73
74 #endif /* _IIO_UTILS_H_ */
This page took 0.034104 seconds and 5 git commands to generate.