Home | History | Annotate | Download | only in libsensors_iio
      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_O,
     44     ID_RV,
     45     ID_LA,
     46     ID_GR,
     47     ID_SO
     48 };
     49 
     50 /*****************************************************************************/
     51 
     52 /*
     53  * The SENSORS Module
     54  */
     55 
     56 /* ITG3500 */
     57 #define EVENT_TYPE_GYRO_X          REL_X
     58 #define EVENT_TYPE_GYRO_Y          REL_Y
     59 #define EVENT_TYPE_GYRO_Z          REL_Z
     60 /* MPU6050 MPU9150 */
     61 #define EVENT_TYPE_IACCEL_X        REL_RX
     62 #define EVENT_TYPE_IACCEL_Y        REL_RY
     63 #define EVENT_TYPE_IACCEL_Z        REL_RZ
     64 /* MPU6050 MPU9150 */
     65 #define EVENT_TYPE_ICOMPASS_X      REL_X
     66 #define EVENT_TYPE_ICOMPASS_Y      REL_Y
     67 #define EVENT_TYPE_ICOMPASS_Z      REL_Z
     68 /* MPUxxxx */
     69 #define EVENT_TYPE_TIMESTAMP_HI    REL_MISC
     70 #define EVENT_TYPE_TIMESTAMP_LO    REL_WHEEL
     71 
     72 /* Accel BMA250 */
     73 #define EVENT_TYPE_ACCEL_X          ABS_X
     74 #define EVENT_TYPE_ACCEL_Y          ABS_Y
     75 #define EVENT_TYPE_ACCEL_Z          ABS_Z
     76 #define LSG                         (1000.0f)
     77 
     78 // conversion of acceleration data to SI units (m/s^2)
     79 #define RANGE_A                     (4*GRAVITY_EARTH)
     80 #define RESOLUTION_A                (GRAVITY_EARTH / LSG)
     81 #define CONVERT_A                   (GRAVITY_EARTH / LSG)
     82 #define CONVERT_A_X                 (CONVERT_A)
     83 #define CONVERT_A_Y                 (CONVERT_A)
     84 #define CONVERT_A_Z                 (CONVERT_A)
     85 
     86 /* Compass AKM8975 */
     87 #define EVENT_TYPE_MAGV_X           ABS_RX
     88 #define EVENT_TYPE_MAGV_Y           ABS_RY
     89 #define EVENT_TYPE_MAGV_Z           ABS_RZ
     90 #define EVENT_TYPE_MAGV_STATUS      ABS_RUDDER
     91 
     92 // conversion of magnetic data to uT units
     93 #define CONVERT_M                   (0.06f)
     94 
     95 __END_DECLS
     96 
     97 #endif  // ANDROID_SENSORS_H
     98