This source file includes following definitions.
- iioutils_check_suffix
1
2 #ifndef _IIO_UTILS_H_
3 #define _IIO_UTILS_H_
4
5
6
7
8
9
10 #include <stdint.h>
11
12
13 #define IIO_MAX_NAME_LENGTH 64
14
15 #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
16 #define FORMAT_TYPE_FILE "%s_type"
17
18 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
19
20 extern const char *iio_dir;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 struct iio_channel_info {
38 char *name;
39 char *generic_name;
40 float scale;
41 float offset;
42 unsigned index;
43 unsigned bytes;
44 unsigned bits_used;
45 unsigned shift;
46 uint64_t mask;
47 unsigned be;
48 unsigned is_signed;
49 unsigned location;
50 };
51
52 static inline int iioutils_check_suffix(const char *str, const char *suffix)
53 {
54 return strlen(str) >= strlen(suffix) &&
55 strncmp(str+strlen(str)-strlen(suffix),
56 suffix, strlen(suffix)) == 0;
57 }
58
59 int iioutils_break_up_name(const char *full_name, char **generic_name);
60 int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
61 unsigned *shift, uint64_t *mask, unsigned *be,
62 const char *device_dir, const char *name,
63 const char *generic_name);
64 int iioutils_get_param_float(float *output, const char *param_name,
65 const char *device_dir, const char *name,
66 const char *generic_name);
67 void bsort_channel_array_by_index(struct iio_channel_info *ci_array, int cnt);
68 int build_channel_array(const char *device_dir,
69 struct iio_channel_info **ci_array, int *counter);
70 int find_type_by_name(const char *name, const char *type);
71 int write_sysfs_int(const char *filename, const char *basedir, int val);
72 int write_sysfs_int_and_verify(const char *filename, const char *basedir,
73 int val);
74 int write_sysfs_string_and_verify(const char *filename, const char *basedir,
75 const char *val);
76 int write_sysfs_string(const char *filename, const char *basedir,
77 const char *val);
78 int read_sysfs_posint(const char *filename, const char *basedir);
79 int read_sysfs_float(const char *filename, const char *basedir, float *val);
80 int read_sysfs_string(const char *filename, const char *basedir, char *str);
81
82 #endif