esp-idf-lib/bmi160
The BMI160 is an ultra-small, low power, low noise 16 bit inertial measurement unit designed for mobile applications like Augmented Reality applications or indoor navigation which require highly accurate, real-time sensor data.
Defines
-
BMI160_I2C_ADDRESS_GND
I2C address of BMI160 if SDO is pulled to GND.
-
BMI160_I2C_ADDRESS_VDD
I2C address of BMI160 if SDO is pulled to VDDIO.
Enums
-
enum bmi160_acc_range_t
enum for the accelerometer range
Values:
-
enumerator BMI160_ACC_RANGE_2G
+-2g
-
enumerator BMI160_ACC_RANGE_4G
+-4g
-
enumerator BMI160_ACC_RANGE_8G
+-8g
-
enumerator BMI160_ACC_RANGE_16G
+-16g
-
enumerator BMI160_ACC_RANGE_2G
-
enum bmi160_gyr_range_t
enum for the gyroscope range
Values:
-
enumerator BMI160_GYR_RANGE_125DPS
+-125dps
-
enumerator BMI160_GYR_RANGE_250DPS
+-250dps
-
enumerator BMI160_GYR_RANGE_500DPS
+-500dps
-
enumerator BMI160_GYR_RANGE_1000DPS
+-1000dps
-
enumerator BMI160_GYR_RANGE_2000DPS
+-2000dps
-
enumerator BMI160_GYR_RANGE_125DPS
-
enum bmi160_acc_odr_t
enum for the accelerometer ODR
Values:
-
enumerator BMI160_ACC_ODR_0_78HZ
0.78Hz
-
enumerator BMI160_ACC_ODR_1_56HZ
1.56Hz
-
enumerator BMI160_ACC_ODR_3_12HZ
3.12Hz
-
enumerator BMI160_ACC_ODR_6_25HZ
6.25Hz
-
enumerator BMI160_ACC_ODR_12_5HZ
12.5Hz
-
enumerator BMI160_ACC_ODR_25HZ
25Hz
-
enumerator BMI160_ACC_ODR_50HZ
50Hz
-
enumerator BMI160_ACC_ODR_100HZ
100Hz
-
enumerator BMI160_ACC_ODR_200HZ
200Hz
-
enumerator BMI160_ACC_ODR_400HZ
400Hz
-
enumerator BMI160_ACC_ODR_800HZ
800Hz
-
enumerator BMI160_ACC_ODR_1600HZ
1600Hz
-
enumerator BMI160_ACC_ODR_0_78HZ
-
enum bmi160_gyr_odr_t
enum for the gyroscope ODR
Values:
-
enumerator BMI160_GYR_ODR_25HZ
25Hz
-
enumerator BMI160_GYR_ODR_50HZ
50Hz
-
enumerator BMI160_GYR_ODR_100HZ
100Hz
-
enumerator BMI160_GYR_ODR_200HZ
200Hz
-
enumerator BMI160_GYR_ODR_400HZ
400Hz
-
enumerator BMI160_GYR_ODR_800HZ
800Hz
-
enumerator BMI160_GYR_ODR_1600HZ
1600Hz
-
enumerator BMI160_GYR_ODR_25HZ
-
enum bmi160_int_pin_t
enum for int pin
Values:
-
enumerator BMI160_PIN_INT1
INT1.
-
enumerator BMI160_PIN_INT2
INT2.
-
enumerator BMI160_PIN_INT1
-
enum bmi160_int_enable_t
enum for int enable
Values:
-
enumerator BMI160_INT_DISABLE
Disable interrupt.
-
enumerator BMI160_INT_ENABLE
Enable interrupt.
-
enumerator BMI160_INT_DISABLE
-
enum bmi160_int_od_t
enum for int od
Values:
-
enumerator BMI160_INT_PUSH_PULL
Push-pull.
-
enumerator BMI160_INT_OPEN_DRAIN
Open-drain.
-
enumerator BMI160_INT_PUSH_PULL
-
enum bmi160_int_level_t
enum for int level
Values:
-
enumerator BMI160_INT_ACTIVE_LOW
Active low.
-
enumerator BMI160_INT_ACTIVE_HIGH
Active high.
-
enumerator BMI160_INT_ACTIVE_LOW
-
enum bmi160_step_counter_mode_t
step counter mode
Values:
-
enumerator BMI160_STEP_COUNTER_NORMAL
Normal mode.
-
enumerator BMI160_STEP_COUNTER_SENSITIVE
Sensitive mode.
-
enumerator BMI160_STEP_COUNTER_ROBUST
Robust mode.
-
enumerator BMI160_STEP_COUNTER_NORMAL
-
enum bmi160_pmu_acc_mode_t
Accelerometer PMU mode.
Values:
-
enumerator BMI160_PMU_ACC_SUSPEND
Suspend mode.
-
enumerator BMI160_PMU_ACC_NORMAL
Normal mode.
-
enumerator BMI160_PMU_ACC_LOW_POWER
Low power mode.
-
enumerator BMI160_PMU_ACC_SUSPEND
-
enum bmi160_pmu_gyr_mode_t
Gyroscope PMU mode.
Values:
-
enumerator BMI160_PMU_GYR_SUSPEND
Suspend mode.
-
enumerator BMI160_PMU_GYR_NORMAL
Normal mode.
-
enumerator BMI160_PMU_GYR_FAST_STARTUP
Fast startup mode.
-
enumerator BMI160_PMU_GYR_SUSPEND
-
enum bmi160_acc_lp_avg_t
averaging configuration in low power mode for accelerometer
Note
For low power mode defines averaging, for normal mode defines filter bandwidth
Values:
-
enumerator BMI160_ACC_LP_AVG_1
1 sample
-
enumerator BMI160_ACC_LP_AVG_2
2 samples
-
enumerator BMI160_ACC_LP_AVG_4
4 samples
-
enumerator BMI160_ACC_LP_AVG_8
8 samples
-
enumerator BMI160_ACC_LP_AVG_16
16 samples
-
enumerator BMI160_ACC_LP_AVG_32
32 samples
-
enumerator BMI160_ACC_LP_AVG_64
64 samples
-
enumerator BMI160_ACC_LP_AVG_128
128 samples
-
enumerator BMI160_ACC_LP_AVG_1
-
enum bmi160_acc_us_t
bmi160 accelerometer undersampling configuration
Note
This is only applicable for low power mode
Values:
-
enumerator BMI160_ACC_US_ON
Enable undersampling.
-
enumerator BMI160_ACC_US_OFF
Disable undersampling.
-
enumerator BMI160_ACC_US_ON
-
enum bmi160_tap_quiet_t
tap configuration quiet
Values:
-
enumerator BMI160_TAP_QUIET_30MS
30ms
-
enumerator BMI160_TAP_QUIET_20MS
20ms
-
enumerator BMI160_TAP_QUIET_30MS
-
enum bmi160_tap_mode_t
tap mode
Values:
-
enumerator BMI160_TAP_MODE_SINGLE
Single tap.
-
enumerator BMI160_TAP_MODE_DOUBLE
Double tap.
-
enumerator BMI160_TAP_MODE_SINGLE
-
enum bmi160_tap_shock_t
tap configuration shock
Values:
-
enumerator BMI160_TAP_SHOCK_50MS
50ms
-
enumerator BMI160_TAP_SHOCK_75MS
75ms
-
enumerator BMI160_TAP_SHOCK_50MS
-
enum bmi160_tap_dur_t
tap configuration duration
Values:
-
enumerator BMI160_TAP_DUR_50MS
50ms
-
enumerator BMI160_TAP_DUR_100MS
100ms
-
enumerator BMI160_TAP_DUR_150MS
-
enumerator BMI160_TAP_DUR_200MS
-
enumerator BMI160_TAP_DUR_250MS
-
enumerator BMI160_TAP_DUR_375MS
-
enumerator BMI160_TAP_DUR_500MS
-
enumerator BMI160_TAP_DUR_700MS
-
enumerator BMI160_TAP_DUR_50MS
-
enum bmi160_tap_th_t
tap threshold
Values:
-
enumerator BMI160_TAP_TH_0_032G
0.032g
-
enumerator BMI160_TAP_TH_0_0625G
0.0625g
-
enumerator BMI160_TAP_TH_0_125G
0.125g
-
enumerator BMI160_TAP_TH_0_25G
0.25g
-
enumerator BMI160_TAP_TH_0_5G
0.5g
-
enumerator BMI160_TAP_TH_1G
1g
-
enumerator BMI160_TAP_TH_2G
2g
-
enumerator BMI160_TAP_TH_4G
4g
-
enumerator BMI160_TAP_TH_0_032G
Functions
-
esp_err_t bmi160_init(bmi160_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)
Initialize the BMI160.
- Parameters:
dev – Pointer to the device descriptor
addr – I2C address of the device
port – I2C port number
sda_gpio – SDA GPIO number
scl_gpio – SCL GPIO number
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_read_reg(bmi160_t *dev, uint8_t reg, uint8_t *val)
Read a register from the BMI160.
- Parameters:
dev – Pointer to the device descriptor
reg – Register address
val – Pointer to store the value
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_read_reg_array(bmi160_t *dev, uint8_t reg, uint8_t *val, uint8_t num)
Read an array of registers from the BMI160.
- Parameters:
dev – Pointer to the device descriptor
reg – Register address
val – Pointer to store the values
num – Number of registers to read
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_free(bmi160_t *dev)
free descriptor
- Parameters:
dev – Pointer to the device descriptor
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_write_reg(bmi160_t *dev, uint8_t reg, uint8_t val)
Write a register to the BMI160.
- Parameters:
dev – Pointer to the device descriptor
reg – Register address
val – Value to write
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_calibrate(bmi160_t *dev)
Calibrate the BMI160 to calculate bias.
Note
bmi160_start must be called before calling this function. After calling this function output data will be offset by the bias values.
- Parameters:
dev – Pointer to the device descriptor
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_start(bmi160_t *dev, bmi160_conf_t *conf)
start the BMI160
- Parameters:
dev – Pointer to the device descriptor
conf – Pointer to the configuration structure
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_read_data(bmi160_t *dev, bmi160_result_t *result)
Read data from the BMI160.
- Parameters:
dev – Pointer to the device descriptor
result – Pointer to store the result
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_set_acc_range(bmi160_t *dev, bmi160_acc_range_t range)
set acc range
- Parameters:
dev – Pointer to the device descriptor
range – Accelerometer range
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_set_gyr_range(bmi160_t *dev, bmi160_gyr_range_t range)
set gyro range
- Parameters:
dev – Pointer to the device descriptor
range – Gyroscope range
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_set_acc_conf(bmi160_t *dev, bmi160_acc_odr_t odr, bmi160_acc_lp_avg_t avg, bmi160_acc_us_t acc_us)
set acc configuration
- Parameters:
dev – Pointer to the device descriptor
odr – Accelerometer ODR
avg – Averaging configuration
acc_us – Accelerometer undersampling configuration
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_set_gyr_odr(bmi160_t *dev, bmi160_gyr_odr_t odr)
set gyro odr
- Parameters:
dev – Pointer to the device descriptor
odr – Gyroscope ODR
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_self_test(bmi160_t *dev)
self test for the BMI160
- Parameters:
dev – Pointer to the device descriptor
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_enable_int_new_data(bmi160_t *dev, bmi160_int_out_conf_t *intOutConf)
Enable interrupt for the BMI160.
- Parameters:
dev – Pointer to the device descriptor
intOutConf – Interrupt out configuration
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_enable_step_counter(bmi160_t *dev, bmi160_step_counter_mode_t mode)
configure step counter
- Parameters:
dev – Pointer to the device descriptor
mode – Step counter mode
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_read_step_counter(bmi160_t *dev, uint16_t *stepCounter)
read step counter
- Parameters:
dev – Pointer to the device descriptor
stepCounter – Pointer to store the step counter value
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_reset_step_counter(bmi160_t *dev)
reset step counter
- Parameters:
dev – Pointer to the device descriptor
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_enable_int_step(bmi160_t *dev, bmi160_int_out_conf_t *intOutConf)
Enable interrupt for the BMI160 for new step.
- Parameters:
dev – Pointer to the device descriptor
intOutConf – Interrupt out configuration
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_switch_mode(bmi160_t *dev, bmi160_pmu_acc_mode_t accMode, bmi160_pmu_gyr_mode_t gyrMode)
switch mode for the BMI160
-
esp_err_t bmi160_enable_tap_detection(bmi160_t *dev, bmi160_tap_conf_t *tapConf)
configure tap detection
- Parameters:
dev – Pointer to the device descriptor
tapConf – Pointer to the configuration structure
- Returns:
esp_err_t ESP_OK if success
-
esp_err_t bmi160_enable_int_tap(bmi160_t *dev, bmi160_int_out_conf_t *intOutConf)
Enable interrupt for the BMI160 for tap detection.
- Parameters:
dev – Pointer to the device descriptor
intOutConf – Interrupt out configuration
- Returns:
esp_err_t ESP_OK if success
-
struct bmi160_conf_t
- #include <bmi160.h>
bmi160 configuration structure
Public Members
-
bmi160_acc_range_t accRange
Accelerometer range.
-
bmi160_acc_odr_t accOdr
Accelerometer ODR.
-
bmi160_pmu_acc_mode_t accMode
Accelerometer PMU mode.
-
bmi160_acc_lp_avg_t accAvg
Accelerometer averaging configuration for low power mode.
-
bmi160_acc_us_t accUs
Accelerometer undersampling configuration.
-
bmi160_gyr_range_t gyrRange
Gyroscope range.
-
bmi160_gyr_odr_t gyrOdr
Gyroscope ODR.
-
bmi160_pmu_gyr_mode_t gyrMode
Gyroscope PMU mode.
-
bmi160_acc_range_t accRange
-
struct bmi160_result_t
- #include <bmi160.h>
result structure for the BMI160
-
struct bmi160_int_out_conf_t
- #include <bmi160.h>
int out configuration
Public Members
-
bmi160_int_pin_t intPin
Interrupt pin.
-
bmi160_int_enable_t intEnable
Enable interrupt.
-
bmi160_int_od_t intOd
Open-drain.
-
bmi160_int_level_t intLevel
Active high.
-
bmi160_int_pin_t intPin
-
struct bmi160_tap_conf_t
- #include <bmi160.h>
tap configuration
Public Members
-
bmi160_tap_quiet_t tapQuiet
Tap quiet.
-
bmi160_tap_shock_t tapShock
Tap shock.
-
bmi160_tap_dur_t tapDur
Tap duration.
-
bmi160_tap_th_t tapTh
Tap threshold.
-
bmi160_tap_mode_t tapMode
Tap mode.
-
bmi160_tap_quiet_t tapQuiet
-
struct bmi160_t
- #include <bmi160.h>
Device descriptor.
Public Members
-
i2c_dev_t i2c_dev
I2C device descriptor.
-
float aBias[3]
Accelerometer bias.
-
float gBias[3]
Gyroscope bias.
-
float aRes
Accelerometer resolution.
-
float gRes
Gyroscope resolution.
-
bmi160_acc_range_t accRange
Accelerometer range.
-
bmi160_gyr_range_t gyrRange
Gyroscope range.
-
bmi160_acc_odr_t accOdr
Accelerometer ODR.
-
uint8_t accConf
Accelerometer configuration.
-
bmi160_gyr_odr_t gyrOdr
Gyroscope ODR.
-
gpio_num_t intPin
Interrupt pin.
-
bmi160_tap_mode_t tapMode
Tap mode.
-
void (*callback)()
Interrupt callback.
-
i2c_dev_t i2c_dev