Library for Bosch Sensortech BMI160 IMU
Fork of BMI160 by
bmi160.h
- Committer:
- j3
- Date:
- 2016-12-07
- Revision:
- 0:bb5b832891fb
- Child:
- 1:a4c911640569
File content as of revision 0:bb5b832891fb:
/********************************************************************** * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Maxim Integrated * Products, Inc. shall not be used except as stated in the Maxim Integrated * Products, Inc. Branding Policy. * * The mere transfer of this software does not imply any licenses * of trade secrets, proprietary technology, copyrights, patents, * trademarks, maskwork rights, or any other form of intellectual * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. **********************************************************************/ #ifndef BMI160_H #define BMI160_H #include "mbed.h" /** @brief The BMI160 is a small, low power, low noise 16-bit inertial measurement unit designed for use in mobile applications like augmented reality or indoor navigation which require highly accurate, real-time sensor data. In full operation mode, with both the accelerometer and gyroscope enabled, the current consumption is typically 950 μA, enabling always-on applications in battery driven devices. It is available in a compact 14-pin 2.5 x 3.0 x 0.8 mm³ LGA package." */ class BMI160 { public: static const uint8_t I2C_ADRS_SDO_LO = 0x68; static const uint8_t I2C_ADRS_SDO_HI = 0x69; static const uint8_t NO_ERROR = 0; enum Registers { CHIP_ID = 0x00, ERR_REG = 0x02, PMU_STATUS, DATA_0, DATA_1, DATA_2, DATA_3, DATA_4, DATA_5, DATA_6, DATA_7, DATA_8, DATA_9, DATA_10, DATA_11, DATA_12, DATA_13, DATA_14, DATA_15, DATA_16, DATA_17, DATA_18, DATA_19, SENSORTIME_0, SENSORTIME_1, SENSORTIME_2, STATUS, INT_STATUS_0, INT_STATUS_1, INT_STATUS_2, INT_STATUS_3, TEMPERATURE_0, TEMPERATURE_1, FIFO_LENGTH_0, FIFO_LENGTH_1, FIFO_DATA, ACC_CONF = 0x40, ACC_RANGE, GYR_CONF, GYR_RANGE, MAG_CONF, FIFO_DOWNS, FIFO_CONFIG_0, FIFO_CONFIG_1, MAG_IF_0 = 0x4B, MAG_IF_1, MAG_IF_2, MAG_IF_3, MAG_IF_4, INT_EN_0, INT_EN_1, INT_EN_2, INT_OUT_CTRL, INT_LATCH, INT_MAP_0, INT_MAP_1, INT_MAP_2, INT_DATA_0, INT_DATA_1, INT_LOWHIGH_0, INT_LOWHIGH_1, INT_LOWHIGH_2, INT_LOWHIGH_3, INT_LOWHIGH_4, INT_MOTION_0, INT_MOTION_1, INT_MOTION_2, INT_MOTION_3, INT_TAP_0, INT_TAP_1, INT_ORIENT_0, INT_ORIENT_1, INT_FLAT_0, INT_FLAT_1, FOC_CONF, CONF, IF_CONF, PMU_TRIGGER, SELF_TEST, NV_CONF = 0x70, OFFSET_0, OFFSET_1, OFFSET_2, OFFSET_3, OFFSET_4, OFFSET_5, OFFSET_6, STEP_CNT_0, STEP_CNT_1, STEP_CONF_0, STEP_CONF_1, CMD = 0x7E }; ///@brief BMI160 Constructor.\n /// ///On Entry: ///@param[in] i2cBus - reference to I2C bus for this device ///@param[in] i2cAdrs - 7-bit I2C address /// ///On Exit: ///@param[out] none /// ///@returns none BMI160(I2C &i2cBus, uint8_t i2cAdrs); ///@brief BMI160 Destructor.\n /// ///On Entry: ///@param[in] none /// ///On Exit: ///@param[out] none /// ///@returns none ~BMI160(); ///@brief Reads a single register.\n /// ///On Entry: ///@param[in] data - pointer to memory for storing read data /// ///On Exit: ///@param[out] data - holds contents of read register on success /// ///@returns 0 on success, non 0 on failure int32_t readRegister(Registers reg, uint8_t *data); ///@brief Writes a single register.\n /// ///On Entry: ///@param[in] data - data to write to register /// ///On Exit: ///@param[out] none /// ///@returns 0 on success, non 0 on failure int32_t writeRegister(Registers reg, uint8_t data); ///@brief Reads a block of registers.\n ///@detail User must ensure that all registers between 'startReg' and ///'stopReg' exist and are readable. Function reads up to, including, ///'stopReg'.\n /// ///On Entry: ///@param[in] startReg - register to start reading from ///@param[in] stopReg - register to stop reading from ///@param[in] data - pointer to memory for storing read data /// ///On Exit: ///@param[out] data - holds contents of read registers on success /// ///@returns 0 on success, non 0 on failure int32_t readBlock(Registers startReg, Registers stopReg, uint8_t *data); ///@brief Writes a block of registers.\n ///@detail User must ensure that all registers between 'startReg' and ///'stopReg' exist and are writeable. Function writes up to, including, ///'stopReg'.\n /// ///On Entry: ///@param[in] startReg - register to start writing at ///@param[in] stopReg - register to stop writing at ///@param[in] data - pointer to data to write to registers /// ///On Exit: ///@param[out] none /// ///@returns 0 on success, non 0 on failure int32_t writeBlock(Registers startReg, Registers stopReg, uint8_t *data); ///@brief fx documentation template.\n /// ///On Entry: ///@param[in] none /// ///On Exit: ///@param[out] none /// ///@returns none private: I2C m_i2cBus; uint8_t m_Wadrs, m_Radrs; }; #endif /* BMI160_H */