BMI160 Initial

Dependents:   MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_Pitch_Charles Maxim_Squeeks

Committer:
j3
Date:
Fri Dec 09 00:29:29 2016 +0000
Revision:
3:e1770675eca4
Parent:
2:598e601e5846
Child:
4:ebac8c8f6347
Added register enumeration documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:bb5b832891fb 1 /**********************************************************************
j3 0:bb5b832891fb 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:bb5b832891fb 3 *
j3 0:bb5b832891fb 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:bb5b832891fb 5 * copy of this software and associated documentation files (the "Software"),
j3 0:bb5b832891fb 6 * to deal in the Software without restriction, including without limitation
j3 0:bb5b832891fb 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:bb5b832891fb 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:bb5b832891fb 9 * Software is furnished to do so, subject to the following conditions:
j3 0:bb5b832891fb 10 *
j3 0:bb5b832891fb 11 * The above copyright notice and this permission notice shall be included
j3 0:bb5b832891fb 12 * in all copies or substantial portions of the Software.
j3 0:bb5b832891fb 13 *
j3 0:bb5b832891fb 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:bb5b832891fb 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:bb5b832891fb 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:bb5b832891fb 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:bb5b832891fb 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:bb5b832891fb 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:bb5b832891fb 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:bb5b832891fb 21 *
j3 0:bb5b832891fb 22 * Except as contained in this notice, the name of Maxim Integrated
j3 0:bb5b832891fb 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:bb5b832891fb 24 * Products, Inc. Branding Policy.
j3 0:bb5b832891fb 25 *
j3 0:bb5b832891fb 26 * The mere transfer of this software does not imply any licenses
j3 0:bb5b832891fb 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:bb5b832891fb 28 * trademarks, maskwork rights, or any other form of intellectual
j3 0:bb5b832891fb 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:bb5b832891fb 30 * ownership rights.
j3 0:bb5b832891fb 31 **********************************************************************/
j3 0:bb5b832891fb 32
j3 0:bb5b832891fb 33
j3 0:bb5b832891fb 34 #ifndef BMI160_H
j3 0:bb5b832891fb 35 #define BMI160_H
j3 0:bb5b832891fb 36
j3 0:bb5b832891fb 37 #include "mbed.h"
j3 0:bb5b832891fb 38
j3 0:bb5b832891fb 39 /**
j3 0:bb5b832891fb 40 @brief The BMI160 is a small, low power, low noise 16-bit inertial measurement
j3 0:bb5b832891fb 41 unit designed for use in mobile applications like augmented reality or indoor
j3 0:bb5b832891fb 42 navigation which require highly accurate, real-time sensor data.
j3 0:bb5b832891fb 43
j3 0:bb5b832891fb 44 In full operation mode, with both the accelerometer and gyroscope enabled, the
j3 0:bb5b832891fb 45 current consumption is typically 950 μA, enabling always-on applications in
j3 0:bb5b832891fb 46 battery driven devices. It is available in a compact 14-pin 2.5 x 3.0 x 0.8 mm³
j3 0:bb5b832891fb 47 LGA package."
j3 2:598e601e5846 48
j3 2:598e601e5846 49 This class is an abstract base class and can not be instaniated, use BMI160_I2C
j3 2:598e601e5846 50 or BMI160_SPI.
j3 0:bb5b832891fb 51 */
j3 0:bb5b832891fb 52 class BMI160
j3 0:bb5b832891fb 53 {
j3 0:bb5b832891fb 54 public:
j3 0:bb5b832891fb 55
j3 2:598e601e5846 56 ///Return value on success.
j3 3:e1770675eca4 57 static const uint8_t RTN_NO_ERROR = 0;
j3 0:bb5b832891fb 58
j3 1:a4c911640569 59 ///BMI160 registers
j3 0:bb5b832891fb 60 enum Registers
j3 0:bb5b832891fb 61 {
j3 3:e1770675eca4 62 CHIP_ID = 0x00, ///<Chip Identification.
j3 3:e1770675eca4 63 ERR_REG = 0x02, ///<Reports sensor error flags. Flags reset when read.
j3 3:e1770675eca4 64 PMU_STATUS, ///<Reports current power mode for sensors.
j3 3:e1770675eca4 65 DATA_0, ///<MAG_X axis bits7:0
j3 3:e1770675eca4 66 DATA_1, ///<MAG_X axis bits15:8
j3 3:e1770675eca4 67 DATA_2, ///<MAG_Y axis bits7:0
j3 3:e1770675eca4 68 DATA_3, ///<MAG_Y axis bits15:8
j3 3:e1770675eca4 69 DATA_4, ///<MAG_Z axis bits7:0
j3 3:e1770675eca4 70 DATA_5, ///<MAG_Z axis bits15:8
j3 3:e1770675eca4 71 DATA_6, ///<RHALL bits7:0
j3 3:e1770675eca4 72 DATA_7, ///<RHALL bits15:8
j3 3:e1770675eca4 73 DATA_8, ///<GYR_X axis bits7:0
j3 3:e1770675eca4 74 DATA_9, ///<GYR_X axis bits15:8
j3 3:e1770675eca4 75 DATA_10, ///<GYR_Y axis bits7:0
j3 3:e1770675eca4 76 DATA_11, ///<GYR_Y axis bits15:8
j3 3:e1770675eca4 77 DATA_12, ///<GYR_Z axis bits7:0
j3 3:e1770675eca4 78 DATA_13, ///<GYR_Z axis bits15:8
j3 3:e1770675eca4 79 DATA_14, ///<ACC_X axis bits7:0
j3 3:e1770675eca4 80 DATA_15, ///<ACC_X axis bits15:8
j3 3:e1770675eca4 81 DATA_16, ///<ACC_Y axis bits7:0
j3 3:e1770675eca4 82 DATA_17, ///<ACC_Y axis bits15:8
j3 3:e1770675eca4 83 DATA_18, ///<ACC_Z axis bits7:0
j3 3:e1770675eca4 84 DATA_19, ///<ACC_Z axis bits15:8
j3 3:e1770675eca4 85 SENSORTIME_0, ///<24bit counter synchronized with data, bits7:0
j3 3:e1770675eca4 86 SENSORTIME_1, ///<24bit counter synchronized with data, bits15:8
j3 3:e1770675eca4 87 SENSORTIME_2, ///<24bit counter synchronized with data, bits23:16
j3 3:e1770675eca4 88 STATUS, ///<Reports sensors status flags
j3 3:e1770675eca4 89 INT_STATUS_0, ///<Contains interrupt status flags
j3 3:e1770675eca4 90 INT_STATUS_1, ///<Contains interrupt status flags
j3 3:e1770675eca4 91 INT_STATUS_2, ///<Contains interrupt status flags
j3 3:e1770675eca4 92 INT_STATUS_3, ///<Contains interrupt status flags
j3 3:e1770675eca4 93 TEMPERATURE_0, ///<Contains temperature of sensor, bits7:0
j3 3:e1770675eca4 94 TEMPERATURE_1, ///<Contains temperature of sensor, bits15:8
j3 3:e1770675eca4 95 FIFO_LENGTH_0, ///<Current fill level of FIFO, bits7:0
j3 3:e1770675eca4 96 FIFO_LENGTH_1, ///<Current fill level of FIFO, bits10:8
j3 3:e1770675eca4 97 FIFO_DATA, ///<FIFO data read out register, burst read
j3 3:e1770675eca4 98 ACC_CONF = 0x40, ///<Set ODR, bandwidth, and read mode of accelerometer
j3 3:e1770675eca4 99 ACC_RANGE, ///<Sets accelerometer g-range
j3 3:e1770675eca4 100 GYR_CONF, ///<Set ODR, bandwidth, and read mode of gyroscope
j3 3:e1770675eca4 101 GYR_RANGE, ///<Sets gyroscope angular rate measurement range
j3 3:e1770675eca4 102 MAG_CONF, ///<Sets ODR of magnetometer interface
j3 3:e1770675eca4 103 FIFO_DOWNS, ///<Sets down sampling ratios of accel and gyro data
j3 3:e1770675eca4 104 ///<for FIFO
j3 3:e1770675eca4 105 FIFO_CONFIG_0, ///<Sets FIFO Watermark
j3 3:e1770675eca4 106 FIFO_CONFIG_1, ///<Sets which sensor data is available in FIFO,
j3 3:e1770675eca4 107 ///<Header/Headerless mode, Ext Int tagging, Sensortime
j3 3:e1770675eca4 108 MAG_IF_0 = 0x4B, ///<Magnetometer 7-bit I2C address, bits7:1
j3 3:e1770675eca4 109 MAG_IF_1, ///<Magnetometer interface configuration
j3 3:e1770675eca4 110 MAG_IF_2, ///<Magnetometer address to read
j3 3:e1770675eca4 111 MAG_IF_3, ///<Magnetometer address to write
j3 3:e1770675eca4 112 MAG_IF_4, ///<Magnetometer data to write
j3 3:e1770675eca4 113 INT_EN_0, ///<Interrupt enable bits
j3 3:e1770675eca4 114 INT_EN_1, ///<Interrupt enable bits
j3 3:e1770675eca4 115 INT_EN_2, ///<Interrupt enable bits
j3 3:e1770675eca4 116 INT_OUT_CTRL, ///<Contains the behavioral configuration of INT pins
j3 3:e1770675eca4 117 INT_LATCH, ///<Contains the interrupt rest bit and the interrupt
j3 3:e1770675eca4 118 ///<mode selection
j3 3:e1770675eca4 119 INT_MAP_0, ///<Controls which interrupt signals are mapped to the
j3 3:e1770675eca4 120 ///<INT1 and INT2 pins
j3 3:e1770675eca4 121 INT_MAP_1, ///<Controls which interrupt signals are mapped to the
j3 3:e1770675eca4 122 ///<INT1 and INT2 pins
j3 3:e1770675eca4 123 INT_MAP_2, ///<Controls which interrupt signals are mapped to the
j3 3:e1770675eca4 124 ///<INT1 and INT2 pins
j3 3:e1770675eca4 125 INT_DATA_0, ///<Contains the data source definition for the two
j3 3:e1770675eca4 126 ///<interrupt groups
j3 3:e1770675eca4 127 INT_DATA_1, ///<Contains the data source definition for the two
j3 3:e1770675eca4 128 ///<interrupt groups
j3 3:e1770675eca4 129 INT_LOWHIGH_0, ///<Contains the configuration for the low g interrupt
j3 3:e1770675eca4 130 INT_LOWHIGH_1, ///<Contains the configuration for the low g interrupt
j3 3:e1770675eca4 131 INT_LOWHIGH_2, ///<Contains the configuration for the low g interrupt
j3 3:e1770675eca4 132 INT_LOWHIGH_3, ///<Contains the configuration for the low g interrupt
j3 3:e1770675eca4 133 INT_LOWHIGH_4, ///<Contains the configuration for the low g interrupt
j3 3:e1770675eca4 134 INT_MOTION_0, ///<Contains the configuration for the any motion and
j3 3:e1770675eca4 135 ///<no motion interrupts
j3 3:e1770675eca4 136 INT_MOTION_1, ///<Contains the configuration for the any motion and
j3 3:e1770675eca4 137 ///<no motion interrupts
j3 3:e1770675eca4 138 INT_MOTION_2, ///<Contains the configuration for the any motion and
j3 3:e1770675eca4 139 ///<no motion interrupts
j3 3:e1770675eca4 140 INT_MOTION_3, ///<Contains the configuration for the any motion and
j3 3:e1770675eca4 141 ///<no motion interrupts
j3 3:e1770675eca4 142 INT_TAP_0, ///<Contains the configuration for the tap interrupts
j3 3:e1770675eca4 143 INT_TAP_1, ///<Contains the configuration for the tap interrupts
j3 3:e1770675eca4 144 INT_ORIENT_0, ///<Contains the configuration for the oeientation
j3 3:e1770675eca4 145 ///<interrupt
j3 3:e1770675eca4 146 INT_ORIENT_1, ///<Contains the configuration for the oeientation
j3 3:e1770675eca4 147 ///<interrupt
j3 3:e1770675eca4 148 INT_FLAT_0, ///<Contains the configuration for the flat interrupt
j3 3:e1770675eca4 149 INT_FLAT_1, ///<Contains the configuration for the flat interrupt
j3 3:e1770675eca4 150 FOC_CONF, ///<Contains configuration for the fast offset
j3 3:e1770675eca4 151 ///<compensation for the accelerometer and gyroscope
j3 3:e1770675eca4 152 CONF, ///<Configuration of sensor, nvm_prog_en bit
j3 3:e1770675eca4 153 IF_CONF, ///<Contains settings for the digital interface
j3 3:e1770675eca4 154 PMU_TRIGGER, ///<Sets trigger conditions to change gyro power modes
j3 3:e1770675eca4 155 SELF_TEST, ///<Self test configuration
j3 3:e1770675eca4 156 NV_CONF = 0x70, ///<Contains settings for the digital interface
j3 3:e1770675eca4 157 OFFSET_0, ///<Contains offset comp values for acc_off_x7:0
j3 3:e1770675eca4 158 OFFSET_1, ///<Contains offset comp values for acc_off_y7:0
j3 3:e1770675eca4 159 OFFSET_2, ///<Contains offset comp values for acc_off_z7:0
j3 3:e1770675eca4 160 OFFSET_3, ///<Contains offset comp values for gyr_off_x7:0
j3 3:e1770675eca4 161 OFFSET_4, ///<Contains offset comp values for gyr_off_y7:0
j3 3:e1770675eca4 162 OFFSET_5, ///<Contains offset comp values for gyr_off_z7:0
j3 3:e1770675eca4 163 OFFSET_6, ///<gyr/acc offset enable bit and gyr_off_(zyx) bits9:8
j3 3:e1770675eca4 164 STEP_CNT_0, ///<Step counter bits 15:8
j3 3:e1770675eca4 165 STEP_CNT_1, ///<Step counter bits 7:0
j3 3:e1770675eca4 166 STEP_CONF_0, ///<Contains configuration of the step detector
j3 3:e1770675eca4 167 STEP_CONF_1, ///<Contains configuration of the step detector
j3 3:e1770675eca4 168 CMD = 0x7E ///<Command register triggers operations like
j3 3:e1770675eca4 169 ///<softreset, NVM programming, etc.
j3 3:e1770675eca4 170 };
j3 3:e1770675eca4 171
j3 3:e1770675eca4 172 ///ERR_REG Bit Mask bit0
j3 3:e1770675eca4 173 static const uint8_t FATAL_ERR = 0x01;
j3 3:e1770675eca4 174 ///ERR_REG Bit Mask bits4:1
j3 3:e1770675eca4 175 static const uint8_t ERR_CODE = 0x1E;
j3 3:e1770675eca4 176 ///ERR_REG Bit Mask bit5
j3 3:e1770675eca4 177 static const uint8_t I2C_FAIL_ERR = 0x20;
j3 3:e1770675eca4 178 ///ERR_REG Bit Mask bit6
j3 3:e1770675eca4 179 static const uint8_t DROP_CMD_ERR = 0x40;
j3 3:e1770675eca4 180 ///ERR_REG Bit Mask bit7
j3 3:e1770675eca4 181 static const uint8_t MAG_DRDY_ERR = 0x80;
j3 3:e1770675eca4 182
j3 3:e1770675eca4 183 ///ERR_REG bits4:1 codes
j3 3:e1770675eca4 184 enum ErrorCodes
j3 3:e1770675eca4 185 {
j3 3:e1770675eca4 186 NO_ERROR = 0, ///<No Error
j3 3:e1770675eca4 187 ERROR_1, ///<Listed as error
j3 3:e1770675eca4 188 ERROR_2, ///<Listed as error
j3 3:e1770675eca4 189 LPM_INT_PFD, ///<Low-power mode and interrupt uses pre-filtered
j3 3:e1770675eca4 190 ///<data
j3 3:e1770675eca4 191 ODR_MISMATCH = 0x06, ///<ODRs of enabled sensors in headless mode do not
j3 3:e1770675eca4 192 ///<match
j3 3:e1770675eca4 193 PFD_USED_LPM ///<Pre-filtered data are used in low power mode
j3 0:bb5b832891fb 194 };
j3 0:bb5b832891fb 195
j3 0:bb5b832891fb 196
j3 0:bb5b832891fb 197 ///@brief BMI160 Destructor.\n
j3 0:bb5b832891fb 198 ///
j3 0:bb5b832891fb 199 ///On Entry:
j3 0:bb5b832891fb 200 ///@param[in] none
j3 0:bb5b832891fb 201 ///
j3 0:bb5b832891fb 202 ///On Exit:
j3 0:bb5b832891fb 203 ///@param[out] none
j3 0:bb5b832891fb 204 ///
j3 0:bb5b832891fb 205 ///@returns none
j3 2:598e601e5846 206 virtual ~BMI160(){ }
j3 0:bb5b832891fb 207
j3 0:bb5b832891fb 208
j3 0:bb5b832891fb 209 ///@brief Reads a single register.\n
j3 0:bb5b832891fb 210 ///
j3 0:bb5b832891fb 211 ///On Entry:
j3 0:bb5b832891fb 212 ///@param[in] data - pointer to memory for storing read data
j3 0:bb5b832891fb 213 ///
j3 0:bb5b832891fb 214 ///On Exit:
j3 0:bb5b832891fb 215 ///@param[out] data - holds contents of read register on success
j3 0:bb5b832891fb 216 ///
j3 0:bb5b832891fb 217 ///@returns 0 on success, non 0 on failure
j3 2:598e601e5846 218 virtual int32_t readRegister(Registers reg, uint8_t *data) = 0;
j3 0:bb5b832891fb 219
j3 0:bb5b832891fb 220
j3 0:bb5b832891fb 221 ///@brief Writes a single register.\n
j3 0:bb5b832891fb 222 ///
j3 0:bb5b832891fb 223 ///On Entry:
j3 0:bb5b832891fb 224 ///@param[in] data - data to write to register
j3 0:bb5b832891fb 225 ///
j3 0:bb5b832891fb 226 ///On Exit:
j3 0:bb5b832891fb 227 ///@param[out] none
j3 0:bb5b832891fb 228 ///
j3 0:bb5b832891fb 229 ///@returns 0 on success, non 0 on failure
j3 2:598e601e5846 230 virtual int32_t writeRegister(Registers reg, const uint8_t data) = 0;
j3 0:bb5b832891fb 231
j3 0:bb5b832891fb 232
j3 0:bb5b832891fb 233 ///@brief Reads a block of registers.\n
j3 0:bb5b832891fb 234 ///@detail User must ensure that all registers between 'startReg' and
j3 0:bb5b832891fb 235 ///'stopReg' exist and are readable. Function reads up to, including,
j3 0:bb5b832891fb 236 ///'stopReg'.\n
j3 0:bb5b832891fb 237 ///
j3 0:bb5b832891fb 238 ///On Entry:
j3 0:bb5b832891fb 239 ///@param[in] startReg - register to start reading from
j3 0:bb5b832891fb 240 ///@param[in] stopReg - register to stop reading from
j3 0:bb5b832891fb 241 ///@param[in] data - pointer to memory for storing read data
j3 0:bb5b832891fb 242 ///
j3 0:bb5b832891fb 243 ///On Exit:
j3 0:bb5b832891fb 244 ///@param[out] data - holds contents of read registers on success
j3 0:bb5b832891fb 245 ///
j3 0:bb5b832891fb 246 ///@returns 0 on success, non 0 on failure
j3 3:e1770675eca4 247 virtual int32_t readBlock(Registers startReg, Registers stopReg,
j3 3:e1770675eca4 248 uint8_t *data) = 0;
j3 0:bb5b832891fb 249
j3 0:bb5b832891fb 250
j3 0:bb5b832891fb 251 ///@brief Writes a block of registers.\n
j3 0:bb5b832891fb 252 ///@detail User must ensure that all registers between 'startReg' and
j3 0:bb5b832891fb 253 ///'stopReg' exist and are writeable. Function writes up to, including,
j3 0:bb5b832891fb 254 ///'stopReg'.\n
j3 0:bb5b832891fb 255 ///
j3 0:bb5b832891fb 256 ///On Entry:
j3 0:bb5b832891fb 257 ///@param[in] startReg - register to start writing at
j3 0:bb5b832891fb 258 ///@param[in] stopReg - register to stop writing at
j3 0:bb5b832891fb 259 ///@param[in] data - pointer to data to write to registers
j3 0:bb5b832891fb 260 ///
j3 0:bb5b832891fb 261 ///On Exit:
j3 0:bb5b832891fb 262 ///@param[out] none
j3 0:bb5b832891fb 263 ///
j3 0:bb5b832891fb 264 ///@returns 0 on success, non 0 on failure
j3 3:e1770675eca4 265 virtual int32_t writeBlock(Registers startReg, Registers stopReg,
j3 3:e1770675eca4 266 const uint8_t *data) = 0;
j3 3:e1770675eca4 267
j3 3:e1770675eca4 268
j3 3:e1770675eca4 269 ///@brief Get die temperature.\n
j3 3:e1770675eca4 270 ///
j3 3:e1770675eca4 271 ///On Entry:
j3 3:e1770675eca4 272 ///@param[in] temp - pointer to float for temperature
j3 3:e1770675eca4 273 ///
j3 3:e1770675eca4 274 ///On Exit:
j3 3:e1770675eca4 275 ///@param[out] temp - on success, holds the die temperature
j3 3:e1770675eca4 276 ///
j3 3:e1770675eca4 277 ///@returns 0 on success, non 0 on failure
j3 3:e1770675eca4 278 int32_t getTemperature(float *temp);
j3 3:e1770675eca4 279
j3 3:e1770675eca4 280
j3 3:e1770675eca4 281 ///@brief fx documentation template.\n
j3 3:e1770675eca4 282 ///
j3 3:e1770675eca4 283 ///On Entry:
j3 3:e1770675eca4 284 ///@param[in] none
j3 3:e1770675eca4 285 ///
j3 3:e1770675eca4 286 ///On Exit:
j3 3:e1770675eca4 287 ///@param[out] none
j3 3:e1770675eca4 288 ///
j3 3:e1770675eca4 289 ///@returns none
j3 0:bb5b832891fb 290
j3 2:598e601e5846 291 private:
j3 2:598e601e5846 292
j3 2:598e601e5846 293 };
j3 2:598e601e5846 294
j3 2:598e601e5846 295
j3 2:598e601e5846 296 /**
j3 2:598e601e5846 297 @brief BMI160_I2C - supports BMI160 object with I2C interface
j3 2:598e601e5846 298 */
j3 2:598e601e5846 299 class BMI160_I2C: public BMI160
j3 2:598e601e5846 300 {
j3 2:598e601e5846 301 public:
j3 2:598e601e5846 302
j3 2:598e601e5846 303 ///BMI160 default I2C address.
j3 2:598e601e5846 304 static const uint8_t I2C_ADRS_SDO_LO = 0x68;
j3 2:598e601e5846 305 ///BMI160 optional I2C address.
j3 2:598e601e5846 306 static const uint8_t I2C_ADRS_SDO_HI = 0x69;
j3 0:bb5b832891fb 307
j3 2:598e601e5846 308
j3 2:598e601e5846 309 ///@brief BMI160_I2C Constructor.\n
j3 0:bb5b832891fb 310 ///
j3 0:bb5b832891fb 311 ///On Entry:
j3 2:598e601e5846 312 ///@param[in] i2cBus - reference to I2C bus for this device
j3 2:598e601e5846 313 ///@param[in] i2cAdrs - 7-bit I2C address
j3 0:bb5b832891fb 314 ///
j3 0:bb5b832891fb 315 ///On Exit:
j3 0:bb5b832891fb 316 ///@param[out] none
j3 0:bb5b832891fb 317 ///
j3 0:bb5b832891fb 318 ///@returns none
j3 2:598e601e5846 319 BMI160_I2C(I2C &i2cBus, uint8_t i2cAdrs);
j3 2:598e601e5846 320
j3 2:598e601e5846 321
j3 2:598e601e5846 322 virtual int32_t readRegister(Registers reg, uint8_t *data);
j3 2:598e601e5846 323 virtual int32_t writeRegister(Registers reg, const uint8_t data);
j3 3:e1770675eca4 324 virtual int32_t readBlock(Registers startReg, Registers stopReg,
j3 3:e1770675eca4 325 uint8_t *data);
j3 3:e1770675eca4 326 virtual int32_t writeBlock(Registers startReg, Registers stopReg,
j3 3:e1770675eca4 327 const uint8_t *data);
j3 2:598e601e5846 328
j3 0:bb5b832891fb 329 private:
j3 0:bb5b832891fb 330
j3 0:bb5b832891fb 331 I2C m_i2cBus;
j3 0:bb5b832891fb 332 uint8_t m_Wadrs, m_Radrs;
j3 0:bb5b832891fb 333 };
j3 0:bb5b832891fb 334
j3 2:598e601e5846 335
j3 2:598e601e5846 336 /**
j3 2:598e601e5846 337 @brief BMI160_SPI - supports BMI160 object with SPI interface
j3 2:598e601e5846 338 */
j3 2:598e601e5846 339 class BMI160_SPI: public BMI160
j3 2:598e601e5846 340 {
j3 2:598e601e5846 341 public:
j3 2:598e601e5846 342
j3 2:598e601e5846 343 ///@brief BMI160_SPI Constructor.\n
j3 2:598e601e5846 344 ///
j3 2:598e601e5846 345 ///On Entry:
j3 2:598e601e5846 346 ///@param[in] spiBus - reference to SPI bus for this device
j3 2:598e601e5846 347 ///@param[in] cs - reference to DigitalOut used for chip select
j3 2:598e601e5846 348 ///
j3 2:598e601e5846 349 ///On Exit:
j3 2:598e601e5846 350 ///@param[out] none
j3 2:598e601e5846 351 ///
j3 2:598e601e5846 352 ///@returns none
j3 2:598e601e5846 353 BMI160_SPI(SPI &spiBus, DigitalOut &cs);
j3 2:598e601e5846 354
j3 2:598e601e5846 355 virtual int32_t readRegister(Registers reg, uint8_t *data);
j3 2:598e601e5846 356 virtual int32_t writeRegister(Registers reg, const uint8_t data);
j3 3:e1770675eca4 357 virtual int32_t readBlock(Registers startReg, Registers stopReg,
j3 3:e1770675eca4 358 uint8_t *data);
j3 3:e1770675eca4 359 virtual int32_t writeBlock(Registers startReg, Registers stopReg,
j3 3:e1770675eca4 360 const uint8_t *data);
j3 2:598e601e5846 361
j3 2:598e601e5846 362 private:
j3 2:598e601e5846 363
j3 2:598e601e5846 364 SPI m_spiBus;
j3 2:598e601e5846 365 DigitalOut m_cs;
j3 2:598e601e5846 366 };
j3 2:598e601e5846 367
j3 0:bb5b832891fb 368 #endif /* BMI160_H */