Skip to content

Commit 0c9d1ad

Browse files
BST-Github-Adminkegov
authored andcommitted
Changed the macro datatype for gyro foc comparison. Fixed issue with calling Gyro cross axes sensitivity before axes remap. Delay after soft reset command changed to 2ms from 1.8ms. Fixed issue with nested macros in bmi2.c. Removed config file size macro, now config file will be computed at build time depending on the size of the config file array. Corrected Gyro offset compensation.
1 parent 3407255 commit 0c9d1ad

14 files changed

+2065
-1596
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
BMI2xy Sensor API
1+
# BMI2xy Sensor API
22

33
> This package contains BMI2xy sensor API
44
55
## Sensor Overview
6+
67
The BMI2xy is a small, low power, low noise inertial measurement unit designed for use in mobile applications like augmented reality or indoor navigation which require highly accurate, real-time sensor data.
78

89
### Features
910

1011
- Indoor navigation, pedestrian dead-reckoning, step-counting
1112

12-
For more information refer product page [Link](To Be Updated)
13+
For more information refer [product page](https://www.bosch-sensortec.com/bst/products/all_products/bmi270)
1314

1415
---
16+
1517
#### Copyright (C) 2019 Bosch Sensortec GmbH

bmi2.c

+23-26
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
* patent rights of the copyright holder.
4141
*
4242
* @file bmi2.c
43-
* @date 2019-5-28
44-
* @version v2.19.0
43+
* @date 2019-07-24
44+
* @version v2.34.0
4545
*
4646
*/
4747

@@ -359,14 +359,14 @@
359359
#define GYRO_FOC_NOISE_LIMIT_POSITIVE UINT8_C(20)
360360

361361
/* reference value with positive and negative noise range in lsb */
362-
#define ACC_2G_MAX_NOISE_LIMIT UINT16_C(ACC_FOC_2G_REF + 255)
363-
#define ACC_2G_MIN_NOISE_LIMIT UINT16_C(ACC_FOC_2G_REF - 255)
364-
#define ACC_4G_MAX_NOISE_LIMIT UINT16_C(ACC_FOC_4G_REF + 255)
365-
#define ACC_4G_MIN_NOISE_LIMIT UINT16_C(ACC_FOC_4G_REF - 255)
366-
#define ACC_8G_MAX_NOISE_LIMIT UINT16_C(ACC_FOC_8G_REF + 255)
367-
#define ACC_8G_MIN_NOISE_LIMIT UINT16_C(ACC_FOC_8G_REF - 255)
368-
#define ACC_16G_MAX_NOISE_LIMIT UINT16_C(ACC_FOC_16G_REF + 255)
369-
#define ACC_16G_MIN_NOISE_LIMIT UINT16_C(ACC_FOC_16G_REF - 255)
362+
#define ACC_2G_MAX_NOISE_LIMIT (ACC_FOC_2G_REF + UINT16_C(255))
363+
#define ACC_2G_MIN_NOISE_LIMIT (ACC_FOC_2G_REF - UINT16_C(255))
364+
#define ACC_4G_MAX_NOISE_LIMIT (ACC_FOC_4G_REF + UINT16_C(255))
365+
#define ACC_4G_MIN_NOISE_LIMIT (ACC_FOC_4G_REF - UINT16_C(255))
366+
#define ACC_8G_MAX_NOISE_LIMIT (ACC_FOC_8G_REF + UINT16_C(255))
367+
#define ACC_8G_MIN_NOISE_LIMIT (ACC_FOC_8G_REF - UINT16_C(255))
368+
#define ACC_16G_MAX_NOISE_LIMIT (ACC_FOC_16G_REF + UINT16_C(255))
369+
#define ACC_16G_MIN_NOISE_LIMIT (ACC_FOC_16G_REF - UINT16_C(255))
370370

371371
#define BMI2_FOC_SAMPLE_LIMIT UINT8_C(128)
372372

@@ -4180,7 +4180,7 @@ int8_t bmi2_soft_reset(struct bmi2_dev *dev)
41804180
{
41814181
/* Reset bmi2 device */
41824182
rslt = bmi2_set_regs(BMI2_CMD_REG_ADDR, &data, 1, dev);
4183-
dev->delay_us(1800);
4183+
dev->delay_us(2000);
41844184

41854185
/* set APS flag as after soft reset the sensor is on advance power save mode */
41864186
dev->aps_status = BMI2_ENABLE;
@@ -5196,16 +5196,11 @@ int8_t bmi2_read_fifo_data(struct bmi2_fifo_frame *fifo, const struct bmi2_dev *
51965196
/* Clear the FIFO data structure */
51975197
reset_fifo_frame_structure(fifo, dev);
51985198

5199-
/* Select the interface */
5200-
if (dev->intf == BMI2_SPI_INTERFACE)
5201-
{
5202-
addr = addr | BMI2_SPI_RD_MASK;
5203-
}
5204-
5205-
/* Read FIFO data */
5206-
rslt = dev->read(dev->dev_id, addr, fifo->data, fifo->length);
5199+
/*red fifo data*/
5200+
rslt = bmi2_get_regs(addr, fifo->data, fifo->length, dev);
52075201
if (rslt == BMI2_OK)
52085202
{
5203+
52095204
/* Get the set FIFO frame configurations */
52105205
rslt = bmi2_get_regs(BMI2_FIFO_CONFIG_0_ADDR, config_data, 2, dev);
52115206
if (rslt == BMI2_OK)
@@ -5265,6 +5260,7 @@ int8_t bmi2_extract_accel(struct bmi2_sens_axes_data *accel_data,
52655260
/* Parsing the FIFO data in header-less mode */
52665261
if (fifo->header_enable == 0)
52675262
{
5263+
52685264
/* Get the number of accelerometer bytes to be read */
52695265
rslt = parse_fifo_accel_len(&data_index, &data_read_length, accel_length, fifo, dev);
52705266

@@ -5333,6 +5329,7 @@ int8_t bmi2_extract_gyro(struct bmi2_sens_axes_data *gyro_data,
53335329
/* Parsing the FIFO data in header-less mode */
53345330
if (fifo->header_enable == 0)
53355331
{
5332+
/* Get the number of gyro bytes to be read */
53365333
rslt = parse_fifo_gyro_len(&data_index, &data_read_length, gyro_length, fifo, dev);
53375334

53385335
/* Convert word to byte since all sensor enables are in a byte */
@@ -7673,14 +7670,13 @@ int8_t bmi2_set_act_recg_sett(const struct act_recg_sett *sett, struct bmi2_dev
76737670
{
76747671
/* Define the offset in bytes */
76757672
idx = act_recg_sett.start_addr;
7676-
if((sett->act_rec_4 > 10) || (sett->act_rec_5 > 10)){
7673+
if ((sett->act_rec_4 > 10) || (sett->act_rec_5 > 10))
7674+
{
76777675
rslt = BMI2_E_INVALID_INPUT;
76787676
}
76797677
if (rslt == BMI2_OK)
76807678
{
7681-
feat_config[idx] = BMI2_SET_BIT_POS0(feat_config[idx],
7682-
BMI2_ACT_RECG_POST_PROS_EN_DIS,
7683-
sett->act_rec_1);
7679+
feat_config[idx] = BMI2_SET_BIT_POS0(feat_config[idx], BMI2_ACT_RECG_POST_PROS_EN_DIS, sett->act_rec_1);
76847680

76857681
/* increment idx by 2 to point min gdi thres addres */
76867682
idx = idx + 2;
@@ -13328,11 +13324,12 @@ static int8_t get_gyro_sensor_data(struct bmi2_sens_axes_data *data, uint8_t reg
1332813324
/* Get gyroscope data from the register */
1332913325
get_acc_gyr_data(data, reg_data);
1333013326

13327+
/* Get the compensated gyroscope data */
13328+
comp_gyro_cross_axis_sensitivity(data, dev);
13329+
1333113330
/* Get the re-mapped gyroscope data */
1333213331
get_remapped_data(data, dev);
1333313332

13334-
/* Get the compensated gyroscope data */
13335-
comp_gyro_cross_axis_sensitivity(data, dev);
1333613333
}
1333713334

1333813335
return rslt;
@@ -16562,7 +16559,7 @@ static int8_t perform_accel_foc(const struct accel_foc_g_value *accel_g_value,
1656216559
uint8_t reg_status = 0;
1656316560

1656416561
/* Array of structure to store accelerometer data */
16565-
struct bmi2_sens_axes_data accel_value[128];
16562+
struct bmi2_sens_axes_data accel_value[128] = { { 0 } };
1656616563

1656716564
/* Structure to store accelerometer data temporarily */
1656816565
struct foc_temp_value temp = { 0, 0, 0 };

bmi2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
* patent rights of the copyright holder.
4141
*
4242
* @file bmi2.h
43-
* @date 2019-5-28
44-
* @version v2.19.0
43+
* @date 2019-07-24
44+
* @version v2.34.0
4545
*
4646
*/
4747

0 commit comments

Comments
 (0)