mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
iio_kernel_headers.h
1 /*
2  * Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 //For kernel 4.1+,
26 //#include <linux/iio/types.h>
27 //#include <linux/iio/events.h>
28 
29 //linux/iio/types.h
30 enum iio_chan_type {
31  IIO_VOLTAGE,
32  IIO_CURRENT,
33  IIO_POWER,
34  IIO_ACCEL,
35  IIO_ANGL_VEL,
36  IIO_MAGN,
37  IIO_LIGHT,
38  IIO_INTENSITY,
39  IIO_PROXIMITY,
40  IIO_TEMP,
41  IIO_INCLI,
42  IIO_ROT,
43  IIO_ANGL,
44  IIO_TIMESTAMP,
45  IIO_CAPACITANCE,
46  IIO_ALTVOLTAGE,
47  IIO_CCT,
48  IIO_PRESSURE,
49  IIO_HUMIDITYRELATIVE,
50  IIO_ACTIVITY,
51  IIO_STEPS,
52  IIO_ENERGY,
53  IIO_DISTANCE,
54  IIO_VELOCITY,
55 };
56 
57 enum iio_modifier {
58  IIO_NO_MOD,
59  IIO_MOD_X,
60  IIO_MOD_Y,
61  IIO_MOD_Z,
62  IIO_MOD_X_AND_Y,
63  IIO_MOD_X_AND_Z,
64  IIO_MOD_Y_AND_Z,
65  IIO_MOD_X_AND_Y_AND_Z,
66  IIO_MOD_X_OR_Y,
67  IIO_MOD_X_OR_Z,
68  IIO_MOD_Y_OR_Z,
69  IIO_MOD_X_OR_Y_OR_Z,
70  IIO_MOD_LIGHT_BOTH,
71  IIO_MOD_LIGHT_IR,
72  IIO_MOD_ROOT_SUM_SQUARED_X_Y,
73  IIO_MOD_SUM_SQUARED_X_Y_Z,
74  IIO_MOD_LIGHT_CLEAR,
75  IIO_MOD_LIGHT_RED,
76  IIO_MOD_LIGHT_GREEN,
77  IIO_MOD_LIGHT_BLUE,
78  IIO_MOD_QUATERNION,
79  IIO_MOD_TEMP_AMBIENT,
80  IIO_MOD_TEMP_OBJECT,
81  IIO_MOD_NORTH_MAGN,
82  IIO_MOD_NORTH_TRUE,
83  IIO_MOD_NORTH_MAGN_TILT_COMP,
84  IIO_MOD_NORTH_TRUE_TILT_COMP,
85  IIO_MOD_RUNNING,
86  IIO_MOD_JOGGING,
87  IIO_MOD_WALKING,
88  IIO_MOD_STILL,
89  IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
90 };
91 
92 enum iio_event_type {
93  IIO_EV_TYPE_THRESH,
94  IIO_EV_TYPE_MAG,
95  IIO_EV_TYPE_ROC,
96  IIO_EV_TYPE_THRESH_ADAPTIVE,
97  IIO_EV_TYPE_MAG_ADAPTIVE,
98  IIO_EV_TYPE_CHANGE,
99 };
100 
101 enum iio_event_direction {
102  IIO_EV_DIR_EITHER,
103  IIO_EV_DIR_RISING,
104  IIO_EV_DIR_FALLING,
105  IIO_EV_DIR_NONE,
106 };
107 
108 //linux/iio/events.h
109 #if defined(MSYS)
110 #define __USE_LINUX_IOCTL_DEFS
111 #include <sys/ioctl.h>
112 #else
113 #include <linux/ioctl.h>
114 #endif
115 
121  unsigned long long int id;
123  long long int timestamp;
124 };
125 
126 #define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
127 
128 #define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
129 
130 #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F)
131 
132 #define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
133 
134 /* Event code number extraction depends on which type of event we have.
135  * Perhaps review this function in the future*/
136 #define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((short int)(mask & 0xFFFF))
137 #define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((short int)(((mask) >> 16) & 0xFFFF))
138 
139 #define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
140 #define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1)
long long int timestamp
Definition: iio_kernel_headers.h:123
Definition: iio_kernel_headers.h:119
unsigned long long int id
Definition: iio_kernel_headers.h:121