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_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_FC,
     55     ID_SO
     56 };
     57 
     58 /*****************************************************************************/
     59 
     60 /*
     61  * The SENSORS Module
     62  */
     63 
     64 /* ITG3500 */
     65 #define EVENT_TYPE_GYRO_X          REL_X
     66 #define EVENT_TYPE_GYRO_Y          REL_Y
     67 #define EVENT_TYPE_GYRO_Z          REL_Z
     68 /* MPU6050 MPU9150 */
     69 #define EVENT_TYPE_IACCEL_X        REL_RX
     70 #define EVENT_TYPE_IACCEL_Y        REL_RY
     71 #define EVENT_TYPE_IACCEL_Z        REL_RZ
     72 /* MPU6050 MPU9150 */
     73 #define EVENT_TYPE_ICOMPASS_X      REL_X
     74 #define EVENT_TYPE_ICOMPASS_Y      REL_Y
     75 #define EVENT_TYPE_ICOMPASS_Z      REL_Z
     76 /* MPUxxxx */
     77 #define EVENT_TYPE_TIMESTAMP_HI    REL_MISC
     78 #define EVENT_TYPE_TIMESTAMP_LO    REL_WHEEL
     79 
     80 /* Accel BMA250 */
     81 #define EVENT_TYPE_ACCEL_X          ABS_X
     82 #define EVENT_TYPE_ACCEL_Y          ABS_Y
     83 #define EVENT_TYPE_ACCEL_Z          ABS_Z
     84 #define LSG                         (1000.0f)
     85 
     86 // conversion of acceleration data to SI units (m/s^2)
     87 #define RANGE_A                     (4*GRAVITY_EARTH)
     88 #define RESOLUTION_A                (GRAVITY_EARTH / LSG)
     89 #define CONVERT_A                   (GRAVITY_EARTH / LSG)
     90 #define CONVERT_A_X                 (CONVERT_A)
     91 #define CONVERT_A_Y                 (CONVERT_A)
     92 #define CONVERT_A_Z                 (CONVERT_A)
     93 
     94 /* AKM  compasses */
     95 #define EVENT_TYPE_MAGV_X           ABS_RX
     96 #define EVENT_TYPE_MAGV_Y           ABS_RY
     97 #define EVENT_TYPE_MAGV_Z           ABS_RZ
     98 #define EVENT_TYPE_MAGV_STATUS      ABS_RUDDER
     99 
    100 // conversion of magnetic data to uT units
    101 #define CONVERT_M                   (0.06f)
    102 
    103 __END_DECLS
    104 
    105 #endif  // ANDROID_SENSORS_H
    106