|
40 | 40 | * patent rights of the copyright holder.
|
41 | 41 | *
|
42 | 42 | * @file bmi2.c
|
43 |
| - * @date 2019-5-28 |
44 |
| - * @version v2.19.0 |
| 43 | + * @date 2019-07-24 |
| 44 | + * @version v2.34.0 |
45 | 45 | *
|
46 | 46 | */
|
47 | 47 |
|
|
359 | 359 | #define GYRO_FOC_NOISE_LIMIT_POSITIVE UINT8_C(20)
|
360 | 360 |
|
361 | 361 | /* 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)) |
370 | 370 |
|
371 | 371 | #define BMI2_FOC_SAMPLE_LIMIT UINT8_C(128)
|
372 | 372 |
|
@@ -4180,7 +4180,7 @@ int8_t bmi2_soft_reset(struct bmi2_dev *dev)
|
4180 | 4180 | {
|
4181 | 4181 | /* Reset bmi2 device */
|
4182 | 4182 | rslt = bmi2_set_regs(BMI2_CMD_REG_ADDR, &data, 1, dev);
|
4183 |
| - dev->delay_us(1800); |
| 4183 | + dev->delay_us(2000); |
4184 | 4184 |
|
4185 | 4185 | /* set APS flag as after soft reset the sensor is on advance power save mode */
|
4186 | 4186 | dev->aps_status = BMI2_ENABLE;
|
@@ -5196,16 +5196,11 @@ int8_t bmi2_read_fifo_data(struct bmi2_fifo_frame *fifo, const struct bmi2_dev *
|
5196 | 5196 | /* Clear the FIFO data structure */
|
5197 | 5197 | reset_fifo_frame_structure(fifo, dev);
|
5198 | 5198 |
|
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); |
5207 | 5201 | if (rslt == BMI2_OK)
|
5208 | 5202 | {
|
| 5203 | + |
5209 | 5204 | /* Get the set FIFO frame configurations */
|
5210 | 5205 | rslt = bmi2_get_regs(BMI2_FIFO_CONFIG_0_ADDR, config_data, 2, dev);
|
5211 | 5206 | if (rslt == BMI2_OK)
|
@@ -5265,6 +5260,7 @@ int8_t bmi2_extract_accel(struct bmi2_sens_axes_data *accel_data,
|
5265 | 5260 | /* Parsing the FIFO data in header-less mode */
|
5266 | 5261 | if (fifo->header_enable == 0)
|
5267 | 5262 | {
|
| 5263 | + |
5268 | 5264 | /* Get the number of accelerometer bytes to be read */
|
5269 | 5265 | rslt = parse_fifo_accel_len(&data_index, &data_read_length, accel_length, fifo, dev);
|
5270 | 5266 |
|
@@ -5333,6 +5329,7 @@ int8_t bmi2_extract_gyro(struct bmi2_sens_axes_data *gyro_data,
|
5333 | 5329 | /* Parsing the FIFO data in header-less mode */
|
5334 | 5330 | if (fifo->header_enable == 0)
|
5335 | 5331 | {
|
| 5332 | + /* Get the number of gyro bytes to be read */ |
5336 | 5333 | rslt = parse_fifo_gyro_len(&data_index, &data_read_length, gyro_length, fifo, dev);
|
5337 | 5334 |
|
5338 | 5335 | /* 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
|
7673 | 7670 | {
|
7674 | 7671 | /* Define the offset in bytes */
|
7675 | 7672 | 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 | + { |
7677 | 7675 | rslt = BMI2_E_INVALID_INPUT;
|
7678 | 7676 | }
|
7679 | 7677 | if (rslt == BMI2_OK)
|
7680 | 7678 | {
|
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); |
7684 | 7680 |
|
7685 | 7681 | /* increment idx by 2 to point min gdi thres addres */
|
7686 | 7682 | idx = idx + 2;
|
@@ -13328,11 +13324,12 @@ static int8_t get_gyro_sensor_data(struct bmi2_sens_axes_data *data, uint8_t reg
|
13328 | 13324 | /* Get gyroscope data from the register */
|
13329 | 13325 | get_acc_gyr_data(data, reg_data);
|
13330 | 13326 |
|
| 13327 | + /* Get the compensated gyroscope data */ |
| 13328 | + comp_gyro_cross_axis_sensitivity(data, dev); |
| 13329 | + |
13331 | 13330 | /* Get the re-mapped gyroscope data */
|
13332 | 13331 | get_remapped_data(data, dev);
|
13333 | 13332 |
|
13334 |
| - /* Get the compensated gyroscope data */ |
13335 |
| - comp_gyro_cross_axis_sensitivity(data, dev); |
13336 | 13333 | }
|
13337 | 13334 |
|
13338 | 13335 | return rslt;
|
@@ -16562,7 +16559,7 @@ static int8_t perform_accel_foc(const struct accel_foc_g_value *accel_g_value,
|
16562 | 16559 | uint8_t reg_status = 0;
|
16563 | 16560 |
|
16564 | 16561 | /* 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 } }; |
16566 | 16563 |
|
16567 | 16564 | /* Structure to store accelerometer data temporarily */
|
16568 | 16565 | struct foc_temp_value temp = { 0, 0, 0 };
|
|
0 commit comments