• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_SENSORS_H
18 #define ANDROID_SENSORS_H
19 
20 #include <stdint.h>
21 #include <errno.h>
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
24 
25 #include <linux/input.h>
26 
27 #include <hardware/hardware.h>
28 #include <hardware/sensors.h>
29 
30 __BEGIN_DECLS
31 
32 /*****************************************************************************/
33 
34 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
35 
36 #define ID_A  (0)
37 #define ID_M  (1)
38 #define ID_O  (2)
39 #define ID_L  (3)
40 #define ID_P  (4)
41 #define ID_GY (5)
42 
43 /*****************************************************************************/
44 
45 /*
46  * The SENSORS Module
47  */
48 
49 /* the GP2A is a binary proximity sensor that triggers around 5 cm on
50  * this hardware */
51 #define PROXIMITY_THRESHOLD_GP2A  5.0f
52 
53 /*****************************************************************************/
54 
55 #define AKM_DEVICE_NAME     "/dev/akm8973_aot"
56 
57 #define EVENT_TYPE_ACCEL_X          REL_Y
58 #define EVENT_TYPE_ACCEL_Y          REL_X
59 #define EVENT_TYPE_ACCEL_Z          REL_Z
60 
61 #define EVENT_TYPE_YAW              REL_RX
62 #define EVENT_TYPE_PITCH            REL_RY
63 #define EVENT_TYPE_ROLL             REL_RZ
64 #define EVENT_TYPE_ORIENT_STATUS    REL_WHEEL
65 
66 /* For AK8973iB */
67 #define EVENT_TYPE_MAGV_X           REL_DIAL
68 #define EVENT_TYPE_MAGV_Y           REL_HWHEEL
69 #define EVENT_TYPE_MAGV_Z           REL_MISC
70 
71 #define EVENT_TYPE_PROXIMITY        ABS_DISTANCE
72 #define EVENT_TYPE_LIGHT            ABS_MISC
73 
74 #define EVENT_TYPE_GYRO_X           REL_RY
75 #define EVENT_TYPE_GYRO_Y           REL_RX
76 #define EVENT_TYPE_GYRO_Z           REL_RZ
77 
78 
79 // 64 LSB = 1G for KR3DM
80 #define LSB                         (64.0f)
81 #define NUMOFACCDATA                (8.0f)
82 
83 // conversion of acceleration data to SI units (m/s^2)
84 #define RANGE_A                     (2*GRAVITY_EARTH)
85 #define CONVERT_A                   (GRAVITY_EARTH / LSB / NUMOFACCDATA)
86 #define CONVERT_A_X                 (CONVERT_A)
87 #define CONVERT_A_Y                 (CONVERT_A)
88 #define CONVERT_A_Z                 (CONVERT_A)
89 
90 // conversion of magnetic data to uT units
91 #define CONVERT_M                   (1.0f/16.0f)
92 #define CONVERT_M_X                 (-CONVERT_M)
93 #define CONVERT_M_Y                 (-CONVERT_M)
94 #define CONVERT_M_Z                 (-CONVERT_M)
95 
96 /* conversion of orientation data to degree units */
97 #define CONVERT_O                   (1.0f/64.0f)
98 #define CONVERT_O_A                 (CONVERT_O)
99 #define CONVERT_O_P                 (CONVERT_O)
100 #define CONVERT_O_R                 (-CONVERT_O)
101 
102 // conversion of gyro data to SI units (radian/sec)
103 #define RANGE_GYRO                  (2000.0f*(float)M_PI/180.0f)
104 #define CONVERT_GYRO                ((70.0f / 1000.0f) * ((float)M_PI / 180.0f))
105 #define CONVERT_GYRO_X              (CONVERT_GYRO)
106 #define CONVERT_GYRO_Y              (-CONVERT_GYRO)
107 #define CONVERT_GYRO_Z              (CONVERT_GYRO)
108 
109 #define SENSOR_STATE_MASK           (0x7FFF)
110 
111 /*****************************************************************************/
112 
113 __END_DECLS
114 
115 #endif  // ANDROID_SENSORS_H
116