Hello Eason,
There were example code in github.
For accelerometer, you could example file "https://github.com/BoschSensortec/BMI270-Sensor-API/blob/master/examples/bmi270/accel/accel.c".
/*! * @brief This function converts lsb to meter per second squared for 16 bit accelerometer at * range 2G, 4G, 8G or 16G. */ static float lsb_to_mps2(int16_t val, float g_range, uint8_t bit_width) { float half_scale = ((float)(1 << bit_width) / 2.0f);
return (GRAVITY_EARTH * val * g_range) / half_scale; }
For gyroscope, you could example file "https://github.com/BoschSensortec/BMI270-Sensor-API/blob/master/examples/bmi270/gyro/gyro.c".
/*! * @brief This function converts lsb to degree per second for 16 bit gyro at * range 125, 250, 500, 1000 or 2000dps. */ static float lsb_to_dps(int16_t val, float dps, uint8_t bit_width) { float half_scale = ((float)(1 << bit_width) / 2.0f);
return (dps / ((half_scale) + BMI2_GYR_RANGE_2000)) * (val); }
... View more