BMI160 Initial

Dependents:   MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_Pitch_Charles Maxim_Squeeks

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bmi160_defs.h Source File

bmi160_defs.h

Go to the documentation of this file.
00001 /**
00002  * Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *
00007  * Redistributions of source code must retain the above copyright
00008  * notice, this list of conditions and the following disclaimer.
00009  *
00010  * Redistributions in binary form must reproduce the above copyright
00011  * notice, this list of conditions and the following disclaimer in the
00012  * documentation and/or other materials provided with the distribution.
00013  *
00014  * Neither the name of the copyright holder nor the names of the
00015  * contributors may be used to endorse or promote products derived from
00016  * this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
00019  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
00020  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
00023  * OR CONTRIBUTORS BE LIABLE FOR ANY
00024  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
00025  * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
00026  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00029  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  * ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00033  *
00034  * The information provided is believed to be accurate and reliable.
00035  * The copyright holder assumes no responsibility
00036  * for the consequences of use
00037  * of such information nor for any infringement of patents or
00038  * other rights of third parties which may result from its use.
00039  * No license is granted by implication or otherwise under any patent or
00040  * patent rights of the copyright holder.
00041  *
00042  * @file    bmi160_defs.h
00043  * @date    11 Jan 2018
00044  * @version 3.7.5
00045  * @brief
00046  *
00047  */
00048 
00049 /*!
00050  * @defgroup bmi160_defs
00051  * @brief
00052  * @{*/
00053 
00054 #ifndef BMI160_DEFS_H_
00055 #define BMI160_DEFS_H_
00056 
00057 /*************************** C types headers *****************************/
00058 #ifdef __KERNEL__
00059 #include <linux/types.h>
00060 #include <linux/kernel.h>
00061 #else
00062 #include <stdint.h>
00063 #include <stddef.h>
00064 #endif
00065 
00066 /*************************** Common macros   *****************************/
00067 
00068 #if !defined(UINT8_C) && !defined(INT8_C)
00069 #define INT8_C(x)       S8_C(x)
00070 #define UINT8_C(x)      U8_C(x)
00071 #endif
00072 
00073 #if !defined(UINT16_C) && !defined(INT16_C)
00074 #define INT16_C(x)      S16_C(x)
00075 #define UINT16_C(x)     U16_C(x)
00076 #endif
00077 
00078 #if !defined(INT32_C) && !defined(UINT32_C)
00079 #define INT32_C(x)      S32_C(x)
00080 #define UINT32_C(x)     U32_C(x)
00081 #endif
00082 
00083 #if !defined(INT64_C) && !defined(UINT64_C)
00084 #define INT64_C(x)      S64_C(x)
00085 #define UINT64_C(x)     U64_C(x)
00086 #endif
00087 
00088 /**@}*/
00089 
00090 /**\name C standard macros */
00091 #ifndef NULL
00092 #ifdef __cplusplus
00093 #define NULL   0
00094 #else
00095 #define NULL   ((void *) 0)
00096 #endif
00097 #endif
00098 
00099 /*************************** Sensor macros   *****************************/
00100 /* Test for an endian machine */
00101 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
00102 #define LITTLE_ENDIAN   1
00103 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
00104 #define BIG_ENDIAN   1
00105 #else
00106 #error "Code does not support Endian format of the processor"
00107 #endif
00108 
00109 /** Mask definitions */
00110 #define BMI160_ACCEL_BW_MASK                    UINT8_C(0x70)
00111 #define BMI160_ACCEL_ODR_MASK                   UINT8_C(0x0F)
00112 #define BMI160_ACCEL_UNDERSAMPLING_MASK         UINT8_C(0x80)
00113 #define BMI160_ACCEL_RANGE_MASK                 UINT8_C(0x0F)
00114 #define BMI160_GYRO_BW_MASK                     UINT8_C(0x30)
00115 #define BMI160_GYRO_ODR_MASK                    UINT8_C(0x0F)
00116 #define BMI160_GYRO_RANGE_MSK                   UINT8_C(0x07)
00117 
00118 /** Mask definitions for INT_EN registers */
00119 #define BMI160_ANY_MOTION_X_INT_EN_MASK         UINT8_C(0x01)
00120 #define BMI160_HIGH_G_X_INT_EN_MASK             UINT8_C(0x01)
00121 #define BMI160_NO_MOTION_X_INT_EN_MASK          UINT8_C(0x01)
00122 #define BMI160_ANY_MOTION_Y_INT_EN_MASK         UINT8_C(0x02)
00123 #define BMI160_HIGH_G_Y_INT_EN_MASK             UINT8_C(0x02)
00124 #define BMI160_NO_MOTION_Y_INT_EN_MASK          UINT8_C(0x02)
00125 #define BMI160_ANY_MOTION_Z_INT_EN_MASK         UINT8_C(0x04)
00126 #define BMI160_HIGH_G_Z_INT_EN_MASK             UINT8_C(0x04)
00127 #define BMI160_NO_MOTION_Z_INT_EN_MASK          UINT8_C(0x04)
00128 #define BMI160_SIG_MOTION_INT_EN_MASK           UINT8_C(0x07)
00129 #define BMI160_ANY_MOTION_ALL_INT_EN_MASK   UINT8_C(0x07)
00130 #define BMI160_STEP_DETECT_INT_EN_MASK          UINT8_C(0x08)
00131 #define BMI160_DOUBLE_TAP_INT_EN_MASK           UINT8_C(0x10)
00132 #define BMI160_SINGLE_TAP_INT_EN_MASK           UINT8_C(0x20)
00133 #define BMI160_FIFO_FULL_INT_EN_MASK            UINT8_C(0x20)
00134 #define BMI160_ORIENT_INT_EN_MASK               UINT8_C(0x40)
00135 #define BMI160_FIFO_WATERMARK_INT_EN_MASK       UINT8_C(0x40)
00136 #define BMI160_LOW_G_INT_EN_MASK                UINT8_C(0x08)
00137 #define BMI160_STEP_DETECT_EN_MASK              UINT8_C(0x08)
00138 #define BMI160_FLAT_INT_EN_MASK                 UINT8_C(0x80)
00139 #define BMI160_DATA_RDY_INT_EN_MASK             UINT8_C(0x10)
00140 
00141 /** PMU status Macros */
00142 #define BMI160_AUX_PMU_SUSPEND         UINT8_C(0x00)
00143 #define BMI160_AUX_PMU_NORMAL          UINT8_C(0x01)
00144 #define BMI160_AUX_PMU_LOW_POWER       UINT8_C(0x02)
00145 
00146 #define BMI160_GYRO_PMU_SUSPEND        UINT8_C(0x00)
00147 #define BMI160_GYRO_PMU_NORMAL         UINT8_C(0x01)
00148 #define BMI160_GYRO_PMU_FSU            UINT8_C(0x03)
00149 
00150 #define BMI160_ACCEL_PMU_SUSPEND       UINT8_C(0x00)
00151 #define BMI160_ACCEL_PMU_NORMAL        UINT8_C(0x01)
00152 #define BMI160_ACCEL_PMU_LOW_POWER     UINT8_C(0x02)
00153 
00154 /** Mask definitions for INT_OUT_CTRL register */
00155 #define BMI160_INT1_EDGE_CTRL_MASK              UINT8_C(0x01)
00156 #define BMI160_INT1_OUTPUT_MODE_MASK            UINT8_C(0x04)
00157 #define BMI160_INT1_OUTPUT_TYPE_MASK            UINT8_C(0x02)
00158 #define BMI160_INT1_OUTPUT_EN_MASK              UINT8_C(0x08)
00159 #define BMI160_INT2_EDGE_CTRL_MASK              UINT8_C(0x10)
00160 #define BMI160_INT2_OUTPUT_MODE_MASK            UINT8_C(0x40)
00161 #define BMI160_INT2_OUTPUT_TYPE_MASK            UINT8_C(0x20)
00162 #define BMI160_INT2_OUTPUT_EN_MASK              UINT8_C(0x80)
00163 
00164 /** Mask definitions for INT_LATCH register */
00165 #define BMI160_INT1_INPUT_EN_MASK               UINT8_C(0x10)
00166 #define BMI160_INT2_INPUT_EN_MASK               UINT8_C(0x20)
00167 #define BMI160_INT_LATCH_MASK                   UINT8_C(0x0F)
00168 
00169 /** Mask definitions for INT_MAP register */
00170 #define BMI160_INT1_LOW_G_MASK                  UINT8_C(0x01)
00171 #define BMI160_INT1_HIGH_G_MASK                 UINT8_C(0x02)
00172 #define BMI160_INT1_SLOPE_MASK                  UINT8_C(0x04)
00173 #define BMI160_INT1_NO_MOTION_MASK              UINT8_C(0x08)
00174 #define BMI160_INT1_DOUBLE_TAP_MASK             UINT8_C(0x10)
00175 #define BMI160_INT1_SINGLE_TAP_MASK             UINT8_C(0x20)
00176 #define BMI160_INT1_FIFO_FULL_MASK              UINT8_C(0x20)
00177 #define BMI160_INT1_FIFO_WM_MASK        UINT8_C(0x40)
00178 #define BMI160_INT1_ORIENT_MASK                 UINT8_C(0x40)
00179 #define BMI160_INT1_FLAT_MASK                   UINT8_C(0x80)
00180 #define BMI160_INT1_DATA_READY_MASK             UINT8_C(0x80)
00181 #define BMI160_INT2_LOW_G_MASK                  UINT8_C(0x01)
00182 #define BMI160_INT1_LOW_STEP_DETECT_MASK        UINT8_C(0x01)
00183 #define BMI160_INT2_LOW_STEP_DETECT_MASK        UINT8_C(0x01)
00184 #define BMI160_INT2_HIGH_G_MASK                 UINT8_C(0x02)
00185 #define BMI160_INT2_FIFO_FULL_MASK              UINT8_C(0x02)
00186 #define BMI160_INT2_FIFO_WM_MASK        UINT8_C(0x04)
00187 #define BMI160_INT2_SLOPE_MASK                  UINT8_C(0x04)
00188 #define BMI160_INT2_DATA_READY_MASK             UINT8_C(0x08)
00189 #define BMI160_INT2_NO_MOTION_MASK              UINT8_C(0x08)
00190 #define BMI160_INT2_DOUBLE_TAP_MASK             UINT8_C(0x10)
00191 #define BMI160_INT2_SINGLE_TAP_MASK             UINT8_C(0x20)
00192 #define BMI160_INT2_ORIENT_MASK                 UINT8_C(0x40)
00193 #define BMI160_INT2_FLAT_MASK                   UINT8_C(0x80)
00194 
00195 /** Mask definitions for INT_DATA register */
00196 #define BMI160_TAP_SRC_INT_MASK                 UINT8_C(0x08)
00197 #define BMI160_LOW_HIGH_SRC_INT_MASK            UINT8_C(0x80)
00198 #define BMI160_MOTION_SRC_INT_MASK              UINT8_C(0x80)
00199 
00200 /** Mask definitions for INT_MOTION register */
00201 #define BMI160_SLOPE_INT_DUR_MASK               UINT8_C(0x03)
00202 #define BMI160_NO_MOTION_INT_DUR_MASK           UINT8_C(0xFC)
00203 #define BMI160_NO_MOTION_SEL_BIT_MASK           UINT8_C(0x01)
00204 
00205 /** Mask definitions for INT_TAP register */
00206 #define BMI160_TAP_DUR_MASK                     UINT8_C(0x07)
00207 #define BMI160_TAP_SHOCK_DUR_MASK               UINT8_C(0x40)
00208 #define BMI160_TAP_QUIET_DUR_MASK               UINT8_C(0x80)
00209 #define BMI160_TAP_THRES_MASK                   UINT8_C(0x1F)
00210 
00211 /** Mask definitions for INT_FLAT register */
00212 #define BMI160_FLAT_THRES_MASK                  UINT8_C(0x3F)
00213 #define BMI160_FLAT_HOLD_TIME_MASK              UINT8_C(0x30)
00214 #define BMI160_FLAT_HYST_MASK                   UINT8_C(0x07)
00215 
00216 /** Mask definitions for INT_LOWHIGH register */
00217 #define BMI160_LOW_G_HYST_MASK                  UINT8_C(0x03)
00218 #define BMI160_LOW_G_LOW_MODE_MASK              UINT8_C(0x04)
00219 #define BMI160_HIGH_G_HYST_MASK                 UINT8_C(0xC0)
00220 
00221 /** Mask definitions for INT_SIG_MOTION register */
00222 #define BMI160_SIG_MOTION_SEL_MASK              UINT8_C(0x02)
00223 #define BMI160_SIG_MOTION_SKIP_MASK             UINT8_C(0x0C)
00224 #define BMI160_SIG_MOTION_PROOF_MASK            UINT8_C(0x30)
00225 
00226 /** Mask definitions for INT_ORIENT register */
00227 #define BMI160_ORIENT_MODE_MASK                 UINT8_C(0x03)
00228 #define BMI160_ORIENT_BLOCK_MASK                UINT8_C(0x0C)
00229 #define BMI160_ORIENT_HYST_MASK                 UINT8_C(0xF0)
00230 #define BMI160_ORIENT_THETA_MASK                UINT8_C(0x3F)
00231 #define BMI160_ORIENT_UD_ENABLE                 UINT8_C(0x40)
00232 #define BMI160_AXES_EN_MASK                     UINT8_C(0x80)
00233 
00234 /** Mask definitions for FIFO_CONFIG register */
00235 #define BMI160_FIFO_GYRO            UINT8_C(0x80)
00236 #define BMI160_FIFO_ACCEL           UINT8_C(0x40)
00237 #define BMI160_FIFO_AUX             UINT8_C(0x20)
00238 #define BMI160_FIFO_TAG_INT1            UINT8_C(0x08)
00239 #define BMI160_FIFO_TAG_INT2            UINT8_C(0x04)
00240 #define BMI160_FIFO_TIME            UINT8_C(0x02)
00241 #define BMI160_FIFO_HEADER          UINT8_C(0x10)
00242 #define BMI160_FIFO_CONFIG_1_MASK               UINT8_C(0xFE)
00243 
00244 
00245 /** Mask definitions for STEP_CONF register */
00246 #define BMI160_STEP_COUNT_EN_BIT_MASK           UINT8_C(0x08)
00247 #define BMI160_STEP_DETECT_MIN_THRES_MASK       UINT8_C(0x18)
00248 #define BMI160_STEP_DETECT_STEPTIME_MIN_MASK    UINT8_C(0x07)
00249 #define BMI160_STEP_MIN_BUF_MASK                UINT8_C(0x07)
00250 
00251 /** Mask definition for FIFO Header Data Tag */
00252 #define BMI160_FIFO_TAG_INTR_MASK               UINT8_C(0xFC)
00253 
00254 /** Fifo byte counter mask definitions */
00255 #define BMI160_FIFO_BYTE_COUNTER_MASK           UINT8_C(0x07)
00256 
00257 /** Enable/disable bit value */
00258 #define BMI160_ENABLE                           0x01
00259 #define BMI160_DISABLE                          UINT8_C(0x00)
00260 
00261 /** Latch Duration */
00262 #define BMI160_LATCH_DUR_NONE                   UINT8_C(0x00)
00263 #define BMI160_LATCH_DUR_312_5_MICRO_SEC        UINT8_C(0x01)
00264 #define BMI160_LATCH_DUR_625_MICRO_SEC          UINT8_C(0x02)
00265 #define BMI160_LATCH_DUR_1_25_MILLI_SEC         UINT8_C(0x03)
00266 #define BMI160_LATCH_DUR_2_5_MILLI_SEC          UINT8_C(0x04)
00267 #define BMI160_LATCH_DUR_5_MILLI_SEC            UINT8_C(0x05)
00268 #define BMI160_LATCH_DUR_10_MILLI_SEC           UINT8_C(0x06)
00269 #define BMI160_LATCH_DUR_20_MILLI_SEC           UINT8_C(0x07)
00270 #define BMI160_LATCH_DUR_40_MILLI_SEC           UINT8_C(0x08)
00271 #define BMI160_LATCH_DUR_80_MILLI_SEC           UINT8_C(0x09)
00272 #define BMI160_LATCH_DUR_160_MILLI_SEC          UINT8_C(0x0A)
00273 #define BMI160_LATCH_DUR_320_MILLI_SEC          UINT8_C(0x0B)
00274 #define BMI160_LATCH_DUR_640_MILLI_SEC          UINT8_C(0x0C)
00275 #define BMI160_LATCH_DUR_1_28_SEC               UINT8_C(0x0D)
00276 #define BMI160_LATCH_DUR_2_56_SEC               UINT8_C(0x0E)
00277 #define BMI160_LATCHED                          UINT8_C(0x0F)
00278 
00279 /** BMI160 Register map */
00280 #define BMI160_CHIP_ID_ADDR     UINT8_C(0x00)
00281 #define BMI160_ERROR_REG_ADDR       UINT8_C(0x02)
00282 #define BMI160_PMU_STATUS_ADDR      UINT8_C(0x03)
00283 #define BMI160_AUX_DATA_ADDR        UINT8_C(0x04)
00284 #define BMI160_GYRO_DATA_ADDR       UINT8_C(0x0C)
00285 #define BMI160_ACCEL_DATA_ADDR      UINT8_C(0x12)
00286 #define BMI160_STATUS_ADDR      UINT8_C(0x1B)
00287 #define BMI160_INT_STATUS_ADDR      UINT8_C(0x1C)
00288 #define BMI160_FIFO_LENGTH_ADDR     UINT8_C(0x22)
00289 #define BMI160_FIFO_DATA_ADDR       UINT8_C(0x24)
00290 #define BMI160_ACCEL_CONFIG_ADDR    UINT8_C(0x40)
00291 #define BMI160_ACCEL_RANGE_ADDR     UINT8_C(0x41)
00292 #define BMI160_GYRO_CONFIG_ADDR     UINT8_C(0x42)
00293 #define BMI160_GYRO_RANGE_ADDR      UINT8_C(0x43)
00294 #define BMI160_AUX_ODR_ADDR     UINT8_C(0x44)
00295 #define BMI160_FIFO_DOWN_ADDR           UINT8_C(0x45)
00296 #define BMI160_FIFO_CONFIG_0_ADDR       UINT8_C(0x46)
00297 #define BMI160_FIFO_CONFIG_1_ADDR       UINT8_C(0x47)
00298 #define BMI160_AUX_IF_0_ADDR        UINT8_C(0x4B)
00299 #define BMI160_AUX_IF_1_ADDR        UINT8_C(0x4C)
00300 #define BMI160_AUX_IF_2_ADDR        UINT8_C(0x4D)
00301 #define BMI160_AUX_IF_3_ADDR        UINT8_C(0x4E)
00302 #define BMI160_AUX_IF_4_ADDR        UINT8_C(0x4F)
00303 #define BMI160_INT_ENABLE_0_ADDR         UINT8_C(0x50)
00304 #define BMI160_INT_ENABLE_1_ADDR         UINT8_C(0x51)
00305 #define BMI160_INT_ENABLE_2_ADDR         UINT8_C(0x52)
00306 #define BMI160_INT_OUT_CTRL_ADDR         UINT8_C(0x53)
00307 #define BMI160_INT_LATCH_ADDR            UINT8_C(0x54)
00308 #define BMI160_INT_MAP_0_ADDR            UINT8_C(0x55)
00309 #define BMI160_INT_MAP_1_ADDR            UINT8_C(0x56)
00310 #define BMI160_INT_MAP_2_ADDR            UINT8_C(0x57)
00311 #define BMI160_INT_DATA_0_ADDR           UINT8_C(0x58)
00312 #define BMI160_INT_DATA_1_ADDR           UINT8_C(0x59)
00313 #define BMI160_INT_LOWHIGH_0_ADDR        UINT8_C(0x5A)
00314 #define BMI160_INT_LOWHIGH_1_ADDR        UINT8_C(0x5B)
00315 #define BMI160_INT_LOWHIGH_2_ADDR        UINT8_C(0x5C)
00316 #define BMI160_INT_LOWHIGH_3_ADDR        UINT8_C(0x5D)
00317 #define BMI160_INT_LOWHIGH_4_ADDR        UINT8_C(0x5E)
00318 #define BMI160_INT_MOTION_0_ADDR         UINT8_C(0x5F)
00319 #define BMI160_INT_MOTION_1_ADDR         UINT8_C(0x60)
00320 #define BMI160_INT_MOTION_2_ADDR         UINT8_C(0x61)
00321 #define BMI160_INT_MOTION_3_ADDR         UINT8_C(0x62)
00322 #define BMI160_INT_TAP_0_ADDR            UINT8_C(0x63)
00323 #define BMI160_INT_TAP_1_ADDR            UINT8_C(0x64)
00324 #define BMI160_INT_ORIENT_0_ADDR         UINT8_C(0x65)
00325 #define BMI160_INT_ORIENT_1_ADDR         UINT8_C(0x66)
00326 #define BMI160_INT_FLAT_0_ADDR           UINT8_C(0x67)
00327 #define BMI160_INT_FLAT_1_ADDR           UINT8_C(0x68)
00328 #define BMI160_FOC_CONF_ADDR             UINT8_C(0x69)
00329 #define BMI160_CONF_ADDR                 UINT8_C(0x6A)
00330 
00331 #define BMI160_IF_CONF_ADDR      UINT8_C(0x6B)
00332 #define BMI160_SELF_TEST_ADDR        UINT8_C(0x6D)
00333 #define BMI160_OFFSET_ADDR       UINT8_C(0x71)
00334 #define BMI160_OFFSET_CONF_ADDR      UINT8_C(0x77)
00335 #define BMI160_INT_STEP_CNT_0_ADDR   UINT8_C(0x78)
00336 #define BMI160_INT_STEP_CONFIG_0_ADDR    UINT8_C(0x7A)
00337 #define BMI160_INT_STEP_CONFIG_1_ADDR    UINT8_C(0x7B)
00338 #define BMI160_COMMAND_REG_ADDR      UINT8_C(0x7E)
00339 #define BMI160_SPI_COMM_TEST_ADDR        UINT8_C(0x7F)
00340 #define BMI160_INTL_PULLUP_CONF_ADDR     UINT8_C(0x85)
00341 
00342 /** Error code definitions */
00343 #define BMI160_OK                         0
00344 #define BMI160_E_NULL_PTR                 INT8_C(-1)
00345 #define BMI160_E_COM_FAIL                 INT8_C(-2)
00346 #define BMI160_E_DEV_NOT_FOUND            INT8_C(-3)
00347 #define BMI160_E_OUT_OF_RANGE             INT8_C(-4)
00348 #define BMI160_E_INVALID_INPUT            INT8_C(-5)
00349 #define BMI160_E_ACCEL_ODR_BW_INVALID     INT8_C(-6)
00350 #define BMI160_E_GYRO_ODR_BW_INVALID      INT8_C(-7)
00351 #define BMI160_E_LWP_PRE_FLTR_INT_INVALID INT8_C(-8)
00352 #define BMI160_E_LWP_PRE_FLTR_INVALID     INT8_C(-9)
00353 #define BMI160_E_AUX_NOT_FOUND        INT8_C(-10)
00354 #define BMI160_FOC_FAILURE        INT8_C(-11)
00355 
00356 /**\name API warning codes */
00357 #define BMI160_W_GYRO_SELF_TEST_FAIL    INT8_C(1)
00358 #define BMI160_W_ACCEl_SELF_TEST_FAIL   INT8_C(2)
00359 
00360 /** BMI160 unique chip identifier */
00361 #define BMI160_CHIP_ID                   UINT8_C(0xD1)
00362 
00363 /** Soft reset command */
00364 #define BMI160_SOFT_RESET_CMD            UINT8_C(0xb6)
00365 #define BMI160_SOFT_RESET_DELAY_MS       UINT8_C(15)
00366 /** Start FOC command */
00367 #define BMI160_START_FOC_CMD            UINT8_C(0x03)
00368 /** NVM backup enabling command */
00369 #define BMI160_NVM_BACKUP_EN        UINT8_C(0xA0)
00370 
00371 /* Delay in ms settings */
00372 #define BMI160_ACCEL_DELAY_MS            UINT8_C(5)
00373 #define BMI160_GYRO_DELAY_MS             UINT8_C(81)
00374 #define BMI160_ONE_MS_DELAY              UINT8_C(1)
00375 #define BMI160_AUX_COM_DELAY         UINT8_C(10)
00376 #define BMI160_GYRO_SELF_TEST_DELAY  UINT8_C(20)
00377 #define BMI160_ACCEL_SELF_TEST_DELAY     UINT8_C(50)
00378 
00379 /** Self test configurations */
00380 #define BMI160_ACCEL_SELF_TEST_CONFIG       UINT8_C(0x2C)
00381 #define BMI160_ACCEL_SELF_TEST_POSITIVE_EN  UINT8_C(0x0D)
00382 #define BMI160_ACCEL_SELF_TEST_NEGATIVE_EN  UINT8_C(0x09)
00383 #define BMI160_ACCEL_SELF_TEST_LIMIT        UINT16_C(8192)
00384 
00385 /** Power mode settings */
00386 /* Accel power mode */
00387 #define BMI160_ACCEL_NORMAL_MODE         UINT8_C(0x11)
00388 #define BMI160_ACCEL_LOWPOWER_MODE       UINT8_C(0x12)
00389 #define BMI160_ACCEL_SUSPEND_MODE        UINT8_C(0x10)
00390 
00391 /* Gyro power mode */
00392 #define BMI160_GYRO_SUSPEND_MODE         UINT8_C(0x14)
00393 #define BMI160_GYRO_NORMAL_MODE          UINT8_C(0x15)
00394 #define BMI160_GYRO_FASTSTARTUP_MODE     UINT8_C(0x17)
00395 
00396 /* Aux power mode */
00397 #define BMI160_AUX_SUSPEND_MODE     UINT8_C(0x18)
00398 #define BMI160_AUX_NORMAL_MODE      UINT8_C(0x19)
00399 #define BMI160_AUX_LOWPOWER_MODE    UINT8_C(0x1A)
00400 
00401 /** Range settings */
00402 /* Accel Range */
00403 #define BMI160_ACCEL_RANGE_2G            UINT8_C(0x03)
00404 #define BMI160_ACCEL_RANGE_4G            UINT8_C(0x05)
00405 #define BMI160_ACCEL_RANGE_8G            UINT8_C(0x08)
00406 #define BMI160_ACCEL_RANGE_16G           UINT8_C(0x0C)
00407 
00408 /* Gyro Range */
00409 #define BMI160_GYRO_RANGE_2000_DPS       UINT8_C(0x00)
00410 #define BMI160_GYRO_RANGE_1000_DPS       UINT8_C(0x01)
00411 #define BMI160_GYRO_RANGE_500_DPS        UINT8_C(0x02)
00412 #define BMI160_GYRO_RANGE_250_DPS        UINT8_C(0x03)
00413 #define BMI160_GYRO_RANGE_125_DPS        UINT8_C(0x04)
00414 
00415 /** Bandwidth settings */
00416 /* Accel Bandwidth */
00417 #define BMI160_ACCEL_BW_OSR4_AVG1        UINT8_C(0x00)
00418 #define BMI160_ACCEL_BW_OSR2_AVG2        UINT8_C(0x01)
00419 #define BMI160_ACCEL_BW_NORMAL_AVG4      UINT8_C(0x02)
00420 #define BMI160_ACCEL_BW_RES_AVG8         UINT8_C(0x03)
00421 #define BMI160_ACCEL_BW_RES_AVG16        UINT8_C(0x04)
00422 #define BMI160_ACCEL_BW_RES_AVG32        UINT8_C(0x05)
00423 #define BMI160_ACCEL_BW_RES_AVG64        UINT8_C(0x06)
00424 #define BMI160_ACCEL_BW_RES_AVG128       UINT8_C(0x07)
00425 
00426 #define BMI160_GYRO_BW_OSR4_MODE         UINT8_C(0x00)
00427 #define BMI160_GYRO_BW_OSR2_MODE         UINT8_C(0x01)
00428 #define BMI160_GYRO_BW_NORMAL_MODE       UINT8_C(0x02)
00429 
00430 /* Output Data Rate settings */
00431 /* Accel Output data rate */
00432 #define BMI160_ACCEL_ODR_RESERVED        UINT8_C(0x00)
00433 #define BMI160_ACCEL_ODR_0_78HZ          UINT8_C(0x01)
00434 #define BMI160_ACCEL_ODR_1_56HZ          UINT8_C(0x02)
00435 #define BMI160_ACCEL_ODR_3_12HZ          UINT8_C(0x03)
00436 #define BMI160_ACCEL_ODR_6_25HZ          UINT8_C(0x04)
00437 #define BMI160_ACCEL_ODR_12_5HZ          UINT8_C(0x05)
00438 #define BMI160_ACCEL_ODR_25HZ            UINT8_C(0x06)
00439 #define BMI160_ACCEL_ODR_50HZ            UINT8_C(0x07)
00440 #define BMI160_ACCEL_ODR_100HZ           UINT8_C(0x08)
00441 #define BMI160_ACCEL_ODR_200HZ           UINT8_C(0x09)
00442 #define BMI160_ACCEL_ODR_400HZ           UINT8_C(0x0A)
00443 #define BMI160_ACCEL_ODR_800HZ           UINT8_C(0x0B)
00444 #define BMI160_ACCEL_ODR_1600HZ          UINT8_C(0x0C)
00445 #define BMI160_ACCEL_ODR_RESERVED0       UINT8_C(0x0D)
00446 #define BMI160_ACCEL_ODR_RESERVED1       UINT8_C(0x0E)
00447 #define BMI160_ACCEL_ODR_RESERVED2       UINT8_C(0x0F)
00448 
00449 /* Gyro Output data rate */
00450 #define BMI160_GYRO_ODR_RESERVED         UINT8_C(0x00)
00451 #define BMI160_GYRO_ODR_25HZ             UINT8_C(0x06)
00452 #define BMI160_GYRO_ODR_50HZ             UINT8_C(0x07)
00453 #define BMI160_GYRO_ODR_100HZ            UINT8_C(0x08)
00454 #define BMI160_GYRO_ODR_200HZ            UINT8_C(0x09)
00455 #define BMI160_GYRO_ODR_400HZ            UINT8_C(0x0A)
00456 #define BMI160_GYRO_ODR_800HZ            UINT8_C(0x0B)
00457 #define BMI160_GYRO_ODR_1600HZ           UINT8_C(0x0C)
00458 #define BMI160_GYRO_ODR_3200HZ           UINT8_C(0x0D)
00459 
00460 /* Auxiliary sensor Output data rate */
00461 #define BMI160_AUX_ODR_RESERVED        UINT8_C(0x00)
00462 #define BMI160_AUX_ODR_0_78HZ          UINT8_C(0x01)
00463 #define BMI160_AUX_ODR_1_56HZ          UINT8_C(0x02)
00464 #define BMI160_AUX_ODR_3_12HZ          UINT8_C(0x03)
00465 #define BMI160_AUX_ODR_6_25HZ          UINT8_C(0x04)
00466 #define BMI160_AUX_ODR_12_5HZ          UINT8_C(0x05)
00467 #define BMI160_AUX_ODR_25HZ            UINT8_C(0x06)
00468 #define BMI160_AUX_ODR_50HZ            UINT8_C(0x07)
00469 #define BMI160_AUX_ODR_100HZ           UINT8_C(0x08)
00470 #define BMI160_AUX_ODR_200HZ           UINT8_C(0x09)
00471 #define BMI160_AUX_ODR_400HZ           UINT8_C(0x0A)
00472 #define BMI160_AUX_ODR_800HZ           UINT8_C(0x0B)
00473 
00474 /* Maximum limits definition */
00475 #define BMI160_ACCEL_ODR_MAX             UINT8_C(15)
00476 #define BMI160_ACCEL_BW_MAX              UINT8_C(2)
00477 #define BMI160_ACCEL_RANGE_MAX           UINT8_C(12)
00478 #define BMI160_GYRO_ODR_MAX              UINT8_C(13)
00479 #define BMI160_GYRO_BW_MAX               UINT8_C(2)
00480 #define BMI160_GYRO_RANGE_MAX            UINT8_C(4)
00481 
00482 /** FIFO_CONFIG Definitions */
00483 #define BMI160_FIFO_TIME_ENABLE          UINT8_C(0x02)
00484 #define BMI160_FIFO_TAG_INT2_ENABLE      UINT8_C(0x04)
00485 #define BMI160_FIFO_TAG_INT1_ENABLE      UINT8_C(0x08)
00486 #define BMI160_FIFO_HEAD_ENABLE          UINT8_C(0x10)
00487 #define BMI160_FIFO_M_ENABLE             UINT8_C(0x20)
00488 #define BMI160_FIFO_A_ENABLE             UINT8_C(0x40)
00489 #define BMI160_FIFO_M_A_ENABLE           UINT8_C(0x60)
00490 #define BMI160_FIFO_G_ENABLE             UINT8_C(0x80)
00491 #define BMI160_FIFO_M_G_ENABLE           UINT8_C(0xA0)
00492 #define BMI160_FIFO_G_A_ENABLE           UINT8_C(0xC0)
00493 #define BMI160_FIFO_M_G_A_ENABLE         UINT8_C(0xE0)
00494 
00495 /* Macro to specify the number of bytes over-read from the
00496  * FIFO in order to get the sensor time at the end of FIFO */
00497 #ifndef BMI160_FIFO_BYTES_OVERREAD
00498 #define BMI160_FIFO_BYTES_OVERREAD       UINT8_C(25)
00499 #endif
00500 
00501 
00502 
00503 /* Accel, gyro and aux. sensor length and also their combined
00504  * length definitions in FIFO */
00505 #define BMI160_FIFO_G_LENGTH             UINT8_C(6)
00506 #define BMI160_FIFO_A_LENGTH             UINT8_C(6)
00507 #define BMI160_FIFO_M_LENGTH             UINT8_C(8)
00508 #define BMI160_FIFO_GA_LENGTH            UINT8_C(12)
00509 #define BMI160_FIFO_MA_LENGTH            UINT8_C(14)
00510 #define BMI160_FIFO_MG_LENGTH            UINT8_C(14)
00511 #define BMI160_FIFO_MGA_LENGTH           UINT8_C(20)
00512 
00513 
00514 /** FIFO Header Data definitions */
00515 #define BMI160_FIFO_HEAD_SKIP_FRAME      UINT8_C(0x40)
00516 #define BMI160_FIFO_HEAD_SENSOR_TIME     UINT8_C(0x44)
00517 #define BMI160_FIFO_HEAD_INPUT_CONFIG    UINT8_C(0x48)
00518 #define BMI160_FIFO_HEAD_OVER_READ       UINT8_C(0x80)
00519 #define BMI160_FIFO_HEAD_A               UINT8_C(0x84)
00520 #define BMI160_FIFO_HEAD_G               UINT8_C(0x88)
00521 #define BMI160_FIFO_HEAD_G_A             UINT8_C(0x8C)
00522 #define BMI160_FIFO_HEAD_M               UINT8_C(0x90)
00523 #define BMI160_FIFO_HEAD_M_A             UINT8_C(0x94)
00524 #define BMI160_FIFO_HEAD_M_G             UINT8_C(0x98)
00525 #define BMI160_FIFO_HEAD_M_G_A           UINT8_C(0x9C)
00526 
00527 
00528 /** FIFO sensor time length definitions */
00529 #define BMI160_SENSOR_TIME_LENGTH        UINT8_C(3)
00530 
00531 
00532 /** FIFO DOWN selection */
00533 /* Accel fifo down-sampling values*/
00534 #define  BMI160_ACCEL_FIFO_DOWN_ZERO     UINT8_C(0x00)
00535 #define  BMI160_ACCEL_FIFO_DOWN_ONE      UINT8_C(0x10)
00536 #define  BMI160_ACCEL_FIFO_DOWN_TWO      UINT8_C(0x20)
00537 #define  BMI160_ACCEL_FIFO_DOWN_THREE    UINT8_C(0x30)
00538 #define  BMI160_ACCEL_FIFO_DOWN_FOUR     UINT8_C(0x40)
00539 #define  BMI160_ACCEL_FIFO_DOWN_FIVE     UINT8_C(0x50)
00540 #define  BMI160_ACCEL_FIFO_DOWN_SIX      UINT8_C(0x60)
00541 #define  BMI160_ACCEL_FIFO_DOWN_SEVEN    UINT8_C(0x70)
00542 
00543 /* Gyro fifo down-smapling values*/
00544 #define  BMI160_GYRO_FIFO_DOWN_ZERO      UINT8_C(0x00)
00545 #define  BMI160_GYRO_FIFO_DOWN_ONE       UINT8_C(0x01)
00546 #define  BMI160_GYRO_FIFO_DOWN_TWO       UINT8_C(0x02)
00547 #define  BMI160_GYRO_FIFO_DOWN_THREE     UINT8_C(0x03)
00548 #define  BMI160_GYRO_FIFO_DOWN_FOUR      UINT8_C(0x04)
00549 #define  BMI160_GYRO_FIFO_DOWN_FIVE      UINT8_C(0x05)
00550 #define  BMI160_GYRO_FIFO_DOWN_SIX       UINT8_C(0x06)
00551 #define  BMI160_GYRO_FIFO_DOWN_SEVEN     UINT8_C(0x07)
00552 
00553 /* Accel Fifo filter enable*/
00554 #define  BMI160_ACCEL_FIFO_FILT_EN       UINT8_C(0x80)
00555 
00556 /* Gyro Fifo filter enable*/
00557 #define  BMI160_GYRO_FIFO_FILT_EN        UINT8_C(0x08)
00558 
00559 /** Definitions to check validity of FIFO frames */
00560 #define FIFO_CONFIG_MSB_CHECK            UINT8_C(0x80)
00561 #define FIFO_CONFIG_LSB_CHECK            UINT8_C(0x00)
00562 
00563 /*! BMI160 accel FOC configurations */
00564 #define BMI160_FOC_ACCEL_DISABLED        UINT8_C(0x00)
00565 #define BMI160_FOC_ACCEL_POSITIVE_G      0x01
00566 #define BMI160_FOC_ACCEL_NEGATIVE_G      0x02
00567 #define BMI160_FOC_ACCEL_0G              0x03
00568 
00569 /** Array Parameter DefinItions */
00570 #define BMI160_SENSOR_TIME_LSB_BYTE      UINT8_C(0)
00571 #define BMI160_SENSOR_TIME_XLSB_BYTE     UINT8_C(1)
00572 #define BMI160_SENSOR_TIME_MSB_BYTE      UINT8_C(2)
00573 
00574 
00575 /** Interface settings */
00576 #define BMI160_SPI_INTF                  UINT8_C(1)
00577 #define BMI160_I2C_INTF                  UINT8_C(0)
00578 #define BMI160_SPI_RD_MASK               UINT8_C(0x80)
00579 #define BMI160_SPI_WR_MASK               UINT8_C(0x7F)
00580 
00581 /* Sensor & time select definition*/
00582 #define BMI160_ACCEL_SEL        UINT8_C(0x01)
00583 #define BMI160_GYRO_SEL         UINT8_C(0x02)
00584 #define BMI160_TIME_SEL         UINT8_C(0x04)
00585 
00586 /* Sensor select mask*/
00587 #define BMI160_SEN_SEL_MASK     UINT8_C(0x07)
00588 
00589 /* Error code mask */
00590 #define BMI160_ERR_REG_MASK     UINT8_C(0x0F)
00591 
00592 /* BMI160 I2C address */
00593 #define BMI160_I2C_ADDR                 UINT8_C(0x68)
00594 
00595 /* BMI160 secondary IF address */
00596 #define BMI160_AUX_BMM150_I2C_ADDR      UINT8_C(0x10)
00597 
00598 /** BMI160 Length definitions */
00599 #define BMI160_ONE                       UINT8_C(1)
00600 #define BMI160_TWO                       UINT8_C(2)
00601 #define BMI160_THREE                     UINT8_C(3)
00602 #define BMI160_FOUR                      UINT8_C(4)
00603 #define BMI160_FIVE                      UINT8_C(5)
00604 
00605 /** BMI160 fifo level Margin */
00606 #define BMI160_FIFO_LEVEL_MARGIN         UINT8_C(16)
00607 
00608 /** BMI160 fifo flush Command */
00609 #define BMI160_FIFO_FLUSH_VALUE          UINT8_C(0xB0)
00610 
00611 /** BMI160 offset values for xyz axes of accel */
00612 #define BMI160_ACCEL_MIN_OFFSET         INT8_C(-128)
00613 #define BMI160_ACCEL_MAX_OFFSET         INT8_C(127)
00614 
00615 /** BMI160 offset values for xyz axes of gyro */
00616 #define BMI160_GYRO_MIN_OFFSET         INT16_C(-512)
00617 #define BMI160_GYRO_MAX_OFFSET         INT16_C(511)
00618 
00619 /** BMI160 fifo full interrupt position and mask */
00620 #define BMI160_FIFO_FULL_INT_POS    UINT8_C(5)
00621 #define BMI160_FIFO_FULL_INT_MSK    UINT8_C(0x20)
00622 #define BMI160_FIFO_WTM_INT_POS     UINT8_C(6)
00623 #define BMI160_FIFO_WTM_INT_MSK     UINT8_C(0x40)
00624 
00625 #define BMI160_FIFO_FULL_INT_PIN1_POS   UINT8_C(5)
00626 #define BMI160_FIFO_FULL_INT_PIN1_MSK   UINT8_C(0x20)
00627 #define BMI160_FIFO_FULL_INT_PIN2_POS   UINT8_C(1)
00628 #define BMI160_FIFO_FULL_INT_PIN2_MSK   UINT8_C(0x02)
00629 
00630 #define BMI160_FIFO_WTM_INT_PIN1_POS    UINT8_C(6)
00631 #define BMI160_FIFO_WTM_INT_PIN1_MSK    UINT8_C(0x40)
00632 #define BMI160_FIFO_WTM_INT_PIN2_POS    UINT8_C(2)
00633 #define BMI160_FIFO_WTM_INT_PIN2_MSK    UINT8_C(0x04)
00634 
00635 #define BMI160_MANUAL_MODE_EN_POS   UINT8_C(7)
00636 #define BMI160_MANUAL_MODE_EN_MSK   UINT8_C(0x80)
00637 #define BMI160_AUX_READ_BURST_POS   UINT8_C(0)
00638 #define BMI160_AUX_READ_BURST_MSK   UINT8_C(0x03)
00639 
00640 #define BMI160_GYRO_SELF_TEST_POS   UINT8_C(4)
00641 #define BMI160_GYRO_SELF_TEST_MSK   UINT8_C(0x10)
00642 #define BMI160_GYRO_SELF_TEST_STATUS_POS    UINT8_C(1)
00643 #define BMI160_GYRO_SELF_TEST_STATUS_MSK    UINT8_C(0x02)
00644 
00645 #define BMI160_GYRO_FOC_EN_POS  UINT8_C(6)
00646 #define BMI160_GYRO_FOC_EN_MSK  UINT8_C(0x40)
00647 
00648 #define BMI160_ACCEL_FOC_X_CONF_POS UINT8_C(4)
00649 #define BMI160_ACCEL_FOC_X_CONF_MSK UINT8_C(0x30)
00650 
00651 #define BMI160_ACCEL_FOC_Y_CONF_POS UINT8_C(2)
00652 #define BMI160_ACCEL_FOC_Y_CONF_MSK UINT8_C(0x0C)
00653 
00654 #define BMI160_ACCEL_FOC_Z_CONF_MSK UINT8_C(0x03)
00655 
00656 #define BMI160_FOC_STATUS_POS   UINT8_C(3)
00657 #define BMI160_FOC_STATUS_MSK   UINT8_C(0x08)
00658 
00659 #define BMI160_GYRO_OFFSET_X_MSK    UINT8_C(0x03)
00660 
00661 #define BMI160_GYRO_OFFSET_Y_POS    UINT8_C(2)
00662 #define BMI160_GYRO_OFFSET_Y_MSK    UINT8_C(0x0C)
00663 
00664 #define BMI160_GYRO_OFFSET_Z_POS    UINT8_C(4)
00665 #define BMI160_GYRO_OFFSET_Z_MSK    UINT8_C(0x30)
00666 
00667 #define BMI160_GYRO_OFFSET_EN_POS   UINT8_C(7)
00668 #define BMI160_GYRO_OFFSET_EN_MSK   UINT8_C(0x80)
00669 
00670 #define BMI160_ACCEL_OFFSET_EN_POS  UINT8_C(6)
00671 #define BMI160_ACCEL_OFFSET_EN_MSK  UINT8_C(0x40)
00672 
00673 #define BMI160_GYRO_OFFSET_POS          UINT16_C(8)
00674 #define BMI160_GYRO_OFFSET_MSK          UINT16_C(0x0300)
00675 
00676 #define BMI160_NVM_UPDATE_POS           UINT8_C(1)
00677 #define BMI160_NVM_UPDATE_MSK           UINT8_C(0x02)
00678 
00679 #define BMI160_NVM_STATUS_POS           UINT8_C(4)
00680 #define BMI160_NVM_STATUS_MSK           UINT8_C(0x10)
00681 
00682 #define BMI160_MAG_POWER_MODE_MSK       UINT8_C(0x03)
00683 
00684 #define BMI160_ACCEL_POWER_MODE_MSK     UINT8_C(0x30)
00685 #define BMI160_ACCEL_POWER_MODE_POS     UINT8_C(4)
00686 
00687 #define BMI160_GYRO_POWER_MODE_MSK      UINT8_C(0x0C)
00688 #define BMI160_GYRO_POWER_MODE_POS      UINT8_C(2)
00689 
00690 
00691 /* BIT SLICE GET AND SET FUNCTIONS */
00692 #define BMI160_GET_BITS(regvar, bitname)\
00693         ((regvar & bitname##_MSK) >> bitname##_POS)
00694 #define BMI160_SET_BITS(regvar, bitname, val)\
00695         ((regvar & ~bitname##_MSK) | \
00696         ((val<<bitname##_POS)&bitname##_MSK))
00697 
00698 #define BMI160_SET_BITS_POS_0(reg_data, bitname, data) \
00699                 ((reg_data & ~(bitname##_MSK)) | \
00700                 (data & bitname##_MSK))
00701 
00702 #define BMI160_GET_BITS_POS_0(reg_data, bitname)  (reg_data & (bitname##_MSK))
00703 
00704 /**\name UTILITY MACROS */
00705 #define BMI160_SET_LOW_BYTE     UINT16_C(0x00FF)
00706 #define BMI160_SET_HIGH_BYTE    UINT16_C(0xFF00)
00707 
00708 #define BMI160_GET_LSB(var) (uint8_t)(var & BMI160_SET_LOW_BYTE)
00709 #define BMI160_GET_MSB(var) (uint8_t)((var & BMI160_SET_HIGH_BYTE) >> 8)
00710 
00711 /*****************************************************************************/
00712 /* type definitions */
00713 typedef int8_t (*bmi160_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr,
00714         uint8_t *data, uint16_t len);
00715 
00716 typedef void (*bmi160_delay_fptr_t)(uint32_t period);
00717 
00718 /*************************** Data structures *********************************/
00719 
00720 struct bmi160_pmu_status {
00721     /*! Power mode status of Accel
00722      * Possible values :
00723      *  - BMI160_ACCEL_PMU_SUSPEND
00724      *  - BMI160_ACCEL_PMU_NORMAL
00725      *  - BMI160_ACCEL_PMU_LOW_POWER
00726      */
00727     uint8_t accel_pmu_status;
00728     /*! Power mode status of Gyro
00729      * Possible values :
00730      *  - BMI160_GYRO_PMU_SUSPEND
00731      *  - BMI160_GYRO_PMU_NORMAL
00732      *  - BMI160_GYRO_PMU_FSU
00733      */
00734     uint8_t gyro_pmu_status;
00735     /*! Power mode status of 'Auxiliary sensor interface' whereas the actual
00736      *  power mode of the aux. sensor should be configured
00737      *  according to the connected sensor specifications
00738      * Possible values :
00739      *  - BMI160_AUX_PMU_SUSPEND
00740      *  - BMI160_AUX_PMU_NORMAL
00741      *  - BMI160_AUX_PMU_LOW_POWER
00742      */
00743     uint8_t aux_pmu_status;
00744 };
00745 /*!
00746  * @brief bmi160 interrupt status selection enum.
00747  */
00748 enum bmi160_int_status_sel {
00749     BMI160_INT_STATUS_0 = 1,
00750     BMI160_INT_STATUS_1 = 2,
00751     BMI160_INT_STATUS_2 = 4,
00752     BMI160_INT_STATUS_3 = 8,
00753     BMI160_INT_STATUS_ALL = 15
00754 };
00755 
00756 /*!
00757  * @brief bmi160 interrupt status bits structure
00758  */
00759 struct bmi160_int_status_bits {
00760 #if LITTLE_ENDIAN == 1
00761     uint32_t step :1;
00762     uint32_t sigmot :1;
00763     uint32_t anym :1;
00764     /* pmu trigger will be handled later */
00765     uint32_t pmu_trigger_reserved :1;
00766     uint32_t d_tap :1;
00767     uint32_t s_tap :1;
00768     uint32_t orient :1;
00769     uint32_t flat_int :1;
00770     uint32_t reserved :2;
00771     uint32_t high_g :1;
00772     uint32_t low_g :1;
00773     uint32_t drdy :1;
00774     uint32_t ffull :1;
00775     uint32_t fwm :1;
00776     uint32_t nomo :1;
00777     uint32_t anym_first_x :1;
00778     uint32_t anym_first_y :1;
00779     uint32_t anym_first_z :1;
00780     uint32_t anym_sign :1;
00781     uint32_t tap_first_x :1;
00782     uint32_t tap_first_y :1;
00783     uint32_t tap_first_z :1;
00784     uint32_t tap_sign :1;
00785     uint32_t high_first_x :1;
00786     uint32_t high_first_y :1;
00787     uint32_t high_first_z :1;
00788     uint32_t high_sign :1;
00789     uint32_t orient_1_0 :2;
00790     uint32_t orient_2 :1;
00791     uint32_t flat :1;
00792 #elif BIG_ENDIAN == 1
00793     uint32_t high_first_x :1;
00794     uint32_t high_first_y :1;
00795     uint32_t high_first_z :1;
00796     uint32_t high_sign :1;
00797     uint32_t orient_1_0 :2;
00798     uint32_t orient_2 :1;
00799     uint32_t flat :1;
00800     uint32_t anym_first_x :1;
00801     uint32_t anym_first_y :1;
00802     uint32_t anym_first_z :1;
00803     uint32_t anym_sign :1;
00804     uint32_t tap_first_x :1;
00805     uint32_t tap_first_y :1;
00806     uint32_t tap_first_z :1;
00807     uint32_t tap_sign :1;
00808     uint32_t reserved :2;
00809     uint32_t high_g :1;
00810     uint32_t low_g :1;
00811     uint32_t drdy :1;
00812     uint32_t ffull :1;
00813     uint32_t fwm :1;
00814     uint32_t nomo :1;
00815     uint32_t step :1;
00816     uint32_t sigmot :1;
00817     uint32_t anym :1;
00818     /* pmu trigger will be handled later */
00819     uint32_t pmu_trigger_reserved :1;
00820     uint32_t d_tap :1;
00821     uint32_t s_tap :1;
00822     uint32_t orient :1;
00823     uint32_t flat_int :1;
00824 #endif
00825 };
00826 
00827 /*!
00828  * @brief bmi160 interrupt status structure
00829  */
00830 union bmi160_int_status {
00831     uint8_t data[4];
00832     struct bmi160_int_status_bits bit;
00833 };
00834 
00835 /*!
00836  * @brief bmi160 sensor data structure which comprises of accel data
00837  */
00838 struct bmi160_sensor_data {
00839     /*! X-axis sensor data */
00840     int16_t x ;
00841     /*! Y-axis sensor data */
00842     int16_t y ;
00843     /*! Z-axis sensor data */
00844     int16_t z ;
00845     /*! sensor time */
00846     uint32_t sensortime ;
00847 };
00848 
00849 /*!
00850  * @brief bmi160 aux data structure which comprises of 8 bytes of accel data
00851  */
00852 struct bmi160_aux_data {
00853     /*! Auxiliary data */
00854     uint8_t data [8];
00855 };
00856 
00857 /*!
00858  * @brief bmi160 FOC configuration structure
00859  */
00860 struct bmi160_foc_conf {
00861     /*! Enabling FOC in gyro
00862      * Assignable macros :
00863      *  - BMI160_ENABLE
00864      *  - BMI160_DISABLE
00865      */
00866     uint8_t foc_gyr_en ;
00867 
00868     /*! Accel FOC configurations
00869      * Assignable macros :
00870      *  - BMI160_FOC_ACCEL_DISABLED
00871      *  - BMI160_FOC_ACCEL_POSITIVE_G
00872      *  - BMI160_FOC_ACCEL_NEGATIVE_G
00873      *  - BMI160_FOC_ACCEL_0G
00874      */
00875     uint8_t foc_acc_x ;
00876     uint8_t foc_acc_y;
00877     uint8_t foc_acc_z;
00878 
00879     /*! Enabling offset compensation for accel in data registers
00880      * Assignable macros :
00881      *  - BMI160_ENABLE
00882      *  - BMI160_DISABLE
00883      */
00884     uint8_t acc_off_en ;
00885 
00886     /*! Enabling offset compensation for gyro in data registers
00887      * Assignable macros :
00888      *  - BMI160_ENABLE
00889      *  - BMI160_DISABLE
00890      */
00891     uint8_t gyro_off_en ;
00892 };
00893 
00894 /*!
00895  * @brief bmi160 accel gyro offsets
00896  */
00897 struct bmi160_offsets {
00898     /*! Accel offset for x axis */
00899     int8_t off_acc_x ;
00900     /*! Accel offset for y axis */
00901     int8_t off_acc_y ;
00902     /*! Accel offset for z axis */
00903     int8_t off_acc_z ;
00904     /*! Gyro offset for x axis */
00905     int16_t off_gyro_x ;
00906     /*! Gyro offset for y axis */
00907     int16_t off_gyro_y ;
00908     /*! Gyro offset for z axis */
00909     int16_t off_gyro_z ;
00910 };
00911 
00912 /*!
00913  * @brief FIFO aux. sensor data structure
00914  */
00915 struct bmi160_aux_fifo_data {
00916     /*! The value of aux. sensor x LSB data */
00917     uint8_t aux_x_lsb ;
00918     /*! The value of aux. sensor x MSB data */
00919     uint8_t aux_x_msb ;
00920     /*! The value of aux. sensor y LSB data */
00921     uint8_t aux_y_lsb ;
00922     /*! The value of aux. sensor y MSB data */
00923     uint8_t aux_y_msb ;
00924     /*! The value of aux. sensor z LSB data */
00925     uint8_t aux_z_lsb ;
00926     /*! The value of aux. sensor z MSB data */
00927     uint8_t aux_z_msb ;
00928     /*! The value of aux. sensor r for BMM150 LSB data */
00929     uint8_t aux_r_y2_lsb ;
00930     /*! The value of aux. sensor r for BMM150 MSB data */
00931     uint8_t aux_r_y2_msb ;
00932 };
00933 
00934 /*!
00935  * @brief bmi160 sensor select structure
00936  */
00937 enum bmi160_select_sensor {
00938     BMI160_ACCEL_ONLY = 1,
00939     BMI160_GYRO_ONLY,
00940     BMI160_BOTH_ACCEL_AND_GYRO
00941 };
00942 
00943 /*!
00944  * @brief bmi160 sensor step detector mode structure
00945  */
00946 enum bmi160_step_detect_mode {
00947     BMI160_STEP_DETECT_NORMAL,
00948     BMI160_STEP_DETECT_SENSITIVE,
00949     BMI160_STEP_DETECT_ROBUST,
00950     /*! Non recommended User defined setting */
00951     BMI160_STEP_DETECT_USER_DEFINE 
00952 };
00953 
00954 /*!
00955  * @brief enum for auxiliary burst read selection
00956  */
00957 enum bm160_aux_read_len {
00958     BMI160_AUX_READ_LEN_0,
00959     BMI160_AUX_READ_LEN_1,
00960     BMI160_AUX_READ_LEN_2,
00961     BMI160_AUX_READ_LEN_3
00962 };
00963 /*!
00964  * @brief bmi160 sensor configuration structure
00965  */
00966 struct bmi160_cfg {
00967     /*! power mode */
00968     uint8_t power ;
00969     /*! output data rate */
00970     uint8_t odr ;
00971     /*! range */
00972     uint8_t range ;
00973     /*! bandwidth */
00974     uint8_t bw ;
00975 };
00976 
00977 /*!
00978  * @brief Aux sensor configuration structure
00979  */
00980 struct bmi160_aux_cfg {
00981     /*! Aux sensor, 1 - enable 0 - disable */
00982     uint8_t aux_sensor_enable  : 1;
00983     /*! Aux manual/auto mode status */
00984     uint8_t manual_enable  : 1;
00985     /*! Aux read burst length */
00986     uint8_t aux_rd_burst_len  : 2;
00987     /*! output data rate */
00988     uint8_t aux_odr  :4;
00989     /*! i2c addr of auxiliary sensor */
00990     uint8_t aux_i2c_addr ;
00991 };
00992 
00993 /*!
00994  * @brief bmi160 interrupt channel selection structure
00995  */
00996 enum bmi160_int_channel {
00997     /*! Un-map both channels */
00998     BMI160_INT_CHANNEL_NONE ,
00999     /*! interrupt Channel 1 */
01000     BMI160_INT_CHANNEL_1 ,
01001     /*! interrupt Channel 2 */
01002     BMI160_INT_CHANNEL_2 ,
01003     /*! Map both channels */
01004     BMI160_INT_CHANNEL_BOTH 
01005 };
01006 
01007 enum bmi160_int_types  {
01008     /*! Slope/Any-motion interrupt */
01009     BMI160_ACC_ANY_MOTION_INT ,
01010     /*! Significant motion interrupt */
01011     BMI160_ACC_SIG_MOTION_INT ,
01012     /*! Step detector interrupt */
01013     BMI160_STEP_DETECT_INT ,
01014     /*! double tap interrupt */
01015     BMI160_ACC_DOUBLE_TAP_INT ,
01016     /*! single tap interrupt */
01017     BMI160_ACC_SINGLE_TAP_INT ,
01018     /*! orientation interrupt */
01019     BMI160_ACC_ORIENT_INT ,
01020     /*! flat interrupt */
01021     BMI160_ACC_FLAT_INT ,
01022     /*! high-g interrupt */
01023     BMI160_ACC_HIGH_G_INT ,
01024     /*! low-g interrupt */
01025     BMI160_ACC_LOW_G_INT ,
01026     /*! slow/no-motion interrupt */
01027     BMI160_ACC_SLOW_NO_MOTION_INT ,
01028     /*! data ready interrupt  */
01029     BMI160_ACC_GYRO_DATA_RDY_INT ,
01030     /*! fifo full interrupt */
01031     BMI160_ACC_GYRO_FIFO_FULL_INT ,
01032     /*! fifo watermark interrupt */
01033     BMI160_ACC_GYRO_FIFO_WATERMARK_INT ,
01034     /*! fifo tagging feature support */
01035     BMI160_FIFO_TAG_INT_PIN 
01036 };
01037 
01038 /*!
01039  * @brief bmi160 active state of any & sig motion interrupt.
01040  */
01041 enum bmi160_any_sig_motion_active_interrupt_state {
01042     /*! Both any & sig motion are disabled */
01043     BMI160_BOTH_ANY_SIG_MOTION_DISABLED  = -1,
01044     /*! Any-motion selected */
01045     BMI160_ANY_MOTION_ENABLED ,
01046     /*! Sig-motion selected */
01047     BMI160_SIG_MOTION_ENABLED 
01048 };
01049 
01050 struct bmi160_acc_tap_int_cfg {
01051 #if LITTLE_ENDIAN == 1
01052     /*! tap threshold */
01053     uint16_t tap_thr :5;
01054     /*! tap shock */
01055     uint16_t tap_shock :1;
01056     /*! tap quiet */
01057     uint16_t tap_quiet :1;
01058     /*! tap duration */
01059     uint16_t tap_dur :3;
01060     /*! data source 0- filter & 1 pre-filter*/
01061     uint16_t tap_data_src :1;
01062     /*! tap enable, 1 - enable, 0 - disable */
01063     uint16_t tap_en :1;
01064 #elif BIG_ENDIAN == 1
01065     /*! tap enable, 1 - enable, 0 - disable */
01066     uint16_t tap_en :1;
01067     /*! data source 0- filter & 1 pre-filter*/
01068     uint16_t tap_data_src :1;
01069     /*! tap duration */
01070     uint16_t tap_dur : 3;
01071     /*! tap quiet */
01072     uint16_t tap_quiet : 1;
01073     /*! tap shock */
01074     uint16_t tap_shock : 1;
01075     /*! tap threshold */
01076     uint16_t tap_thr : 5;
01077 #endif
01078 };
01079 
01080 struct bmi160_acc_any_mot_int_cfg {
01081 #if LITTLE_ENDIAN == 1
01082     /*! 1 any-motion enable, 0 - any-motion disable */
01083     uint8_t anymotion_en :1;
01084     /*! slope interrupt x, 1 - enable, 0 - disable */
01085     uint8_t anymotion_x :1;
01086     /*! slope interrupt y, 1 - enable, 0 - disable */
01087     uint8_t anymotion_y :1;
01088     /*! slope interrupt z, 1 - enable, 0 - disable */
01089     uint8_t anymotion_z :1;
01090     /*! slope duration */
01091     uint8_t anymotion_dur :2;
01092     /*! data source 0- filter & 1 pre-filter*/
01093     uint8_t anymotion_data_src :1;
01094     /*! slope threshold */
01095     uint8_t anymotion_thr;
01096 #elif BIG_ENDIAN == 1
01097     /*! slope threshold */
01098     uint8_t anymotion_thr;
01099     /*! data source 0- filter & 1 pre-filter*/
01100     uint8_t anymotion_data_src :1;
01101     /*! slope duration */
01102     uint8_t anymotion_dur : 2;
01103     /*! slope interrupt z, 1 - enable, 0 - disable */
01104     uint8_t anymotion_z : 1;
01105     /*! slope interrupt y, 1 - enable, 0 - disable */
01106     uint8_t anymotion_y : 1;
01107     /*! slope interrupt x, 1 - enable, 0 - disable */
01108     uint8_t anymotion_x : 1;
01109     /*! 1 any-motion enable, 0 - any-motion disable */
01110     uint8_t anymotion_en :1;
01111 #endif
01112 };
01113 
01114 struct bmi160_acc_sig_mot_int_cfg {
01115 #if LITTLE_ENDIAN == 1
01116     /*! skip time of sig-motion interrupt */
01117     uint8_t sig_mot_skip :2;
01118     /*! proof time of sig-motion interrupt */
01119     uint8_t sig_mot_proof :2;
01120     /*! data source 0- filter & 1 pre-filter*/
01121     uint8_t sig_data_src :1;
01122     /*! 1 - enable sig, 0 - disable sig & enable anymotion */
01123     uint8_t sig_en :1;
01124     /*! sig-motion threshold */
01125     uint8_t sig_mot_thres;
01126 #elif BIG_ENDIAN == 1
01127     /*! sig-motion threshold */
01128     uint8_t sig_mot_thres;
01129     /*! 1 - enable sig, 0 - disable sig & enable anymotion */
01130     uint8_t sig_en :1;
01131     /*! data source 0- filter & 1 pre-filter*/
01132     uint8_t sig_data_src :1;
01133     /*! proof time of sig-motion interrupt */
01134     uint8_t sig_mot_proof : 2;
01135     /*! skip time of sig-motion interrupt */
01136     uint8_t sig_mot_skip : 2;
01137 #endif
01138 };
01139 
01140 struct bmi160_acc_step_detect_int_cfg {
01141 #if LITTLE_ENDIAN == 1
01142     /*! 1- step detector enable, 0- step detector disable */
01143     uint16_t step_detector_en :1;
01144     /*! minimum threshold */
01145     uint16_t min_threshold :2;
01146     /*! minimal detectable step time */
01147     uint16_t steptime_min :3;
01148     /*! enable step counter mode setting */
01149     uint16_t step_detector_mode :2;
01150     /*! minimum step buffer size*/
01151     uint16_t step_min_buf :3;
01152 #elif BIG_ENDIAN == 1
01153     /*! minimum step buffer size*/
01154     uint16_t step_min_buf :3;
01155     /*! enable step counter mode setting */
01156     uint16_t step_detector_mode : 2;
01157     /*! minimal detectable step time */
01158     uint16_t steptime_min : 3;
01159     /*! minimum threshold */
01160     uint16_t min_threshold : 2;
01161     /*! 1- step detector enable, 0- step detector disable */
01162     uint16_t step_detector_en :1;
01163 #endif
01164 };
01165 
01166 struct bmi160_acc_no_motion_int_cfg {
01167 #if LITTLE_ENDIAN == 1
01168     /*! no motion interrupt x */
01169     uint16_t no_motion_x :1;
01170     /*! no motion interrupt y */
01171     uint16_t no_motion_y :1;
01172     /*! no motion interrupt z */
01173     uint16_t no_motion_z :1;
01174     /*! no motion duration */
01175     uint16_t no_motion_dur :6;
01176     /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
01177     uint16_t no_motion_sel :1;
01178     /*! data source 0- filter & 1 pre-filter*/
01179     uint16_t no_motion_src :1;
01180     /*! no motion threshold */
01181     uint8_t no_motion_thres;
01182 #elif BIG_ENDIAN == 1
01183     /*! no motion threshold */
01184     uint8_t no_motion_thres;
01185     /*! data source 0- filter & 1 pre-filter*/
01186     uint16_t no_motion_src :1;
01187     /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
01188     uint16_t no_motion_sel : 1;
01189     /*! no motion duration */
01190     uint16_t no_motion_dur : 6;
01191     /* no motion interrupt z */
01192     uint16_t no_motion_z :1;
01193     /*! no motion interrupt y */
01194     uint16_t no_motion_y :1;
01195     /*! no motion interrupt x */
01196     uint16_t no_motion_x :1;
01197 #endif
01198 };
01199 
01200 struct bmi160_acc_orient_int_cfg {
01201 #if LITTLE_ENDIAN == 1
01202     /*! thresholds for switching between the different orientations */
01203     uint16_t orient_mode :2;
01204     /*! blocking_mode */
01205     uint16_t orient_blocking :2;
01206     /*! Orientation interrupt hysteresis */
01207     uint16_t orient_hyst :4;
01208     /*! Orientation interrupt theta */
01209     uint16_t orient_theta :6;
01210     /*! Enable/disable Orientation interrupt */
01211     uint16_t orient_ud_en :1;
01212     /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
01213     uint16_t axes_ex :1;
01214     /*! 1 - orient enable, 0 - orient disable */
01215     uint8_t orient_en :1;
01216 #elif BIG_ENDIAN == 1
01217     /*! 1 - orient enable, 0 - orient disable */
01218     uint8_t orient_en :1;
01219     /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
01220     uint16_t axes_ex : 1;
01221     /*! Enable/disable Orientation interrupt */
01222     uint16_t orient_ud_en : 1;
01223     /*! Orientation interrupt theta */
01224     uint16_t orient_theta : 6;
01225     /*! Orientation interrupt hysteresis */
01226     uint16_t orient_hyst : 4;
01227     /*! blocking_mode */
01228     uint16_t orient_blocking : 2;
01229     /*! thresholds for switching between the different orientations */
01230     uint16_t orient_mode : 2;
01231 #endif
01232 };
01233 
01234 struct bmi160_acc_flat_detect_int_cfg {
01235 #if LITTLE_ENDIAN == 1
01236     /*! flat threshold */
01237     uint16_t flat_theta :6;
01238     /*! flat interrupt hysteresis */
01239     uint16_t flat_hy :3;
01240     /*! delay time for which the flat value must remain stable for the
01241      * flat interrupt to be generated */
01242     uint16_t flat_hold_time :2;
01243     /*! 1 - flat enable, 0 - flat disable */
01244     uint16_t flat_en :1;
01245 #elif BIG_ENDIAN == 1
01246     /*! 1 - flat enable, 0 - flat disable */
01247     uint16_t flat_en :1;
01248     /*! delay time for which the flat value must remain stable for the
01249      * flat interrupt to be generated */
01250     uint16_t flat_hold_time : 2;
01251     /*! flat interrupt hysteresis */
01252     uint16_t flat_hy : 3;
01253     /*! flat threshold */
01254     uint16_t flat_theta : 6;
01255 #endif
01256 };
01257 
01258 struct bmi160_acc_low_g_int_cfg {
01259 #if LITTLE_ENDIAN == 1
01260     /*! low-g interrupt trigger delay */
01261     uint8_t low_dur;
01262     /*! low-g interrupt trigger threshold */
01263     uint8_t low_thres;
01264     /*! hysteresis of low-g interrupt */
01265     uint8_t low_hyst :2;
01266     /*! 0 - single-axis mode ,1 - axis-summing mode */
01267     uint8_t low_mode :1;
01268     /*! data source 0- filter & 1 pre-filter */
01269     uint8_t low_data_src :1;
01270     /*! 1 - enable low-g, 0 - disable low-g */
01271     uint8_t low_en :1;
01272 #elif BIG_ENDIAN == 1
01273     /*! 1 - enable low-g, 0 - disable low-g */
01274     uint8_t low_en :1;
01275     /*! data source 0- filter & 1 pre-filter */
01276     uint8_t low_data_src :1;
01277     /*! 0 - single-axis mode ,1 - axis-summing mode */
01278     uint8_t low_mode : 1;
01279     /*! hysteresis of low-g interrupt */
01280     uint8_t low_hyst : 2;
01281     /*! low-g interrupt trigger threshold */
01282     uint8_t low_thres;
01283     /*! low-g interrupt trigger delay */
01284     uint8_t low_dur;
01285 #endif
01286 };
01287 
01288 struct bmi160_acc_high_g_int_cfg {
01289 #if LITTLE_ENDIAN == 1
01290     /*! High-g interrupt x, 1 - enable, 0 - disable */
01291     uint8_t high_g_x :1;
01292     /*! High-g interrupt y, 1 - enable, 0 - disable */
01293     uint8_t high_g_y :1;
01294     /*! High-g interrupt z, 1 - enable, 0 - disable */
01295     uint8_t high_g_z :1;
01296     /*! High-g hysteresis  */
01297     uint8_t high_hy :2;
01298     /*! data source 0- filter & 1 pre-filter */
01299     uint8_t high_data_src :1;
01300     /*! High-g threshold */
01301     uint8_t high_thres;
01302     /*! High-g duration */
01303     uint8_t high_dur;
01304 #elif BIG_ENDIAN == 1
01305     /*! High-g duration */
01306     uint8_t high_dur;
01307     /*! High-g threshold */
01308     uint8_t high_thres;
01309     /*! data source 0- filter & 1 pre-filter */
01310     uint8_t high_data_src :1;
01311     /*! High-g hysteresis  */
01312     uint8_t high_hy : 2;
01313     /*! High-g interrupt z, 1 - enable, 0 - disable */
01314     uint8_t high_g_z : 1;
01315     /*! High-g interrupt y, 1 - enable, 0 - disable */
01316     uint8_t high_g_y : 1;
01317     /*! High-g interrupt x, 1 - enable, 0 - disable */
01318     uint8_t high_g_x : 1;
01319 #endif
01320 };
01321 
01322 struct bmi160_int_pin_settg {
01323 #if LITTLE_ENDIAN == 1
01324     /*! To enable either INT1 or INT2 pin as output.
01325      * 0- output disabled ,1- output enabled */
01326     uint16_t output_en :1;
01327     /*! 0 - push-pull 1- open drain,only valid if output_en is set 1 */
01328     uint16_t output_mode :1;
01329     /*! 0 - active low , 1 - active high level.
01330      * if output_en is 1,this applies to interrupts,else PMU_trigger */
01331     uint16_t output_type :1;
01332     /*! 0 - level trigger , 1 - edge trigger  */
01333     uint16_t edge_ctrl :1;
01334     /*! To enable either INT1 or INT2 pin as input.
01335      * 0 - input disabled ,1 - input enabled */
01336     uint16_t input_en :1;
01337     /*! latch duration*/
01338     uint16_t latch_dur :4;
01339 #elif BIG_ENDIAN == 1
01340     /*! latch duration*/
01341     uint16_t latch_dur : 4;
01342     /*! Latched,non-latched or temporary interrupt modes */
01343     uint16_t input_en : 1;
01344     /*! 1 - edge trigger, 0 - level trigger */
01345     uint16_t edge_ctrl : 1;
01346     /*! 0 - active low , 1 - active high level.
01347      * if output_en is 1,this applies to interrupts,else PMU_trigger */
01348     uint16_t output_type : 1;
01349     /*! 0 - push-pull , 1 - open drain,only valid if output_en is set 1 */
01350     uint16_t output_mode : 1;
01351     /*! To enable either INT1 or INT2 pin as output.
01352      * 0 - output disabled , 1 - output enabled */
01353     uint16_t output_en : 1;
01354 #endif
01355 };
01356 
01357 union bmi160_int_type_cfg {
01358     /*! Tap interrupt structure */
01359     struct bmi160_acc_tap_int_cfg acc_tap_int;
01360     /*! Slope interrupt structure */
01361     struct bmi160_acc_any_mot_int_cfg acc_any_motion_int;
01362     /*! Significant motion interrupt structure */
01363     struct bmi160_acc_sig_mot_int_cfg acc_sig_motion_int;
01364     /*! Step detector interrupt structure */
01365     struct bmi160_acc_step_detect_int_cfg acc_step_detect_int;
01366     /*! No motion interrupt structure */
01367     struct bmi160_acc_no_motion_int_cfg acc_no_motion_int;
01368     /*! Orientation interrupt structure */
01369     struct bmi160_acc_orient_int_cfg acc_orient_int;
01370     /*! Flat interrupt structure */
01371     struct bmi160_acc_flat_detect_int_cfg acc_flat_int;
01372     /*! Low-g interrupt structure */
01373     struct bmi160_acc_low_g_int_cfg acc_low_g_int;
01374     /*! High-g interrupt structure */
01375     struct bmi160_acc_high_g_int_cfg acc_high_g_int;
01376 };
01377 
01378 struct bmi160_int_settg {
01379     /*! Interrupt channel */
01380     enum bmi160_int_channel int_channel;
01381     /*! Select Interrupt */
01382     enum bmi160_int_types  int_type;
01383     /*! Structure configuring Interrupt pins */
01384     struct bmi160_int_pin_settg int_pin_settg;
01385     /*! Union configures required interrupt */
01386     union bmi160_int_type_cfg int_type_cfg;
01387     /*! FIFO FULL INT 1-enable, 0-disable */
01388     uint8_t fifo_full_int_en :1;
01389     /*! FIFO WTM INT 1-enable, 0-disable */
01390     uint8_t fifo_WTM_int_en :1;
01391 };
01392 
01393 /*!
01394  *  @brief This structure holds the information for usage of
01395  *  FIFO by the user.
01396  */
01397 struct bmi160_fifo_frame {
01398     /*! Data buffer of user defined length is to be mapped here */
01399     uint8_t *data ;
01400     /*! While calling the API  "bmi160_get_fifo_data" , length stores
01401      *  number of bytes in FIFO to be read (specified by user as input)
01402      *  and after execution of the API ,number of FIFO data bytes
01403      *  available is provided as an output to user
01404      */
01405     uint16_t length ;
01406     /*! FIFO time enable */
01407     uint8_t fifo_time_enable ;
01408     /*! Enabling of the FIFO header to stream in header mode */
01409     uint8_t fifo_header_enable ;
01410     /*! Streaming of the Accelerometer, Gyroscope
01411     sensor data or both in FIFO */
01412     uint8_t fifo_data_enable ;
01413     /*! Will be equal to length when no more frames are there to parse */
01414     uint16_t accel_byte_start_idx ;
01415     /*! Will be equal to length when no more frames are there to parse */
01416     uint16_t gyro_byte_start_idx ;
01417     /*! Will be equal to length when no more frames are there to parse */
01418     uint16_t aux_byte_start_idx ;
01419     /*! Value of FIFO sensor time time */
01420     uint32_t sensor_time ;
01421     /*! Value of Skipped frame counts */
01422     uint8_t skipped_frame_count ;
01423 };
01424 
01425 struct bmi160_dev {
01426     /*! Chip Id */
01427     uint8_t chip_id;
01428     /*! Device Id */
01429     uint8_t id;
01430     /*! 0 - I2C , 1 - SPI Interface */
01431     uint8_t interface;
01432     /*! Hold active interrupts status for any and sig motion
01433      *  0 - Any-motion enable, 1 - Sig-motion enable,
01434      *  -1 neither any-motion nor sig-motion selected */
01435     enum bmi160_any_sig_motion_active_interrupt_state any_sig_sel;
01436     /*! Structure to configure Accel sensor */
01437     struct bmi160_cfg accel_cfg;
01438     /*! Structure to hold previous/old accel config parameters.
01439      * This is used at driver level to prevent overwriting of same
01440      * data, hence user does not change it in the code */
01441     struct bmi160_cfg prev_accel_cfg;
01442     /*! Structure to configure Gyro sensor */
01443     struct bmi160_cfg gyro_cfg;
01444     /*! Structure to hold previous/old gyro config parameters.
01445      * This is used at driver level to prevent overwriting of same
01446      * data, hence user does not change it in the code */
01447     struct bmi160_cfg prev_gyro_cfg;
01448     /*! Structure to configure the auxiliary sensor */
01449     struct bmi160_aux_cfg aux_cfg;
01450     /*! Structure to hold previous/old aux config parameters.
01451      * This is used at driver level to prevent overwriting of same
01452      * data, hence user does not change it in the code */
01453     struct bmi160_aux_cfg prev_aux_cfg;
01454      /*! FIFO related configurations */
01455     struct bmi160_fifo_frame *fifo;
01456     /*! Read function pointer */
01457     bmi160_com_fptr_t read;
01458     /*! Write function pointer */
01459     bmi160_com_fptr_t write;
01460     /*!  Delay function pointer */
01461     bmi160_delay_fptr_t delay_ms;
01462 };
01463 
01464 
01465 #endif /* BMI160_DEFS_H_ */