The function
"static int8_t config_any_dur_threshold(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg, const struct bmi160_dev *dev)"
does not save the correct value for the arbitrary movement interruption duration.
In the API:
@file bmi160.c
@date 2021-10-05
@version v3.9.2
/*!
* @brief This API configure the duration and threshold of
* any-motion interrupt.
*/
static int8_t config_any_dur_threshold(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg, const struct bmi160_dev *dev)
{
int8_t rslt;
uint8_t data = 0;
uint8_t temp = 0;
uint8_t data_array[2] = { 0 };
uint8_t dur;
/* Configure Int Motion 0 register */
rslt = bmi160_get_regs(BMI160_INT_MOTION_0_ADDR, &data, 1, dev);
if (rslt == BMI160_OK)
{
/* slope duration */
dur = (uint8_t)any_motion_int_cfg->anymotion_dur;
temp = data & ~BMI160_SLOPE_INT_DUR_MASK;
data = temp | (dur & BMI160_MOTION_SRC_INT_MASK);
data_array[0] = data;
/* add slope threshold */
data_array[1] = any_motion_int_cfg->anymotion_thr;
/* INT MOTION 0 and INT MOTION 1 address lie consecutively,
hence writing data to respective registers at one go /
/* Writing to Int_motion 0 and
Int_motion 1 Address simultaneously /
rslt = bmi160_set_regs(BMI160_INT_MOTION_0_ADDR, data_array, 2, dev);
}
return rslt;
}
I think an invalid mask "BMI160_MOTION_SRC_INT_MASK" was used.
data = temp | (dur & BMI160_MOTION_SRC_INT_MASK);
It should be:
data = temp | (dur & BMI160_SLOPE_INT_DUR_MASK);
because Register (0x5F) INT_MOTION_0:
int_anym_dur<1:0>: slope interrupt triggers if [int_anym_dur<1:0>+1] consecutive slope data points are above the slope interrupt threshold int_anym_th<7:0>
Please explain this discrepancy.