First Commit as a new library
Dependents: Host_Software_MAX32664GWEB_HR_wrist Host_Software_MAX32664GWEC_SpO2_HR Host_Software_MAX32664GWEB_HR_EXTENDED Host_Software_MAX32664GWEC_SpO2_HR-_EXTE ... more
Revision 3:e1770675eca4, committed 2016-12-09
- Comitter:
- j3
- Date:
- Fri Dec 09 00:29:29 2016 +0000
- Parent:
- 2:598e601e5846
- Child:
- 4:ebac8c8f6347
- Commit message:
- Added register enumeration documentation
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bmi160.cpp Fri Dec 09 00:29:29 2016 +0000
@@ -0,0 +1,43 @@
+/**********************************************************************
+* 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.
+**********************************************************************/
+
+
+#include "bmi160.h"
+
+
+//*****************************************************************************
+int32_t BMI160::getTemperature(float *temp)
+{
+ int32_t rtnVal = -1;
+
+ return rtnVal;
+}
--- a/bmi160.h Thu Dec 08 00:32:41 2016 +0000
+++ b/bmi160.h Fri Dec 09 00:29:29 2016 +0000
@@ -54,103 +54,143 @@
public:
///Return value on success.
- static const uint8_t NO_ERROR = 0;
+ static const uint8_t RTN_NO_ERROR = 0;
///BMI160 registers
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
+ CHIP_ID = 0x00, ///<Chip Identification.
+ ERR_REG = 0x02, ///<Reports sensor error flags. Flags reset when read.
+ PMU_STATUS, ///<Reports current power mode for sensors.
+ DATA_0, ///<MAG_X axis bits7:0
+ DATA_1, ///<MAG_X axis bits15:8
+ DATA_2, ///<MAG_Y axis bits7:0
+ DATA_3, ///<MAG_Y axis bits15:8
+ DATA_4, ///<MAG_Z axis bits7:0
+ DATA_5, ///<MAG_Z axis bits15:8
+ DATA_6, ///<RHALL bits7:0
+ DATA_7, ///<RHALL bits15:8
+ DATA_8, ///<GYR_X axis bits7:0
+ DATA_9, ///<GYR_X axis bits15:8
+ DATA_10, ///<GYR_Y axis bits7:0
+ DATA_11, ///<GYR_Y axis bits15:8
+ DATA_12, ///<GYR_Z axis bits7:0
+ DATA_13, ///<GYR_Z axis bits15:8
+ DATA_14, ///<ACC_X axis bits7:0
+ DATA_15, ///<ACC_X axis bits15:8
+ DATA_16, ///<ACC_Y axis bits7:0
+ DATA_17, ///<ACC_Y axis bits15:8
+ DATA_18, ///<ACC_Z axis bits7:0
+ DATA_19, ///<ACC_Z axis bits15:8
+ SENSORTIME_0, ///<24bit counter synchronized with data, bits7:0
+ SENSORTIME_1, ///<24bit counter synchronized with data, bits15:8
+ SENSORTIME_2, ///<24bit counter synchronized with data, bits23:16
+ STATUS, ///<Reports sensors status flags
+ INT_STATUS_0, ///<Contains interrupt status flags
+ INT_STATUS_1, ///<Contains interrupt status flags
+ INT_STATUS_2, ///<Contains interrupt status flags
+ INT_STATUS_3, ///<Contains interrupt status flags
+ TEMPERATURE_0, ///<Contains temperature of sensor, bits7:0
+ TEMPERATURE_1, ///<Contains temperature of sensor, bits15:8
+ FIFO_LENGTH_0, ///<Current fill level of FIFO, bits7:0
+ FIFO_LENGTH_1, ///<Current fill level of FIFO, bits10:8
+ FIFO_DATA, ///<FIFO data read out register, burst read
+ ACC_CONF = 0x40, ///<Set ODR, bandwidth, and read mode of accelerometer
+ ACC_RANGE, ///<Sets accelerometer g-range
+ GYR_CONF, ///<Set ODR, bandwidth, and read mode of gyroscope
+ GYR_RANGE, ///<Sets gyroscope angular rate measurement range
+ MAG_CONF, ///<Sets ODR of magnetometer interface
+ FIFO_DOWNS, ///<Sets down sampling ratios of accel and gyro data
+ ///<for FIFO
+ FIFO_CONFIG_0, ///<Sets FIFO Watermark
+ FIFO_CONFIG_1, ///<Sets which sensor data is available in FIFO,
+ ///<Header/Headerless mode, Ext Int tagging, Sensortime
+ MAG_IF_0 = 0x4B, ///<Magnetometer 7-bit I2C address, bits7:1
+ MAG_IF_1, ///<Magnetometer interface configuration
+ MAG_IF_2, ///<Magnetometer address to read
+ MAG_IF_3, ///<Magnetometer address to write
+ MAG_IF_4, ///<Magnetometer data to write
+ INT_EN_0, ///<Interrupt enable bits
+ INT_EN_1, ///<Interrupt enable bits
+ INT_EN_2, ///<Interrupt enable bits
+ INT_OUT_CTRL, ///<Contains the behavioral configuration of INT pins
+ INT_LATCH, ///<Contains the interrupt rest bit and the interrupt
+ ///<mode selection
+ INT_MAP_0, ///<Controls which interrupt signals are mapped to the
+ ///<INT1 and INT2 pins
+ INT_MAP_1, ///<Controls which interrupt signals are mapped to the
+ ///<INT1 and INT2 pins
+ INT_MAP_2, ///<Controls which interrupt signals are mapped to the
+ ///<INT1 and INT2 pins
+ INT_DATA_0, ///<Contains the data source definition for the two
+ ///<interrupt groups
+ INT_DATA_1, ///<Contains the data source definition for the two
+ ///<interrupt groups
+ INT_LOWHIGH_0, ///<Contains the configuration for the low g interrupt
+ INT_LOWHIGH_1, ///<Contains the configuration for the low g interrupt
+ INT_LOWHIGH_2, ///<Contains the configuration for the low g interrupt
+ INT_LOWHIGH_3, ///<Contains the configuration for the low g interrupt
+ INT_LOWHIGH_4, ///<Contains the configuration for the low g interrupt
+ INT_MOTION_0, ///<Contains the configuration for the any motion and
+ ///<no motion interrupts
+ INT_MOTION_1, ///<Contains the configuration for the any motion and
+ ///<no motion interrupts
+ INT_MOTION_2, ///<Contains the configuration for the any motion and
+ ///<no motion interrupts
+ INT_MOTION_3, ///<Contains the configuration for the any motion and
+ ///<no motion interrupts
+ INT_TAP_0, ///<Contains the configuration for the tap interrupts
+ INT_TAP_1, ///<Contains the configuration for the tap interrupts
+ INT_ORIENT_0, ///<Contains the configuration for the oeientation
+ ///<interrupt
+ INT_ORIENT_1, ///<Contains the configuration for the oeientation
+ ///<interrupt
+ INT_FLAT_0, ///<Contains the configuration for the flat interrupt
+ INT_FLAT_1, ///<Contains the configuration for the flat interrupt
+ FOC_CONF, ///<Contains configuration for the fast offset
+ ///<compensation for the accelerometer and gyroscope
+ CONF, ///<Configuration of sensor, nvm_prog_en bit
+ IF_CONF, ///<Contains settings for the digital interface
+ PMU_TRIGGER, ///<Sets trigger conditions to change gyro power modes
+ SELF_TEST, ///<Self test configuration
+ NV_CONF = 0x70, ///<Contains settings for the digital interface
+ OFFSET_0, ///<Contains offset comp values for acc_off_x7:0
+ OFFSET_1, ///<Contains offset comp values for acc_off_y7:0
+ OFFSET_2, ///<Contains offset comp values for acc_off_z7:0
+ OFFSET_3, ///<Contains offset comp values for gyr_off_x7:0
+ OFFSET_4, ///<Contains offset comp values for gyr_off_y7:0
+ OFFSET_5, ///<Contains offset comp values for gyr_off_z7:0
+ OFFSET_6, ///<gyr/acc offset enable bit and gyr_off_(zyx) bits9:8
+ STEP_CNT_0, ///<Step counter bits 15:8
+ STEP_CNT_1, ///<Step counter bits 7:0
+ STEP_CONF_0, ///<Contains configuration of the step detector
+ STEP_CONF_1, ///<Contains configuration of the step detector
+ CMD = 0x7E ///<Command register triggers operations like
+ ///<softreset, NVM programming, etc.
+ };
+
+ ///ERR_REG Bit Mask bit0
+ static const uint8_t FATAL_ERR = 0x01;
+ ///ERR_REG Bit Mask bits4:1
+ static const uint8_t ERR_CODE = 0x1E;
+ ///ERR_REG Bit Mask bit5
+ static const uint8_t I2C_FAIL_ERR = 0x20;
+ ///ERR_REG Bit Mask bit6
+ static const uint8_t DROP_CMD_ERR = 0x40;
+ ///ERR_REG Bit Mask bit7
+ static const uint8_t MAG_DRDY_ERR = 0x80;
+
+ ///ERR_REG bits4:1 codes
+ enum ErrorCodes
+ {
+ NO_ERROR = 0, ///<No Error
+ ERROR_1, ///<Listed as error
+ ERROR_2, ///<Listed as error
+ LPM_INT_PFD, ///<Low-power mode and interrupt uses pre-filtered
+ ///<data
+ ODR_MISMATCH = 0x06, ///<ODRs of enabled sensors in headless mode do not
+ ///<match
+ PFD_USED_LPM ///<Pre-filtered data are used in low power mode
};
@@ -204,7 +244,8 @@
///@param[out] data - holds contents of read registers on success
///
///@returns 0 on success, non 0 on failure
- virtual int32_t readBlock(Registers startReg, Registers stopReg, uint8_t *data) = 0;
+ virtual int32_t readBlock(Registers startReg, Registers stopReg,
+ uint8_t *data) = 0;
///@brief Writes a block of registers.\n
@@ -221,7 +262,31 @@
///@param[out] none
///
///@returns 0 on success, non 0 on failure
- virtual int32_t writeBlock(Registers startReg, Registers stopReg, const uint8_t *data) = 0;
+ virtual int32_t writeBlock(Registers startReg, Registers stopReg,
+ const uint8_t *data) = 0;
+
+
+ ///@brief Get die temperature.\n
+ ///
+ ///On Entry:
+ ///@param[in] temp - pointer to float for temperature
+ ///
+ ///On Exit:
+ ///@param[out] temp - on success, holds the die temperature
+ ///
+ ///@returns 0 on success, non 0 on failure
+ int32_t getTemperature(float *temp);
+
+
+ ///@brief fx documentation template.\n
+ ///
+ ///On Entry:
+ ///@param[in] none
+ ///
+ ///On Exit:
+ ///@param[out] none
+ ///
+ ///@returns none
private:
@@ -256,8 +321,10 @@
virtual int32_t readRegister(Registers reg, uint8_t *data);
virtual int32_t writeRegister(Registers reg, const uint8_t data);
- virtual int32_t readBlock(Registers startReg, Registers stopReg, uint8_t *data);
- virtual int32_t writeBlock(Registers startReg, Registers stopReg, const uint8_t *data);
+ virtual int32_t readBlock(Registers startReg, Registers stopReg,
+ uint8_t *data);
+ virtual int32_t writeBlock(Registers startReg, Registers stopReg,
+ const uint8_t *data);
private:
@@ -287,8 +354,10 @@
virtual int32_t readRegister(Registers reg, uint8_t *data);
virtual int32_t writeRegister(Registers reg, const uint8_t data);
- virtual int32_t readBlock(Registers startReg, Registers stopReg, uint8_t *data);
- virtual int32_t writeBlock(Registers startReg, Registers stopReg, const uint8_t *data);
+ virtual int32_t readBlock(Registers startReg, Registers stopReg,
+ uint8_t *data);
+ virtual int32_t writeBlock(Registers startReg, Registers stopReg,
+ const uint8_t *data);
private:
@@ -297,14 +366,3 @@
};
#endif /* BMI160_H */
-
-
-///@brief fx documentation template.\n
-///
-///On Entry:
-///@param[in] none
-///
-///On Exit:
-///@param[out] none
-///
-///@returns none
--- a/bmi160_i2c.cpp Thu Dec 08 00:32:41 2016 +0000
+++ b/bmi160_i2c.cpp Fri Dec 09 00:29:29 2016 +0000
@@ -66,7 +66,8 @@
//*****************************************************************************
-int32_t BMI160_I2C::readBlock(Registers startReg, Registers stopReg, uint8_t *data)
+int32_t BMI160_I2C::readBlock(Registers startReg, Registers stopReg,
+uint8_t *data)
{
int32_t rtnVal = -1;
int32_t numBytes = ((stopReg - startReg) + 1);
@@ -82,7 +83,8 @@
//*****************************************************************************
-int32_t BMI160_I2C::writeBlock(Registers startReg, Registers stopReg, const uint8_t *data)
+int32_t BMI160_I2C::writeBlock(Registers startReg, Registers stopReg,
+const uint8_t *data)
{
int32_t numBytes = ((stopReg - startReg) + 1);
char packet[numBytes + 1];
--- a/bmi160_spi.cpp Thu Dec 08 00:32:41 2016 +0000
+++ b/bmi160_spi.cpp Fri Dec 09 00:29:29 2016 +0000
@@ -60,7 +60,8 @@
//*****************************************************************************
-int32_t BMI160_SPI::readBlock(Registers startReg, Registers stopReg, uint8_t *data)
+int32_t BMI160_SPI::readBlock(Registers startReg, Registers stopReg,
+uint8_t *data)
{
int32_t rtnVal = -1;
@@ -69,7 +70,8 @@
//*****************************************************************************
-int32_t BMI160_SPI::writeBlock(Registers startReg, Registers stopReg, const uint8_t *data)
+int32_t BMI160_SPI::writeBlock(Registers startReg, Registers stopReg,
+const uint8_t *data)
{
int32_t rtnVal = -1;