Skip to content

Commit 17b8d04

Browse files
Dan-Lightsourcecalvinatintel
authored andcommitted
imu: minor clean-ups
- removed some dead code - added/corrected some code comments Signed-off-by: Dan O'Donovan <dan@emutex.com>
1 parent e490400 commit 17b8d04

File tree

3 files changed

+18
-46
lines changed

3 files changed

+18
-46
lines changed

libraries/CurieImu/src/BMI160.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ THE SOFTWARE.
3131
*/
3232
#include "BMI160.h"
3333

34-
#define ACCEL_CONVERT_CONST 9800
35-
3634
#define BMI160_CHIP_ID 0xD1
3735

3836
#define BMI160_ACCEL_POWERUP_DELAY_MS 10
@@ -42,10 +40,6 @@ THE SOFTWARE.
4240
#define BMI160_SIGN_EXTEND(val, from) \
4341
(((val) & (1 << ((from) - 1))) ? (val | (((1 << (1 + (sizeof(val) << 3) - (from))) - 1) << (from))) : val)
4442

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-
4943
/******************************************************************************/
5044

5145
uint8_t BMI160Class::reg_read (uint8_t reg)
@@ -206,6 +200,7 @@ uint8_t BMI160Class::getAccelRate() {
206200
BMI160_ACCEL_RATE_SEL_BIT,
207201
BMI160_ACCEL_RATE_SEL_LEN);
208202
}
203+
209204
/** Set accelerometer output data rate.
210205
* @param rate New output data rate
211206
* @see getGyroRate()
@@ -252,6 +247,7 @@ uint8_t BMI160Class::getGyroDLPFMode() {
252247
BMI160_GYRO_DLPF_SEL_BIT,
253248
BMI160_GYRO_DLPF_SEL_LEN);
254249
}
250+
255251
/** Set gyroscope digital low-pass filter configuration.
256252
* @param mode New DLFP configuration setting
257253
* @see getGyroDLPFMode()
@@ -296,6 +292,7 @@ uint8_t BMI160Class::getAccelDLPFMode() {
296292
BMI160_ACCEL_DLPF_SEL_BIT,
297293
BMI160_ACCEL_DLPF_SEL_LEN);
298294
}
295+
299296
/** Set accelerometer digital low-pass filter configuration.
300297
* @param mode New DLFP configuration setting
301298
* @see getAccelDLPFMode()
@@ -306,7 +303,6 @@ void BMI160Class::setAccelDLPFMode(uint8_t mode) {
306303
BMI160_ACCEL_DLPF_SEL_LEN);
307304
}
308305

309-
310306
/** Get full-scale gyroscope range.
311307
* The gyr_range parameter allows setting the full-scale range of the gyro sensors,
312308
* as described in the table below.
@@ -975,6 +971,7 @@ uint8_t BMI160Class::getMotionDetectionDuration() {
975971
BMI160_ANYMOTION_DUR_BIT,
976972
BMI160_ANYMOTION_DUR_LEN);
977973
}
974+
978975
/** Set motion detection event duration threshold.
979976
* @param duration New motion detection duration threshold value (#samples [1-4])
980977
* @see getMotionDetectionDuration()
@@ -1019,6 +1016,7 @@ void BMI160Class::setMotionDetectionDuration(uint8_t samples) {
10191016
uint8_t BMI160Class::getZeroMotionDetectionThreshold() {
10201017
return reg_read(BMI160_RA_INT_MOTION_2);
10211018
}
1019+
10221020
/** Set zero motion detection event acceleration threshold.
10231021
* @param threshold New zero motion detection acceleration threshold value
10241022
* @see getZeroMotionDetectionThreshold()
@@ -1676,7 +1674,7 @@ uint8_t BMI160Class::getIntStatus3() {
16761674
*
16771675
* @return Current interrupt status
16781676
* @see BMI160_RA_INT_STATUS_1
1679-
* @see BMI160_HIGH_G_INT_BIT
1677+
* @see BMI160_LOW_G_INT_BIT
16801678
*/
16811679
bool BMI160Class::getIntFreefallStatus() {
16821680
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) {
22122210
*x = (((int16_t)buffer[1]) << 8) | buffer[0];
22132211
*y = (((int16_t)buffer[3]) << 8) | buffer[2];
22142212
*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
22232213
}
22242214

22252215
/** Get X-axis accelerometer reading.
@@ -2317,13 +2307,6 @@ void BMI160Class::getRotation(int16_t* x, int16_t* y, int16_t* z) {
23172307
*x = (((int16_t)buffer[1]) << 8) | buffer[0];
23182308
*y = (((int16_t)buffer[3]) << 8) | buffer[2];
23192309
*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
23272310
}
23282311

23292312
/** Get X-axis gyroscope reading.
@@ -2359,8 +2342,6 @@ int16_t BMI160Class::getRotationZ() {
23592342
return (((int16_t)buffer[1]) << 8) | buffer[0];
23602343
}
23612344

2362-
2363-
23642345
/** Read a BMI160 register directly.
23652346
* @param reg register address
23662347
* @return 8-bit register value

libraries/CurieImu/src/BMI160.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -361,26 +361,6 @@ class BMI160Class {
361361
uint8_t getFullScaleAccelRange();
362362
void setFullScaleAccelRange(uint8_t range);
363363

364-
365-
#if 0
366-
// SELF_TEST registers
367-
uint8_t getAccelXSelfTestFactoryTrim();
368-
uint8_t getAccelYSelfTestFactoryTrim();
369-
uint8_t getAccelZSelfTestFactoryTrim();
370-
371-
uint8_t getGyroXSelfTestFactoryTrim();
372-
uint8_t getGyroYSelfTestFactoryTrim();
373-
uint8_t getGyroZSelfTestFactoryTrim();
374-
375-
// ACCEL_CONFIG register
376-
bool getAccelXSelfTest();
377-
void setAccelXSelfTest(bool enabled);
378-
bool getAccelYSelfTest();
379-
void setAccelYSelfTest(bool enabled);
380-
bool getAccelZSelfTest();
381-
void setAccelZSelfTest(bool enabled);
382-
#endif
383-
384364
void autoCalibrateGyroOffset();
385365
bool getGyroOffsetEnabled();
386366
void setGyroOffsetEnabled(bool enabled);
@@ -550,7 +530,6 @@ class BMI160Class {
550530
protected:
551531
virtual int serial_buffer_transfer(uint8_t *buf, unsigned tx_cnt, unsigned rx_cnt);
552532

553-
554533
private:
555534
uint8_t reg_read (uint8_t reg);
556535
void reg_write(uint8_t reg, uint8_t data);

libraries/CurieImu/src/CurieImu.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*
2+
* BMI160 accelerometer/gyroscope library for Intel(R) Curie(TM) devices.
3+
*
24
* Copyright (c) 2015 Intel Corporation. All rights reserved.
35
*
46
* This library is free software; you can redistribute it and/or
@@ -22,6 +24,16 @@
2224

2325
#include "BMI160.h"
2426

27+
/* Note that this CurieImuClass class inherits methods from the BMI160Class which
28+
* is defined in BMI160.h. BMI160Class provides methods for configuring and
29+
* accessing features of the BMI160 IMU device. This CurieImuClass extends that
30+
* class with implementation of details specific to the integration of the BMI160
31+
* device on the Intel Curie module, such as the serial communication interface
32+
* and interrupt signalling.
33+
*
34+
* Please refer to the respective .cpp files for documentation on each of the
35+
* methods provided by these classes.
36+
*/
2537
class CurieImuClass : public BMI160Class {
2638
friend void bmi160_pin1_isr(void);
2739

0 commit comments

Comments
 (0)