@@ -31,8 +31,6 @@ THE SOFTWARE.
31
31
*/
32
32
#include " BMI160.h"
33
33
34
- #define ACCEL_CONVERT_CONST 9800
35
-
36
34
#define BMI160_CHIP_ID 0xD1
37
35
38
36
#define BMI160_ACCEL_POWERUP_DELAY_MS 10
@@ -42,10 +40,6 @@ THE SOFTWARE.
42
40
#define BMI160_SIGN_EXTEND (val, from ) \
43
41
(((val) & (1 << ((from) - 1 ))) ? (val | (((1 << (1 + (sizeof (val) << 3 ) - (from))) - 1 ) << (from))) : val)
44
42
45
- // static uint8_t acc_sensitivity_shift = BMI160_SENSITIVITY_ACCEL_8G_SHIFT;
46
- // static uint16_t gyro_convert_numerator = 305;
47
- // static uint16_t gyro_convert_denominator = 10;
48
-
49
43
/* *****************************************************************************/
50
44
51
45
uint8_t BMI160Class::reg_read (uint8_t reg)
@@ -206,6 +200,7 @@ uint8_t BMI160Class::getAccelRate() {
206
200
BMI160_ACCEL_RATE_SEL_BIT,
207
201
BMI160_ACCEL_RATE_SEL_LEN);
208
202
}
203
+
209
204
/* * Set accelerometer output data rate.
210
205
* @param rate New output data rate
211
206
* @see getGyroRate()
@@ -252,6 +247,7 @@ uint8_t BMI160Class::getGyroDLPFMode() {
252
247
BMI160_GYRO_DLPF_SEL_BIT,
253
248
BMI160_GYRO_DLPF_SEL_LEN);
254
249
}
250
+
255
251
/* * Set gyroscope digital low-pass filter configuration.
256
252
* @param mode New DLFP configuration setting
257
253
* @see getGyroDLPFMode()
@@ -296,6 +292,7 @@ uint8_t BMI160Class::getAccelDLPFMode() {
296
292
BMI160_ACCEL_DLPF_SEL_BIT,
297
293
BMI160_ACCEL_DLPF_SEL_LEN);
298
294
}
295
+
299
296
/* * Set accelerometer digital low-pass filter configuration.
300
297
* @param mode New DLFP configuration setting
301
298
* @see getAccelDLPFMode()
@@ -306,7 +303,6 @@ void BMI160Class::setAccelDLPFMode(uint8_t mode) {
306
303
BMI160_ACCEL_DLPF_SEL_LEN);
307
304
}
308
305
309
-
310
306
/* * Get full-scale gyroscope range.
311
307
* The gyr_range parameter allows setting the full-scale range of the gyro sensors,
312
308
* as described in the table below.
@@ -975,6 +971,7 @@ uint8_t BMI160Class::getMotionDetectionDuration() {
975
971
BMI160_ANYMOTION_DUR_BIT,
976
972
BMI160_ANYMOTION_DUR_LEN);
977
973
}
974
+
978
975
/* * Set motion detection event duration threshold.
979
976
* @param duration New motion detection duration threshold value (#samples [1-4])
980
977
* @see getMotionDetectionDuration()
@@ -1019,6 +1016,7 @@ void BMI160Class::setMotionDetectionDuration(uint8_t samples) {
1019
1016
uint8_t BMI160Class::getZeroMotionDetectionThreshold () {
1020
1017
return reg_read (BMI160_RA_INT_MOTION_2);
1021
1018
}
1019
+
1022
1020
/* * Set zero motion detection event acceleration threshold.
1023
1021
* @param threshold New zero motion detection acceleration threshold value
1024
1022
* @see getZeroMotionDetectionThreshold()
@@ -1676,7 +1674,7 @@ uint8_t BMI160Class::getIntStatus3() {
1676
1674
*
1677
1675
* @return Current interrupt status
1678
1676
* @see BMI160_RA_INT_STATUS_1
1679
- * @see BMI160_HIGH_G_INT_BIT
1677
+ * @see BMI160_LOW_G_INT_BIT
1680
1678
*/
1681
1679
bool BMI160Class::getIntFreefallStatus () {
1682
1680
return !!(reg_read_bits (BMI160_RA_INT_STATUS_1,
@@ -2212,14 +2210,6 @@ void BMI160Class::getAcceleration(int16_t* x, int16_t* y, int16_t* z) {
2212
2210
*x = (((int16_t )buffer[1 ]) << 8 ) | buffer[0 ];
2213
2211
*y = (((int16_t )buffer[3 ]) << 8 ) | buffer[2 ];
2214
2212
*z = (((int16_t )buffer[5 ]) << 8 ) | buffer[4 ];
2215
-
2216
- /* TODO - figure out if the conversion below is needed here */
2217
- #if 0
2218
- /* convert accel data */
2219
- data_accel.x = (int16_t) ((data_accel.x * ACCEL_CONVERT_CONST) >> acc_sensitivity_shift);
2220
- data_accel.y = (int16_t) ((data_accel.y * ACCEL_CONVERT_CONST) >> acc_sensitivity_shift);
2221
- data_accel.z = (int16_t) ((data_accel.z * ACCEL_CONVERT_CONST) >> acc_sensitivity_shift);
2222
- #endif
2223
2213
}
2224
2214
2225
2215
/* * Get X-axis accelerometer reading.
@@ -2317,13 +2307,6 @@ void BMI160Class::getRotation(int16_t* x, int16_t* y, int16_t* z) {
2317
2307
*x = (((int16_t )buffer[1 ]) << 8 ) | buffer[0 ];
2318
2308
*y = (((int16_t )buffer[3 ]) << 8 ) | buffer[2 ];
2319
2309
*z = (((int16_t )buffer[5 ]) << 8 ) | buffer[4 ];
2320
-
2321
- #if 0
2322
- /* convert gyro data */
2323
- data_gyro.x = (data_gyro.x * gyro_convert_numerator) / gyro_convert_denominator;
2324
- data_gyro.y = (data_gyro.y * gyro_convert_numerator) / gyro_convert_denominator;
2325
- data_gyro.z = (data_gyro.z * gyro_convert_numerator) / gyro_convert_denominator;
2326
- #endif
2327
2310
}
2328
2311
2329
2312
/* * Get X-axis gyroscope reading.
@@ -2359,8 +2342,6 @@ int16_t BMI160Class::getRotationZ() {
2359
2342
return (((int16_t )buffer[1 ]) << 8 ) | buffer[0 ];
2360
2343
}
2361
2344
2362
-
2363
-
2364
2345
/* * Read a BMI160 register directly.
2365
2346
* @param reg register address
2366
2347
* @return 8-bit register value
0 commit comments