I put a working example code of sensor intialize here fore your reference (without FIFO since your FIFO configure is correct) .
if you initiliaze all three sensor correctly, the FIFO data should contain the correct data rate for both accel, gyro and mag .
static void init_bmi2xy_bmm150(void) { /* Variable to define error */ int8_t rslt; const uint8_t sensor_list[3] = { BMI2_ACCEL, BMI2_GYRO, BMI2_AUX}; struct bmi2_sens_config config[3] = { [0].type = BMI2_ACCEL, [1].type = BMI2_GYRO, [2].type = BMI2_AUX, };
printf("Please wait for config. file to be uploaded during BMI2xy initialization ...\n"); fflush(stdout);
/* Upload config. file */ if (bmi2_init(&bmi2dev) == BMI2_OK) { printf("BMI2xy initialization success !\n"); printf("Chip ID - 0x%x\n", bmi2dev.chip_id); } else { printf("BMI2xy initialization failure !\n"); printf("Config file - Sensor mismatch !!\n"); exit(COINES_E_FAILURE); }
/* Enable accel. , gyro. mag. sensors */ if (bmi2_sensor_enable(sensor_list, 3, &bmi2dev) == BMI2_OK) { /*acc*/ config[0].cfg.acc.filter_perf = BMI2_PERF_OPT_MODE; config[0].cfg.acc.bwp = BMI2_ACC_OSR2_AVG2; config[0].cfg.acc.odr = BMI2_ACC_ODR_100HZ; //IMU work for 100HZ config[0].cfg.acc.range = BMI2_ACC_RANGE_2G;
/*gyro*/ config[1].cfg.gyr.filter_perf = BMI2_PERF_OPT_MODE; config[1].cfg.gyr.noise_perf = BMI2_GYR_RANGE_2000; config[1].cfg.gyr.bwp = BMI2_GYR_OSR2_MODE; config[1].cfg.gyr.odr = BMI2_GYR_ODR_100HZ; config[1].cfg.gyr.range = BMI2_GYR_RANGE_2000; config[1].cfg.gyr.ois_range = BMI2_GYR_OIS_2000;
/*mag*/ /*The initial configuration of the auxiliary sensor should be done in manual mode.Then, switch to data mode to read data.*/ config[2].cfg.aux.aux_en = BMI2_ENABLE; config[2].cfg.aux.manual_en = BMI2_ENABLE; config[2].cfg.aux.odr = BMI2_AUX_ODR_50HZ; config[2].cfg.aux.i2c_device_addr = BMM150_DEFAULT_I2C_ADDRESS; config[2].cfg.aux.man_rd_burst = BMI2_AUX_READ_LEN_3;
/* Set accel. , gyro. and mag. configuration */ if (bmi2_set_sensor_config(config, 3, &bmi2dev) == BMI2_OK) printf("Accel./Gyro/Mag configuration write success !\n"); else printf("Accel./Gyro/Mag configuration write failure !\n");
/* Initialize bmm150:should be done in aux man mode */ rslt = bmm150_init(&bmm150); if (rslt != BMI2_OK) { printf("BMM150 init,Error code: %d\n", rslt); } /* Set the power mode to either normal or forced mode */ rslt = bmm150_set_op_mode(&bmm150); bmm150.settings.pwr_mode = BMM150_FORCED_MODE; if (rslt != BMI2_OK) { printf("BMM150 set op mode,Error code: %d\n", rslt); }
/* Switch to data mode for reading data*/ config[2].cfg.aux.manual_en = BMI2_DISABLE; /* Configure read address to read Magnetic field data from that address */ config[2].cfg.aux.read_addr = BMI_AUX_MAG_DATA_ADDR; config[2].cfg.aux.aux_rd_burst = BMI2_AUX_READ_LEN_3; /* Set the data mode and the auxiliary read address */ rslt = bmi2_set_sensor_config(config, 3, &bmi2dev); if (rslt != BMI2_OK) { printf("BMI2 set config,Error code: %d\n", rslt); } } }
... View more