1 /* 2 * Copyright (C) 2014 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 #undef ENABLE_PRESSURE 39 40 enum { 41 ID_GY = 0, 42 ID_RG, 43 ID_A, 44 ID_M, 45 ID_RM, 46 #ifdef ENABLE_PRESSURE 47 ID_PS, 48 #endif 49 ID_O, 50 ID_RV, 51 ID_GRV, 52 ID_LA, 53 ID_GR, 54 ID_SM, 55 ID_P, 56 ID_SC, 57 ID_GMRV, 58 ID_SO 59 }; 60 61 enum { 62 Gyro = 0, 63 RawGyro, 64 Accelerometer, 65 MagneticField, 66 RawMagneticField, 67 #ifdef ENABLE_PRESSURE 68 Pressure, 69 #endif 70 Orientation, 71 RotationVector, 72 GameRotationVector, 73 LinearAccel, 74 Gravity, 75 SignificantMotion, 76 StepDetector, 77 StepCounter, 78 GeomagneticRotationVector, 79 NumSensors 80 }; 81 82 #ifdef ENABLE_PRESSURE 83 #define LAST_HW_SENSOR Pressure 84 #else 85 #define LAST_HW_SENSOR RawMagneticField 86 #endif 87 88 /* Physical parameters of the sensors supported by Invensense MPL */ 89 #define SENSORS_GYROSCOPE_HANDLE (ID_GY) 90 #define SENSORS_RAW_GYROSCOPE_HANDLE (ID_RG) 91 #define SENSORS_ACCELERATION_HANDLE (ID_A) 92 #define SENSORS_MAGNETIC_FIELD_HANDLE (ID_M) 93 #define SENSORS_RAW_MAGNETIC_FIELD_HANDLE (ID_RM) 94 #define SENSORS_PRESSURE_HANDLE (ID_PS) 95 #define SENSORS_ORIENTATION_HANDLE (ID_O) 96 #define SENSORS_ROTATION_VECTOR_HANDLE (ID_RV) 97 #define SENSORS_GAME_ROTATION_VECTOR_HANDLE (ID_GRV) 98 #define SENSORS_LINEAR_ACCEL_HANDLE (ID_LA) 99 #define SENSORS_GRAVITY_HANDLE (ID_GR) 100 #define SENSORS_SIGNIFICANT_MOTION_HANDLE (ID_SM) 101 #define SENSORS_PEDOMETER_HANDLE (ID_P) 102 #define SENSORS_STEP_COUNTER_HANDLE (ID_SC) 103 #define SENSORS_GEOMAGNETIC_ROTATION_VECTOR_HANDLE (ID_GMRV) 104 #define SENSORS_SCREEN_ORIENTATION_HANDLE (ID_SO) 105 106 /*****************************************************************************/ 107 108 /* 109 Android Lollipop 110 Populate sensor_t structure according to hardware sensors.h 111 {name, vendor, version, handle, 112 type, maxRange, resolution, power, minDelay, fifoReservedEventCount, fifoMaxEventCount, 113 stringType, requiredPermission, maxDelay, flags, reserved[]} 114 */ 115 #if defined ANDROID_LOLLIPOP 116 117 static struct sensor_t sBaseSensorList[] = 118 { 119 {"MPL Gyroscope", "Invensense", 1, SENSORS_GYROSCOPE_HANDLE, 120 SENSOR_TYPE_GYROSCOPE, 2000.0f, 1.0f, 0.5f, 10000, 0, 124, 121 SENSOR_STRING_TYPE_GYROSCOPE, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 122 {"MPL Raw Gyroscope", "Invensense", 1, SENSORS_RAW_GYROSCOPE_HANDLE, 123 SENSOR_TYPE_GYROSCOPE_UNCALIBRATED, 2000.0f, 1.0f, 0.5f, 10000, 0, 124, 124 SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 125 {"MPL Accelerometer", "Invensense", 1, SENSORS_ACCELERATION_HANDLE, 126 SENSOR_TYPE_ACCELEROMETER, 10240.0f, 1.0f, 0.5f, 10000, 0, 124, 127 SENSOR_STRING_TYPE_ACCELEROMETER, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 128 {"MPL Magnetic Field", "Invensense", 1, SENSORS_MAGNETIC_FIELD_HANDLE, 129 SENSOR_TYPE_MAGNETIC_FIELD, 10240.0f, 1.0f, 0.5f, 10000, 0, 124, 130 SENSOR_STRING_TYPE_MAGNETIC_FIELD, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 131 {"MPL Raw Magnetic Field", "Invensense", 1, SENSORS_RAW_MAGNETIC_FIELD_HANDLE, 132 SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED, 10240.0f, 1.0f, 0.5f, 10000, 0, 124, 133 SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 134 #ifdef ENABLE_PRESSURE 135 {"MPL Pressure", "Invensense", 1, SENSORS_PRESSURE_HANDLE, 136 SENSOR_TYPE_PRESSURE, 10240.0f, 1.0f, 0.5f, 10000, 0, 165, 137 SENSOR_STRING_TYPE_PRESSURE, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 138 #endif 139 {"MPL Orientation", "Invensense", 1, SENSORS_ORIENTATION_HANDLE, 140 SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 9.7f, 10000, 0, 0, 141 SENSOR_STRING_TYPE_ORIENTATION, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 142 {"MPL Rotation Vector", "Invensense", 1, SENSORS_ROTATION_VECTOR_HANDLE, 143 SENSOR_TYPE_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, 0, 0, 144 SENSOR_STRING_TYPE_ROTATION_VECTOR, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 145 {"MPL Game Rotation Vector", "Invensense", 1, SENSORS_GAME_ROTATION_VECTOR_HANDLE, 146 SENSOR_TYPE_GAME_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, 0, 62, 147 SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 148 {"MPL Linear Acceleration", "Invensense", 1, SENSORS_LINEAR_ACCEL_HANDLE, 149 SENSOR_TYPE_LINEAR_ACCELERATION, 10240.0f, 1.0f, 0.5f, 10000, 0, 0, 150 SENSOR_STRING_TYPE_LINEAR_ACCELERATION, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 151 {"MPL Gravity", "Invensense", 1, SENSORS_GRAVITY_HANDLE, 152 SENSOR_TYPE_GRAVITY, 10240.0f, 1.0f, 0.5f, 10000, 0, 0, 153 SENSOR_STRING_TYPE_GRAVITY, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 154 {"MPL Significant Motion", "Invensense", 1, SENSORS_SIGNIFICANT_MOTION_HANDLE, 155 SENSOR_TYPE_SIGNIFICANT_MOTION, 100.0f, 1.0f, 1.1f, 0, 0, 0, 156 SENSOR_STRING_TYPE_SIGNIFICANT_MOTION, "", 0, 157 SENSOR_FLAG_ONE_SHOT_MODE | SENSOR_FLAG_WAKE_UP, {}}, 158 {"MPL Step Detector", "Invensense", 1, SENSORS_PEDOMETER_HANDLE, 159 SENSOR_TYPE_STEP_DETECTOR, 100.0f, 1.0f, 1.1f, 0, 0, 124, 160 SENSOR_STRING_TYPE_STEP_DETECTOR, "", 0, SENSOR_FLAG_SPECIAL_REPORTING_MODE, {}}, 161 {"MPL Step Counter", "Invensense", 1, SENSORS_STEP_COUNTER_HANDLE, 162 SENSOR_TYPE_STEP_COUNTER, 100.0f, 1.0f, 1.1f, 0, 0, 0, 163 SENSOR_STRING_TYPE_STEP_COUNTER, "", 0, SENSOR_FLAG_ON_CHANGE_MODE, {}}, 164 {"MPL Geomagnetic Rotation Vector", "Invensense", 1, 165 SENSORS_GEOMAGNETIC_ROTATION_VECTOR_HANDLE, 166 SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 5000, 0, 0, 167 SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 168 #ifdef ENABLE_DMP_SCREEN_AUTO_ROTATION 169 {"MPL Screen Orientation", "Invensense ", 1, SENSORS_SCREEN_ORIENTATION_HANDLE, 170 SENSOR_TYPE_SCREEN_ORIENTATION, 100.0f, 1.0f, 1.1f, 0, 0, 0, 171 SENSOR_STRING_TYPE_SCREEN_ORIENTATION, "", 0, SENSOR_FLAG_ON_CHANGE_MODE, {}}, 172 #endif 173 }; 174 /* 175 Android KitKat 176 Populate sensor_t structure according to hardware sensors.h 177 {name, vendor, version, 178 handle, 179 type, maxRange, resolution, power, minDelay, fifoReservedEventCount, fifoMaxEventCount, reserved[]} 180 */ 181 #elif defined ANDROID_KITKAT 182 static struct sensor_t sBaseSensorList[] = 183 { 184 {"MPL Gyroscope", "Invensense", 1, SENSORS_GYROSCOPE_HANDLE, 185 SENSOR_TYPE_GYROSCOPE, 2000.0f, 1.0f, 0.5f, 10000, 0, 124, 186 SENSOR_STRING_TYPE_GYROSCOPE, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 187 {"MPL Raw Gyroscope", "Invensense", 1, SENSORS_RAW_GYROSCOPE_HANDLE, 188 SENSOR_TYPE_GYROSCOPE_UNCALIBRATED, 2000.0f, 1.0f, 0.5f, 10000, 0, 124, 189 SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 190 {"MPL Accelerometer", "Invensense", 1, SENSORS_ACCELERATION_HANDLE, 191 SENSOR_TYPE_ACCELEROMETER, 10240.0f, 1.0f, 0.5f, 10000, 0, 124, 192 SENSOR_STRING_TYPE_ACCELEROMETER, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 193 {"MPL Magnetic Field", "Invensense", 1, SENSORS_MAGNETIC_FIELD_HANDLE, 194 SENSOR_TYPE_MAGNETIC_FIELD, 10240.0f, 1.0f, 0.5f, 10000, 0, 124, 195 SENSOR_STRING_TYPE_MAGNETIC_FIELD, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 196 {"MPL Raw Magnetic Field", "Invensense", 1, SENSORS_RAW_MAGNETIC_FIELD_HANDLE, 197 SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED, 10240.0f, 1.0f, 0.5f, 10000, 0, 124, 198 SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 199 #ifdef ENABLE_PRESSURE 200 {"MPL Pressure", "Invensense", 1, SENSORS_PRESSURE_HANDLE, 201 SENSOR_TYPE_PRESSURE, 10240.0f, 1.0f, 0.5f, 10000, 0, 165, 202 SENSOR_STRING_TYPE_PRESSURE, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 203 #endif 204 {"MPL Orientation", "Invensense", 1, SENSORS_ORIENTATION_HANDLE, 205 SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 9.7f, 10000, 0, 0, 206 SENSOR_STRING_TYPE_ORIENTATION, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 207 {"MPL Rotation Vector", "Invensense", 1, SENSORS_ROTATION_VECTOR_HANDLE, 208 SENSOR_TYPE_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, 0, 0, 209 SENSOR_STRING_TYPE_ROTATION_VECTOR, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 210 {"MPL Game Rotation Vector", "Invensense", 1, SENSORS_GAME_ROTATION_VECTOR_HANDLE, 211 SENSOR_TYPE_GAME_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, 0, 62, 212 SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 213 {"MPL Linear Acceleration", "Invensense", 1, SENSORS_LINEAR_ACCEL_HANDLE, 214 SENSOR_TYPE_LINEAR_ACCELERATION, 10240.0f, 1.0f, 0.5f, 10000, 0, 0, 215 SENSOR_STRING_TYPE_LINEAR_ACCELERATION, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 216 {"MPL Gravity", "Invensense", 1, SENSORS_GRAVITY_HANDLE, 217 SENSOR_TYPE_GRAVITY, 10240.0f, 1.0f, 0.5f, 10000, 0, 0, 218 SENSOR_STRING_TYPE_GRAVITY, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 219 {"MPL Significant Motion", "Invensense", 1, SENSORS_SIGNIFICANT_MOTION_HANDLE, 220 SENSOR_TYPE_SIGNIFICANT_MOTION, 100.0f, 1.0f, 1.1f, 0, 0, 0, 221 SENSOR_STRING_TYPE_SIGNIFICANT_MOTION, 0, 0, 222 SENSOR_FLAG_ONE_SHOT_MODE | SENSOR_FLAG_WAKE_UP, {}}, 223 {"MPL Step Detector", "Invensense", 1, SENSORS_PEDOMETER_HANDLE, 224 SENSOR_TYPE_STEP_DETECTOR, 100.0f, 1.0f, 1.1f, 0, 0, 124, 225 SENSOR_STRING_TYPE_STEP_DETECTOR, 0, 0, SENSOR_FLAG_SPECIAL_REPORTING_MODE, {}}, 226 {"MPL Step Counter", "Invensense", 1, SENSORS_STEP_COUNTER_HANDLE, 227 SENSOR_TYPE_STEP_COUNTER, 100.0f, 1.0f, 1.1f, 0, 0, 0, 228 SENSOR_STRING_TYPE_STEP_COUNTER, 0, 0, SENSOR_FLAG_ON_CHANGE_MODE, {}}, 229 {"MPL Geomagnetic Rotation Vector", "Invensense", 1, 230 SENSORS_GEOMAGNETIC_ROTATION_VECTOR_HANDLE, 231 SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 5000, 0, 0, 232 SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, {}}, 233 #ifdef ENABLE_DMP_SCREEN_AUTO_ROTATION 234 {"MPL Screen Orientation", "Invensense ", 1, SENSORS_SCREEN_ORIENTATION_HANDLE, 235 SENSOR_TYPE_SCREEN_ORIENTATION, 100.0f, 1.0f, 1.1f, 0, 0, 0, 236 SENSOR_STRING_TYPE_SCREEN_ORIENTATION, 0, 0, SENSOR_FLAG_ON_CHANGE_MODE, {}}, 237 #endif 238 }; 239 #else //ANDROID_KITKAT END 240 static struct sensor_t sBaseSensorList[] = 241 { 242 {"MPL Gyroscope", "Invensense", 1, 243 SENSORS_GYROSCOPE_HANDLE, 244 SENSOR_TYPE_GYROSCOPE, 2000.0f, 1.0f, 0.5f, 10000, {}}, 245 {"MPL Raw Gyroscope", "Invensense", 1, 246 SENSORS_RAW_GYROSCOPE_HANDLE, 247 SENSOR_TYPE_GYROSCOPE_UNCALIBRATED, 2000.0f, 1.0f, 0.5f, 10000, {}}, 248 {"MPL Accelerometer", "Invensense", 1, 249 SENSORS_ACCELERATION_HANDLE, 250 SENSOR_TYPE_ACCELEROMETER, 10240.0f, 1.0f, 0.5f, 10000, {}}, 251 {"MPL Magnetic Field", "Invensense", 1, 252 SENSORS_MAGNETIC_FIELD_HANDLE, 253 SENSOR_TYPE_MAGNETIC_FIELD, 10240.0f, 1.0f, 0.5f, 10000, {}}, 254 {"MPL Raw Magnetic Field", "Invensense", 1, 255 SENSORS_RAW_MAGNETIC_FIELD_HANDLE, 256 SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED, 10240.0f, 1.0f, 0.5f, 10000, {}}, 257 #ifdef ENABLE_PRESSURE 258 {"MPL Pressure", "Invensense", 1, 259 SENSORS_PRESSURE_HANDLE, 260 SENSOR_TYPE_PRESSURE, 10240.0f, 1.0f, 0.5f, 10000, {}}, 261 #endif 262 {"MPL Orientation", "Invensense", 1, 263 SENSORS_ORIENTATION_HANDLE, 264 SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 9.7f, 10000, {}}, 265 {"MPL Rotation Vector", "Invensense", 1, 266 SENSORS_ROTATION_VECTOR_HANDLE, 267 SENSOR_TYPE_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, {}}, 268 {"MPL Game Rotation Vector", "Invensense", 1, 269 SENSORS_GAME_ROTATION_VECTOR_HANDLE, 270 SENSOR_TYPE_GAME_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, {}}, 271 {"MPL Linear Acceleration", "Invensense", 1, 272 SENSORS_LINEAR_ACCEL_HANDLE, 273 SENSOR_TYPE_LINEAR_ACCELERATION, 10240.0f, 1.0f, 0.5f, 10000, {}}, 274 {"MPL Gravity", "Invensense", 1, 275 SENSORS_GRAVITY_HANDLE, 276 SENSOR_TYPE_GRAVITY, 10240.0f, 1.0f, 0.5f, 10000, {}}, 277 {"MPL Significant Motion", "Invensense", 1, 278 SENSORS_SIGNIFICANT_MOTION_HANDLE, 279 SENSOR_TYPE_SIGNIFICANT_MOTION, 100.0f, 1.0f, 1.1f, 0, {}}, 280 {"MPL Step Detector", "Invensense", 1, 281 SENSORS_PEDOMETER_HANDLE, 282 SENSOR_TYPE_STEP_DETECTOR, 100.0f, 1.0f, 1.1f, 0, {}}, 283 {"MPL Step Counter", "Invensense", 1, 284 SENSORS_STEP_COUNTER_HANDLE, 285 SENSOR_TYPE_STEP_COUNTER, 100.0f, 1.0f, 1.1f, 0, {}}, 286 {"MPL Geomagnetic Rotation Vector", "Invensense", 1, 287 SENSORS_GEOMAGNETIC_ROTATION_VECTOR_HANDLE, 288 SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, {}}, 289 #ifdef ENABLE_DMP_SCREEN_AUTO_ROTATION 290 {"MPL Screen Orientation", "Invensense ", 1, 291 SENSORS_SCREEN_ORIENTATION_HANDLE, 292 SENSOR_TYPE_SCREEN_ORIENTATION, 100.0f, 1.0f, 1.1f, 0, {}}, 293 #endif 294 }; 295 #endif //ANDROID_JELLYBEAN END 296 297 /*****************************************************************************/ 298 299 /* 300 * The SENSORS Module 301 */ 302 303 /* ITG3500 */ 304 #define EVENT_TYPE_GYRO_X REL_X 305 #define EVENT_TYPE_GYRO_Y REL_Y 306 #define EVENT_TYPE_GYRO_Z REL_Z 307 /* MPU6050 MPU9150 */ 308 #define EVENT_TYPE_IACCEL_X REL_RX 309 #define EVENT_TYPE_IACCEL_Y REL_RY 310 #define EVENT_TYPE_IACCEL_Z REL_RZ 311 /* MPU6050 MPU9150 */ 312 #define EVENT_TYPE_ICOMPASS_X REL_X 313 #define EVENT_TYPE_ICOMPASS_Y REL_Y 314 #define EVENT_TYPE_ICOMPASS_Z REL_Z 315 /* MPUxxxx */ 316 #define EVENT_TYPE_TIMESTAMP_HI REL_MISC 317 #define EVENT_TYPE_TIMESTAMP_LO REL_WHEEL 318 319 /* Accel BMA250 */ 320 #define EVENT_TYPE_ACCEL_X ABS_X 321 #define EVENT_TYPE_ACCEL_Y ABS_Y 322 #define EVENT_TYPE_ACCEL_Z ABS_Z 323 #define LSG (1000.0f) 324 325 // conversion of acceleration data to SI units (m/s^2) 326 #define RANGE_A (4*GRAVITY_EARTH) 327 #define RESOLUTION_A (GRAVITY_EARTH / LSG) 328 #define CONVERT_A (GRAVITY_EARTH / LSG) 329 #define CONVERT_A_X (CONVERT_A) 330 #define CONVERT_A_Y (CONVERT_A) 331 #define CONVERT_A_Z (CONVERT_A) 332 333 /* AKM compasses */ 334 #define EVENT_TYPE_MAGV_X ABS_RX 335 #define EVENT_TYPE_MAGV_Y ABS_RY 336 #define EVENT_TYPE_MAGV_Z ABS_RZ 337 #define EVENT_TYPE_MAGV_STATUS ABS_RUDDER 338 339 /* conversion of magnetic data to uT units */ 340 #define CONVERT_M (0.06f) 341 342 /* conversion of sensor rates */ 343 #define hertz_request = 200; 344 #define DEFAULT_MPL_GYRO_RATE (20000L) //us 345 #define DEFAULT_MPL_COMPASS_RATE (20000L) //us 346 347 #define DEFAULT_HW_GYRO_RATE (100) //Hz 348 #define DEFAULT_HW_ACCEL_RATE (20) //ms 349 #define DEFAULT_HW_COMPASS_RATE (20000000L) //ns 350 #define DEFAULT_HW_AKMD_COMPASS_RATE (200000000L) //ns 351 352 /* convert ns to hardware units */ 353 #define HW_GYRO_RATE_NS (1000000000LL / rate_request) // to Hz 354 #define HW_ACCEL_RATE_NS (rate_request / (1000000L)) // to ms 355 #define HW_COMPASS_RATE_NS (rate_request) // to ns 356 357 /* convert Hz to hardware units */ 358 #define HW_GYRO_RATE_HZ (hertz_request) 359 #define HW_ACCEL_RATE_HZ (1000 / hertz_request) 360 #define HW_COMPASS_RATE_HZ (1000000000LL / hertz_request) 361 362 #define RATE_200HZ 5000000LL 363 #define RATE_15HZ 66667000LL 364 #define RATE_5HZ 200000000LL 365 __END_DECLS 366 367 #endif // ANDROID_SENSORS_H 368