Commit | Line | Data |
---|---|---|
bdcb31d0 RD |
1 | #ifndef _IIO_UTILS_H_ |
2 | #define _IIO_UTILS_H_ | |
3 | ||
c57f1ba7 JC |
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 | ||
e58537cc | 13 | #include <stdint.h> |
9d8ae6c8 | 14 | |
b42f2a0c | 15 | /* Made up value to limit allocation sizes */ |
9d8ae6c8 JC |
16 | #define IIO_MAX_NAME_LENGTH 30 |
17 | ||
1aa04278 | 18 | #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements" |
e58537cc | 19 | #define FORMAT_TYPE_FILE "%s_type" |
c57f1ba7 | 20 | |
bdcb31d0 | 21 | extern const char *iio_dir; |
e58537cc JC |
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 | * @mask: a bit mask for the raw output | |
32 | * @is_signed: is the raw value stored signed | |
33 | * @enabled: is this channel enabled | |
34 | **/ | |
35 | struct iio_channel_info { | |
36 | char *name; | |
37 | char *generic_name; | |
38 | float scale; | |
39 | float offset; | |
40 | unsigned index; | |
41 | unsigned bytes; | |
42 | unsigned bits_used; | |
52615d47 | 43 | unsigned shift; |
e58537cc | 44 | uint64_t mask; |
117cf8b7 | 45 | unsigned be; |
e58537cc | 46 | unsigned is_signed; |
e58537cc JC |
47 | unsigned location; |
48 | }; | |
49 | ||
bdcb31d0 RD |
50 | int iioutils_break_up_name(const char *full_name, char **generic_name); |
51 | int iioutils_get_type(unsigned *is_signed, unsigned *bytes, | |
52 | unsigned *bits_used, unsigned *shift, | |
53 | uint64_t *mask, unsigned *be, | |
54 | const char *device_dir, const char *name, | |
55 | const char *generic_name); | |
56 | int iioutils_get_param_float(float *output, const char *param_name, | |
57 | const char *device_dir, const char *name, | |
58 | const char *generic_name); | |
59 | void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt); | |
60 | int build_channel_array(const char *device_dir, | |
61 | struct iio_channel_info **ci_array, int *counter); | |
62 | int find_type_by_name(const char *name, const char *type); | |
63 | int write_sysfs_int(char *filename, char *basedir, int val); | |
64 | int write_sysfs_int_and_verify(char *filename, char *basedir, int val); | |
65 | int write_sysfs_string_and_verify(char *filename, char *basedir, char *val); | |
66 | int write_sysfs_string(char *filename, char *basedir, char *val); | |
67 | int read_sysfs_posint(char *filename, char *basedir); | |
68 | int read_sysfs_float(char *filename, char *basedir, float *val); | |
69 | int read_sysfs_string(const char *filename, const char *basedir, char *str); | |
70 | ||
71 | #endif /* _IIO_UTILS_H_ */ |