Hello potter1234,
I tested low-g on MCU, it worked well. MCU could received interrupt, and low-g bit value of 0x1D register is 1.
Please refer my code and test result.
int8_t Open_BMI160_LOW_G(struct bmi160_dev *dev) { int8_t rslt = BMI160_OK; struct bmi160_int_settg int_config;
/* Select the Interrupt channel/pin */ int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1
/* Select the Interrupt type */ int_config.int_type = BMI160_ACC_LOW_G_INT; /* 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;// latched output
/* Select the Flat interrupt parameters */ int_config.int_type_cfg.acc_low_g_int.low_dur = 24;/*! low-g interrupt trigger delay */ int_config.int_type_cfg.acc_low_g_int.low_thres = 12;/*! low-g interrupt trigger threshold */ int_config.int_type_cfg.acc_low_g_int.low_hyst = BMI160_ENABLE;/*! hysteresis of low-g interrupt */ int_config.int_type_cfg.acc_low_g_int.low_mode = BMI160_ENABLE;/*! 0 - single-axis mode ,1 - axis-summing mode */ int_config.int_type_cfg.acc_low_g_int.low_data_src=BMI160_ENABLE; /*! data source 0- filter & 1 pre-filter */ int_config.int_type_cfg.acc_low_g_int.low_en = BMI160_ENABLE; /*! 1 - enable low-g, 0 - disable low-g */
/* Set the Flat interrupt */ rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */ if(rslt == BMI160_OK) { PDEBUG("bmi160_set_int_config for low-g success\r\n"); } else { PDEBUG("bmi160_set_int_config for low-g failed\r\n"); } return rslt; }
void StartBMI160InterruptTask(void const * argument) { int8_t rslt = BMI160_OK; struct bmi160_dev *dev; volatile union bmi160_int_status int_status;
dev = &bmi160dev;
for(;;) { if((int1_flag == 1) || (int2_flag == 1)) { memset(int_status.data, 0x00, sizeof(int_status.data)); bmi160_get_int_status(BMI160_INT_STATUS_ALL, &int_status, dev); PDEBUG("data: 0x%02X, 0x%02X, 0x%02X, 0x%02X\r\n", int_status.data[0], int_status.data[1], int_status.data[2], int_status.data[3]);
if(int_status.bit.step) { PDEBUG("Step detector interrupt occured\r\n"); }
if(int_status.bit.anym) { PDEBUG("Any motion interrupt occured\r\n"); }
if(int_status.bit.nomo) { PDEBUG("No motion interrupt occured\r\n"); }
if(int_status.bit.flat_int) { PDEBUG("Flat detection interrupt occured\r\n"); }
if(int_status.bit.s_tap) { PDEBUG("Single TAP interrupt occured\r\n"); }
if(int_status.bit.d_tap) { PDEBUG("Double TAP interrupt occured\r\n"); }
if(int_status.bit.tap_sign) { PDEBUG("TAP sign 1\r\n"); } else { PDEBUG("TAP sign 0\r\n"); }
if(int_status.bit.orient) { PDEBUG("Orientation interrupt occured\r\n"); }
if(int_status.bit.high_g) { PDEBUG("High-g interrupt occured\r\n"); }
if(int_status.bit.low_g) { PDEBUG("Low-g interrupt occured\r\n"); }
memset(int_status.data, 0x00, sizeof(int_status.data)); int1_flag = 0; } } }
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if(GPIO_Pin == GPIO_PIN_10)//INT1 { PDEBUG("INT1 Triggered\r\n"); int1_flag = 1;
}
}
struct bmi160_acc_low_g_int_cfg { #if LITTLE_ENDIAN == 1
/*! low-g interrupt trigger delay */ uint8_t low_dur;
/*! low-g interrupt trigger threshold */ uint8_t low_thres;
/*! hysteresis of low-g interrupt */ uint8_t low_hyst : 2;
/*! 0 - single-axis mode ,1 - axis-summing mode */ uint8_t low_mode : 1;
/*! data source 0- filter & 1 pre-filter */ uint8_t low_data_src : 1;
/*! 1 - enable low-g, 0 - disable low-g */ uint8_t low_en : 1; #elif BIG_ENDIAN == 1
/*! 1 - enable low-g, 0 - disable low-g */ uint8_t low_en : 1;
/*! data source 0- filter & 1 pre-filter */ uint8_t low_data_src : 1;
/*! 0 - single-axis mode ,1 - axis-summing mode */ uint8_t low_mode : 1;
/*! hysteresis of low-g interrupt */ uint8_t low_hyst : 2;
/*! low-g interrupt trigger threshold */ uint8_t low_thres;
/*! low-g interrupt trigger delay */ uint8_t low_dur; #endif
}
... View more