Hi gianmariai,
It is recommended that you refer to the sensor API to configure the sensor BMI160. This is a reference example. https://github.com/BoschSensortec/BMI160_driver/blob/master/examples/tap/tap.c
Open_BMI160_TAP(dev, BMI160_ENABLE); Enable_MCU_INT1_Pin();
int8_t Open_BMI160_TAP(struct bmi160_dev *dev, uint8_t feature_enable) { int8_t rslt = BMI160_OK; struct bmi160_int_settg int_config;
if (feature_enable > 0) { /* Select the Interrupt channel/pin */ int_config.int_channel = BMI160_INT_CHANNEL_1; /* Interrupt channel/pin 1 */
/* Select the interrupt channel/pin settings */ int_config.int_pin_settg.output_en = BMI160_ENABLE; /* Enabling interrupt pins to act as output pin */ int_config.int_pin_settg.output_mode = BMI160_DISABLE; /* Choosing push-pull mode for interrupt pin */ int_config.int_pin_settg.output_type = BMI160_ENABLE; /* Choosing active low output */ int_config.int_pin_settg.edge_ctrl = BMI160_DISABLE; /* Choosing edge triggered output */ int_config.int_pin_settg.input_en = BMI160_DISABLE; /* Disabling interrupt pin to act as input */ int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; /* non-latched output */
/* Select the Interrupt type */ int_config.int_type = BMI160_ACC_SINGLE_TAP_INT; /* Choosing tap interrupt */
/* Select the Any-motion interrupt parameters */ int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_ENABLE; /* 1- Enable tap, 0- disable tap */ int_config.int_type_cfg.acc_tap_int.tap_thr = 2; /* Set tap threshold */ int_config.int_type_cfg.acc_tap_int.tap_dur = 2; /* Set tap duration */ int_config.int_type_cfg.acc_tap_int.tap_shock = 0; /* Set tap shock value */ int_config.int_type_cfg.acc_tap_int.tap_quiet = 0; /* Set tap quiet duration */ int_config.int_type_cfg.acc_tap_int.tap_data_src=1; /* data source 0 : filter or 1 : pre-filter */
/* Set the Any-motion interrupt */ rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */ PDEBUG("bmi160_set_int_config(tap enable) status:%d\r\n", rslt); } else { /* Select the Interrupt channel/pin */ int_config.int_channel = BMI160_INT_CHANNEL_1; int_config.int_pin_settg.output_en = BMI160_DISABLE; /* Disabling interrupt pins to act as output pin */ int_config.int_pin_settg.edge_ctrl = BMI160_DISABLE; /* Choosing edge triggered output */
/* Select the Interrupt type */ int_config.int_type = BMI160_ACC_SINGLE_TAP_INT; /* Choosing Tap interrupt */ int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_DISABLE; /* 1- Enable tap, 0- disable tap */
/* Set the Data ready interrupt */ rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */ PDEBUG("bmi160_set_int_config(tap disable) status:%d\r\n", rslt); }
return rslt; }
... View more