1 /* 2 * Copyright (C) 2012 Invensense, Inc. 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 #ifndef ARRAY_SIZE 35 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 36 #endif 37 38 enum { 39 ID_GY = 0, 40 ID_RG, 41 ID_A, 42 ID_M, 43 ID_RM, 44 ID_PS, 45 ID_O, 46 ID_RV, 47 ID_GRV, 48 ID_LA, 49 ID_GR, 50 ID_SM, 51 ID_P, 52 ID_SC, 53 ID_GMRV, 54 ID_SO 55 }; 56 57 /*****************************************************************************/ 58 59 /* 60 * The SENSORS Module 61 */ 62 63 /* ITG3500 */ 64 #define EVENT_TYPE_GYRO_X REL_X 65 #define EVENT_TYPE_GYRO_Y REL_Y 66 #define EVENT_TYPE_GYRO_Z REL_Z 67 /* MPU6050 MPU9150 */ 68 #define EVENT_TYPE_IACCEL_X REL_RX 69 #define EVENT_TYPE_IACCEL_Y REL_RY 70 #define EVENT_TYPE_IACCEL_Z REL_RZ 71 /* MPU6050 MPU9150 */ 72 #define EVENT_TYPE_ICOMPASS_X REL_X 73 #define EVENT_TYPE_ICOMPASS_Y REL_Y 74 #define EVENT_TYPE_ICOMPASS_Z REL_Z 75 /* MPUxxxx */ 76 #define EVENT_TYPE_TIMESTAMP_HI REL_MISC 77 #define EVENT_TYPE_TIMESTAMP_LO REL_WHEEL 78 79 /* Accel BMA250 */ 80 #define EVENT_TYPE_ACCEL_X ABS_X 81 #define EVENT_TYPE_ACCEL_Y ABS_Y 82 #define EVENT_TYPE_ACCEL_Z ABS_Z 83 #define LSG (1000.0f) 84 85 // conversion of acceleration data to SI units (m/s^2) 86 #define RANGE_A (4*GRAVITY_EARTH) 87 #define RESOLUTION_A (GRAVITY_EARTH / LSG) 88 #define CONVERT_A (GRAVITY_EARTH / LSG) 89 #define CONVERT_A_X (CONVERT_A) 90 #define CONVERT_A_Y (CONVERT_A) 91 #define CONVERT_A_Z (CONVERT_A) 92 93 /* AKM compasses */ 94 #define EVENT_TYPE_MAGV_X ABS_RX 95 #define EVENT_TYPE_MAGV_Y ABS_RY 96 #define EVENT_TYPE_MAGV_Z ABS_RZ 97 #define EVENT_TYPE_MAGV_STATUS ABS_RUDDER 98 99 // conversion of magnetic data to uT units 100 #define CONVERT_M (0.06f) 101 102 __END_DECLS 103 104 #endif // ANDROID_SENSORS_H 105