Library for Bosch Sensortech BMI160 IMU
Fork of BMI160 by
BMI160_SPI Class Reference
BMI160_SPI - supports BMI160 object with SPI interface. More...
#include <bmi160.h>
Inherits BMI160.
Public Types | |
enum | Sensors { MAG = 0, GYRO, ACC } |
Sensor types. More... | |
enum | SensorAxis |
Sensor Axis. More... | |
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 = 0x50, INT_EN_1 = 0x51, INT_EN_2 = 0x52, INT_OUT_CTRL = 0x53, INT_LATCH = 0x54, INT_MAP_0 = 0x55, INT_MAP_1 = 0x56, INT_MAP_2 = 0x57, 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 = 0x63, INT_TAP_1 = 0x64, 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 } |
BMI160 registers. More... | |
enum | PowerModes { SUSPEND = 0, NORMAL, LOW_POWER, FAST_START_UP } |
Enumerated power modes. More... | |
enum | Commands { START_FOC = 0x03, ACC_SET_PMU_MODE = 0x10, GYR_SET_PMU_MODE = 0x14, MAG_SET_PMU_MODE = 0x18, PROG_NVM = 0xA0, FIFO_FLUSH = 0xB0, INT_RESET, STEP_CNT_CLR, SOFT_RESET = 0xB6 } |
Enumerated commands used with CMD register. More... | |
Public Member Functions | |
BMI160_SPI (SPI &spiBus, DigitalOut &cs) | |
BMI160_SPI Constructor. | |
virtual int32_t | readRegister (Registers reg, uint8_t *data) |
Reads a single register. | |
virtual int32_t | writeRegister (Registers reg, const uint8_t data) |
Writes a single register. | |
virtual int32_t | readBlock (Registers startReg, Registers stopReg, uint8_t *data) |
Reads a block of registers. | |
virtual int32_t | writeBlock (Registers startReg, Registers stopReg, const uint8_t *data) |
Writes a block of registers. | |
int32_t | setSensorPowerMode (Sensors sensor, PowerModes pwrMode) |
Sets sensors power mode through CMD register. | |
int32_t | setSensorConfig (const AccConfig &config) |
Configure sensor. | |
int32_t | getSensorConfig (AccConfig &config) |
Get sensor configuration. | |
int32_t | getSensorAxis (SensorAxis axis, AxisData &data, AccRange range) |
Get sensor axis. | |
int32_t | getSensorXYZ (SensorData &data, AccRange range) |
Get sensor xyz axis. | |
int32_t | getSensorXYZandSensorTime (SensorData &data, SensorTime &sensorTime, AccRange range) |
Get sensor xyz axis and sensor time. | |
int32_t | getGyroAccXYZandSensorTime (SensorData &accData, SensorData &gyroData, SensorTime &sensorTime, AccRange accRange, GyroRange gyroRange) |
Get Gyroscope/Accelerometer data and sensor time. | |
int32_t | getSensorTime (SensorTime &sensorTime) |
Get sensor time. | |
int32_t | getTemperature (float *temp) |
Get die temperature. | |
Static Public Attributes | |
static const uint8_t | RTN_NO_ERROR = 0 |
Return value on success. | |
static const float | SENSOR_TIME_LSB = 39e-6 |
Period of internal counter. | |
ERR_REG(0x02) | |
| |
enum | ErrorCodes { NO_ERROR = 0, ERROR_1, ERROR_2, LPM_INT_PFD, ODR_MISMATCH = 0x06, PFD_USED_LPM } |
Enumerated error codes. More... | |
static const uint8_t | FATAL_ERR_MASK = 0x01 |
static const uint8_t | FATAL_ERR_POS = 0x00 |
static const uint8_t | ERR_CODE_MASK = 0x1E |
static const uint8_t | ERR_CODE_POS = 0x01 |
static const uint8_t | I2C_FAIL_ERR_MASK = 0x20 |
static const uint8_t | I2C_FAIL_ERR_POS = 0x05 |
static const uint8_t | DROP_CMD_ERR_MASK = 0x40 |
static const uint8_t | DROP_CMD_ERR_POS = 0x06 |
static const uint8_t | MAG_DRDY_ERR_MASK = 0x80 |
static const uint8_t | MAG_DRDY_ERR_POS = 0x08 |
ACC_CONF(0x40) and ACC_RANGE(0x41) | |
Data for configuring accelerometer | |
enum | AccOutputDataRate { ACC_ODR_1 = 1, ACC_ODR_2, ACC_ODR_3, ACC_ODR_4, ACC_ODR_5, ACC_ODR_6, ACC_ODR_7, ACC_ODR_8, ACC_ODR_9, ACC_ODR_10, ACC_ODR_11, ACC_ODR_12 } |
Accelerometer output data rates. More... | |
enum | AccBandWidthParam { ACC_BWP_0 = 0, ACC_BWP_1, ACC_BWP_2, ACC_BWP_3, ACC_BWP_4, ACC_BWP_5, ACC_BWP_6, ACC_BWP_7 } |
Accelerometer bandwidth parameters. More... | |
enum | AccUnderSampling |
Accelerometer undersampling. More... | |
enum | AccRange { SENS_2G = 0x03, SENS_4G = 0x05, SENS_8G = 0x08, SENS_16G = 0x0C } |
Accelerometer ranges. More... | |
static const uint8_t | ACC_ODR_MASK = 0x0F |
static const uint8_t | ACC_ODR_POS = 0x00 |
static const uint8_t | ACC_BWP_MASK = 0x70 |
static const uint8_t | ACC_BWP_POS = 0x04 |
static const uint8_t | ACC_US_MASK = 0x80 |
static const uint8_t | ACC_US_POS = 0x07 |
static const uint8_t | ACC_RANGE_MASK = 0x0F |
static const uint8_t | ACC_RANGE_POS = 0x00 |
static const float | SENS_2G_LSB_PER_G = 16384.0F |
static const float | SENS_4G_LSB_PER_G = 8192.0F |
static const float | SENS_8G_LSB_PER_G = 4096.0F |
static const float | SENS_16G_LSB_PER_G = 2048.0F |
static const AccConfig | DEFAULT_ACC_CONFIG |
Accelerometer default configuration. | |
GYR_CONF(0x42) and GYR_RANGE(0x43) | |
Data for configuring gyroscope | |
enum | GyroOutputDataRate { GYRO_ODR_6 = 0x06, GYRO_ODR_7 = 0x07, GYRO_ODR_8 = 0x08, GYRO_ODR_9 = 0x09, GYRO_ODR_10 = 0x0A, GYRO_ODR_11 = 0x0B, GYRO_ODR_12 = 0x0C, GYRO_ODR_13 = 0x0D } |
Gyroscope output data rates. More... | |
enum | GyroBandWidthParam { GYRO_BWP_0 = 0, GYRO_BWP_1, GYRO_BWP_2 } |
Gyroscope bandwidth paramaters. More... | |
enum | GyroRange { DPS_2000 = 0, DPS_1000, DPS_500, DPS_250, DPS_125 } |
Gyroscope ranges. More... | |
static const uint8_t | GYRO_ODR_MASK = 0x0F |
static const uint8_t | GYRO_ODR_POS = 0x00 |
static const uint8_t | GYRO_BWP_MASK = 0x30 |
static const uint8_t | GYRO_BWP_POS = 0x04 |
static const uint8_t | GYRO_RANGE_MASK = 0x07 |
static const uint8_t | GYRO_RANGE_POS = 0x00 |
static const float | SENS_2000_DPS_LSB_PER_DPS = 16.4F |
static const float | SENS_1000_DPS_LSB_PER_DPS = 32.8F |
static const float | SENS_500_DPS_LSB_PER_DPS = 65.6F |
static const float | SENS_250_DPS_LSB_PER_DPS = 131.2F |
static const float | SENS_125_DPS_LSB_PER_DPS = 262.4F |
static const GyroConfig | DEFAULT_GYRO_CONFIG |
Gyroscope default configuration. |
Detailed Description
BMI160_SPI - supports BMI160 object with SPI interface.
Definition at line 711 of file bmi160.h.
Member Enumeration Documentation
enum AccBandWidthParam [inherited] |
enum AccOutputDataRate [inherited] |
enum AccUnderSampling [inherited] |
enum Commands [inherited] |
enum GyroBandWidthParam [inherited] |
enum GyroOutputDataRate [inherited] |
Constructor & Destructor Documentation
BMI160_SPI | ( | SPI & | spiBus, |
DigitalOut & | cs | ||
) |
BMI160_SPI Constructor.
On Entry:
- Parameters:
-
[in] spiBus - reference to SPI bus for this device [in] cs - reference to DigitalOut used for chip select
On Exit:
- Parameters:
-
[out] none
- Returns:
- none
Definition at line 38 of file bmi160_spi.cpp.
Member Function Documentation
int32_t getGyroAccXYZandSensorTime | ( | SensorData & | accData, |
SensorData & | gyroData, | ||
SensorTime & | sensorTime, | ||
AccRange | accRange, | ||
GyroRange | gyroRange | ||
) | [inherited] |
Get Gyroscope/Accelerometer data and sensor time.
On Entry:
- Parameters:
-
[in] accData - Sensor data structure for accelerometer [in] gyroData - Sensor data structure for gyroscope [in] sensorTime - SensorTime data structure [in] accRange - Accelerometer range [in] gyroRange - Gyroscope range
On Exit:
- Parameters:
-
[out] accData - Synchronized accelerometer data [out] gyroData - Synchronized gyroscope data [out] sensorTime - Synchronized sensor time
- Returns:
- 0 on success, non 0 on failure
Definition at line 449 of file bmi160.cpp.
int32_t getSensorAxis | ( | SensorAxis | axis, |
AxisData & | data, | ||
AccRange | range | ||
) | [inherited] |
Get sensor axis.
On Entry:
- Parameters:
-
[in] axis - Sensor axis [in] data - AxisData structure [in] range - Sensor range
On Exit:
- Parameters:
-
[out] data - Structure holds raw and scaled axis data
- Returns:
- 0 on success, non 0 on failure
Definition at line 143 of file bmi160.cpp.
int32_t getSensorConfig | ( | AccConfig & | config ) | [inherited] |
Get sensor configuration.
On Entry:
- Parameters:
-
[in] config - Sensor configuration data structure
On Exit:
- Parameters:
-
[out] config - on success, holds sensor's current configuration
- Returns:
- 0 on success, non 0 on failure
Definition at line 101 of file bmi160.cpp.
int32_t getSensorTime | ( | SensorTime & | sensorTime ) | [inherited] |
Get sensor time.
On Entry:
- Parameters:
-
[in] sensorTime - SensorTime structure for data
On Exit:
- Parameters:
-
[out] sensorTime - Holds sensor time on success
- Returns:
- returns 0 on success, non 0 on failure
Definition at line 537 of file bmi160.cpp.
int32_t getSensorXYZ | ( | SensorData & | data, |
AccRange | range | ||
) | [inherited] |
Get sensor xyz axis.
On Entry:
- Parameters:
-
[in] data - SensorData structure [in] range - Sensor range
On Exit:
- Parameters:
-
[out] data - Structure holds raw and scaled data for all three axis
- Returns:
- 0 on success, non 0 on failure
Definition at line 251 of file bmi160.cpp.
int32_t getSensorXYZandSensorTime | ( | SensorData & | data, |
SensorTime & | sensorTime, | ||
AccRange | range | ||
) | [inherited] |
Get sensor xyz axis and sensor time.
On Entry:
- Parameters:
-
[in] data - SensorData structure [in] sensorTime - SensorTime structure for data [in] range - Sensor range
On Exit:
- Parameters:
-
[out] data - Structure holds raw and scaled data for all three axis [out] sensorTime - Holds sensor time on success
- Returns:
- 0 on success, non 0 on failure
Definition at line 345 of file bmi160.cpp.
int32_t getTemperature | ( | float * | temp ) | [inherited] |
Get die temperature.
On Entry:
- Parameters:
-
[in] temp - pointer to float for temperature
On Exit:
- Parameters:
-
[out] temp - on success, holds the die temperature
- Returns:
- 0 on success, non 0 on failure
Definition at line 554 of file bmi160.cpp.
int32_t readBlock | ( | Registers | startReg, |
Registers | stopReg, | ||
uint8_t * | data | ||
) | [virtual] |
Reads a block of registers.
User must ensure that all registers between 'startReg' and 'stopReg' exist and are readable. Function reads up to, including, 'stopReg'.
On Entry:
- Parameters:
-
[in] startReg - register to start reading from [in] stopReg - register to stop reading from [in] data - pointer to memory for storing read data
On Exit:
- Parameters:
-
[out] data - holds contents of read registers on success
- Returns:
- 0 on success, non 0 on failure
Definition at line 64 of file bmi160_spi.cpp.
int32_t readRegister | ( | Registers | reg, |
uint8_t * | data | ||
) | [virtual] |
Reads a single register.
On Entry:
- Parameters:
-
[in] data - pointer to memory for storing read data
On Exit:
- Parameters:
-
[out] data - holds contents of read register on success
- Returns:
- 0 on success, non 0 on failure
Definition at line 46 of file bmi160_spi.cpp.
int32_t setSensorConfig | ( | const AccConfig & | config ) | [inherited] |
Configure sensor.
On Entry:
- Parameters:
-
[in] config - sSensor configuration data structure
On Exit:
- Parameters:
-
[out] none
- Returns:
- 0 on success, non 0 on failure
Definition at line 76 of file bmi160.cpp.
int32_t setSensorPowerMode | ( | Sensors | sensor, |
PowerModes | pwrMode | ||
) | [inherited] |
Sets sensors power mode through CMD register.
Observe command execution times given in datasheet.
On Entry:
- Parameters:
-
[in] sensor - Sensor which power mode we are setting [in] pwrMode - Desired powermode of the sensor
On Exit:
- Parameters:
-
[out]
- Returns:
- 0 on success, non 0 on failure
Definition at line 48 of file bmi160.cpp.
int32_t writeBlock | ( | Registers | startReg, |
Registers | stopReg, | ||
const uint8_t * | data | ||
) | [virtual] |
Writes a block of registers.
User must ensure that all registers between 'startReg' and 'stopReg' exist and are writeable. Function writes up to, including, 'stopReg'.
On Entry:
- Parameters:
-
[in] startReg - register to start writing at [in] stopReg - register to stop writing at [in] data - pointer to data to write to registers
On Exit:
- Parameters:
-
[out] none
- Returns:
- 0 on success, non 0 on failure
Definition at line 74 of file bmi160_spi.cpp.
int32_t writeRegister | ( | Registers | reg, |
const uint8_t | data | ||
) | [virtual] |
Writes a single register.
On Entry:
- Parameters:
-
[in] data - data to write to register
On Exit:
- Parameters:
-
[out] none
- Returns:
- 0 on success, non 0 on failure
Definition at line 55 of file bmi160_spi.cpp.
Field Documentation
const AccConfig DEFAULT_ACC_CONFIG [static, inherited] |
const GyroConfig DEFAULT_GYRO_CONFIG [static, inherited] |
const uint8_t RTN_NO_ERROR = 0 [static, inherited] |
Generated on Wed Jul 13 2022 23:21:00 by 1.7.2