Skip to content

Commit 520f922

Browse files
Kevin Moloneycalvinatintel
Kevin Moloney
authored andcommitted
ATLEDGE-426/ATLEDGE-445 CurieImu missing functions
* Removed CurieImu.getZeroShockDetected() & CurieImu.getZeroMotionDetected(). * Functions replaced with CurieImu.getIntShockStatus() & CurieImu.getIntZeroMotionStatus(). * Implemented getStepDetectionMode(). * There was no means of verifying setStepDetectionMode(). Signed-off-by: Kevin Moloney <kevin.moloney@emutex.com>
1 parent 4422bce commit 520f922

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

libraries/CurieImu/src/BMI160.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,35 @@ void BMI160Class::setShockDetectionDuration(uint8_t duration) {
807807
reg_write(BMI160_RA_INT_LOWHIGH_3, duration);
808808
}
809809

810+
/** Get Step Detection mode.
811+
* Returns an enum value which corresponds to current mode
812+
* 0 = Normal Mode
813+
* 1 = Sensitive Mode
814+
* 2 = Robust Mode
815+
* 3 = Unkown Mode
816+
* For more details on the Step Detection, see Section
817+
* 2.11.37 of the BMI160 Data Sheet.
818+
*
819+
* @return Current configuration of the step detector
820+
* @see BMI160_RA_STEP_CONF_0
821+
* @see BMI160_RA_STEP_CONF_1
822+
*/
823+
uint8_t BMI160Class::getStepDetectionMode() {
824+
uint8_t ret_step_conf0, ret_min_step_buf;
825+
826+
ret_step_conf0 = reg_read(BMI160_RA_STEP_CONF_0);
827+
ret_min_step_buf = reg_read(BMI160_RA_STEP_CONF_1);
828+
829+
if ((ret_step_conf0 == BMI160_RA_STEP_CONF_0_NOR) && (ret_min_step_buf == BMI160_RA_STEP_CONF_1_NOR))
830+
return BMI160_STEP_MODE_NORMAL;
831+
else if ((ret_step_conf0 == BMI160_RA_STEP_CONF_0_SEN) && (ret_min_step_buf == BMI160_RA_STEP_CONF_1_SEN))
832+
return BMI160_STEP_MODE_SENSITIVE;
833+
else if ((ret_step_conf0 == BMI160_RA_STEP_CONF_0_ROB) && (ret_min_step_buf == BMI160_RA_STEP_CONF_1_ROB))
834+
return BMI160_STEP_MODE_ROBUST;
835+
else
836+
return BMI160_STEP_MODE_UNKNOWN;
837+
}
838+
810839
/** Set Step Detection mode.
811840
* Sets the step detection mode to one of 3 predefined sensitivity settings:
812841
*
@@ -850,6 +879,7 @@ void BMI160Class::setStepDetectionMode(BMI160StepMode mode) {
850879
BMI160_STEP_BUF_MIN_LEN);
851880
}
852881

882+
853883
/** Get Step Counter enabled status.
854884
* Once enabled and configured correctly (@see setStepDetectionMode()), the
855885
* BMI160 will increment a counter for every step detected by the accelerometer.

libraries/CurieImu/src/BMI160.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ THE SOFTWARE.
231231
#define BMI160_RA_STEP_CONF_0 0x7A
232232
#define BMI160_RA_STEP_CONF_1 0x7B
233233

234+
#define BMI160_RA_STEP_CONF_0_NOR 0x15
235+
#define BMI160_RA_STEP_CONF_0_SEN 0x2D
236+
#define BMI160_RA_STEP_CONF_0_ROB 0x1D
237+
#define BMI160_RA_STEP_CONF_1_NOR 0x03
238+
#define BMI160_RA_STEP_CONF_1_SEN 0x00
239+
#define BMI160_RA_STEP_CONF_1_ROB 0x07
240+
241+
234242
#define BMI160_GYRO_RANGE_SEL_BIT 0
235243
#define BMI160_GYRO_RANGE_SEL_LEN 3
236244

@@ -351,6 +359,7 @@ typedef enum {
351359
BMI160_STEP_MODE_NORMAL = 0,
352360
BMI160_STEP_MODE_SENSITIVE,
353361
BMI160_STEP_MODE_ROBUST,
362+
BMI160_STEP_MODE_UNKNOWN,
354363
} BMI160StepMode;
355364

356365
/**
@@ -539,6 +548,7 @@ class BMI160Class {
539548
uint8_t getDoubleTapDetectionDuration();
540549
void setDoubleTapDetectionDuration(uint8_t duration);
541550

551+
uint8_t getStepDetectionMode();
542552
void setStepDetectionMode(BMI160StepMode mode);
543553
bool getStepCountEnabled();
544554
void setStepCountEnabled(bool enabled);
@@ -603,15 +613,13 @@ class BMI160Class {
603613
bool getYPosShockDetected();
604614
bool getZNegShockDetected();
605615
bool getZPosShockDetected();
606-
bool getZeroShockDetected();
607616

608617
bool getXNegMotionDetected();
609618
bool getXPosMotionDetected();
610619
bool getYNegMotionDetected();
611620
bool getYPosMotionDetected();
612621
bool getZNegMotionDetected();
613622
bool getZPosMotionDetected();
614-
bool getZeroMotionDetected();
615623

616624
bool getXNegTapDetected();
617625
bool getXPosTapDetected();

0 commit comments

Comments
 (0)