I'm trying to understand how to configure the BMI160 so that I can read the FIFO when a significant motion interrupt occurs. Here is how I have the BM160 configured at the moment. After the initial setup I'm not sure how to go about configuring the FIFO so that it has accelerometer data.
Also, I setup both interrupt pins since they are connected to an OR gate on my hardware and I need both of them to set to active high.
Note: I'm using this API https://github.com/BoschSensortec/BMI160_driver
/* Select the Output data rate, range of accelerometer sensor */
dev->accel_cfg.odr = BMI160_ACCEL_ODR_100HZ;
dev->accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
/* Select the power mode of accelerometer sensor */
dev->accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
/* Select the Output data rate, range of Gyroscope sensor */
dev->gyro_cfg.odr = BMI160_GYRO_ODR_100HZ;
dev->gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS;
dev->gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
/* Select the power mode of Gyroscope sensor */
dev->gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE;
int8_t result = bmi160_set_sens_conf(dev);
struct bmi160_int_settg int_config;
int_config.int_channel = BMI160_INT_CHANNEL_1; // Interrupt channel/pin 1
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_ANY_MOTION_INT; // Choosing Any motion interrupt
/* 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 high output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE; // 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 Any-motion interrupt parameters */
int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_DISABLE; // 1- Enable the any-motion, 0- disable any-motion
int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE; // Enabling x-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE; // Enabling y-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE; // Enabling z-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 0; // any-motion duration
int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 20;
result = bmi160_set_int_config(&int_config, dev);
/* Select the Interrupt channel/pin */
int_config.int_channel = BMI160_INT_CHANNEL_2; // Interrupt channel/pin 2
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_SIG_MOTION_INT; // Choosing Significant motion interrupt
/* 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 high output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE; // Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE; // Disabling interrupt pin to act as
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; // non-latched output
int_config.int_type_cfg.acc_sig_motion_int.sig_en = BMI160_ENABLE;
int_config.int_type_cfg.acc_sig_motion_int.sig_data_src = BMI160_DISABLE;
int_config.int_type_cfg.acc_sig_motion_int.sig_mot_proof = 0x3;
int_config.int_type_cfg.acc_sig_motion_int.sig_mot_skip = 0x0;
int_config.int_type_cfg.acc_sig_motion_int.sig_mot_thres = 0x14;
result = bmi160_set_int_config(&int_config, dev);