我现在使用的FIFO模式,但是感觉这个中断信号来的太频繁了,这个中断触发的机制是什么呢?下面是我这边的代码:
S32 init_lsm6ds3(void)
{
S32 error = STATUS_OK;
U8 device_id, rst;
lsm6ds3tr_c_int1_route_t int_1_reg = {0};
//init I2C
error = (lsm6ds3_wire_connection_routine(LSM6DS3_WIRE_TYPE_I2C));
kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of init_I2C is:""%d", error);
if(error!= STATUS_OK) return error;
//read device id
error = lsm6ds3tr_c_device_id_get(&lsm6ds3, &device_id);
kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of get_device_id and device id are:""%d,%x", error,device_id);
if (device_id != LSM6DS3TR_C_ID) return STATUS_DEVICE_NOT_EXIST;
//software reset,gyr and acc in power down mode
error = lsm6ds3tr_c_reset_set(&lsm6ds3, PROPERTY_ENABLE);
kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of software_reset is:""%d", error);
if(error!= STATUS_OK) return error;
do {
lsm6ds3tr_c_reset_get(&lsm6ds3, &rst);
} while (rst);
#if 1 //xb test 2020-01-7 FIFO模式初始化
//set acc and gry full-scale
error = lsm6ds3tr_c_xl_full_scale_set(&lsm6ds3, LSM6DS3TR_C_2g);
kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of set_acc_full_scale is:""%d", error);
if(error!= STATUS_OK) return error;
error = lsm6ds3tr_c_gy_full_scale_set(&lsm6ds3, LSM6DS3TR_C_250dps);
kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of set_gry_full_scale is:""%d", error);
if(error!= STATUS_OK) return error;
//set acc and gry data rate
//error = lsm6ds3tr_c_xl_data_rate_set(&lsm6ds3, LSM6DS3TR_C_XL_ODR_208Hz);
//kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of set_acc_data_rate is:""%d", error);
//if(error!= STATUS_OK) return error;
//error = lsm6ds3tr_c_gy_data_rate_set(&lsm6ds3, LSM6DS3TR_C_GY_ODR_208Hz);
//kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of set_gry_data_rate is:""%d", error);
//if(error!= STATUS_OK) return error;
//enable block data update
error = lsm6ds3tr_c_block_data_update_set(&lsm6ds3, PROPERTY_ENABLE);
kal_prompt_trace(MOD_ABM, "YOUNG TEST:DBG error of block_data_update is:""%d", error);
if(error!= STATUS_OK) return error;
/*AAKASH
*Enable Tap Detection on X, Y, Z
*/
lsm6ds3tr_c_tap_detection_on_z_set(&lsm6ds3, PROPERTY_ENABLE);
lsm6ds3tr_c_tap_detection_on_y_set(&lsm6ds3, PROPERTY_ENABLE);
lsm6ds3tr_c_tap_detection_on_x_set(&lsm6ds3, PROPERTY_ENABLE);
lsm6ds3tr_c_4d_mode_set(&lsm6ds3, PROPERTY_ENABLE);
/*AAKASH
*Set Tap threshold to 01001b, therefore the tap threshold is
*562.5 mg (= 9 * FS_XL / 25)
*/
lsm6ds3tr_c_tap_threshold_x_set(&lsm6ds3, 0x09);
lsm6ds3tr_c_tap_quiet_set(&lsm6ds3, 1);
lsm6ds3tr_c_tap_shock_set(&lsm6ds3, 2);
lsm6ds3tr_c_tap_mode_set(&lsm6ds3, LSM6DS3TR_C_ONLY_SINGLE);
//Set FIFO watermark to a multiple of a pattern
pattern_len = 12;
lsm6ds3tr_c_fifo_watermark_set(&lsm6ds3, 10*pattern_len);
//Set FIFO mode to Stream mode
lsm6ds3tr_c_fifo_mode_set(&lsm6ds3, LSM6DS3TR_C_STREAM_MODE);
//Enable FIFO watermark interrupt generation on INT1 pin
lsm6ds3tr_c_pin_int1_route_get(&lsm6ds3, &int_1_reg);
int_1_reg.int1_fth = PROPERTY_ENABLE;
//int_1_reg.int1_fifo_ovr = PROPERTY_ENABLE;
int_1_reg.int1_full_flag = PROPERTY_ENABLE;
int_1_reg.int1_single_tap = PROPERTY_ENABLE;
lsm6ds3tr_c_pin_int1_route_set(&lsm6ds3, int_1_reg);
//Set FIFO sensor decimator
lsm6ds3tr_c_fifo_xl_batch_set(&lsm6ds3, LSM6DS3TR_C_FIFO_XL_NO_DEC);
lsm6ds3tr_c_fifo_gy_batch_set(&lsm6ds3, LSM6DS3TR_C_FIFO_GY_NO_DEC);
//Set ODR FIFO
lsm6ds3tr_c_fifo_data_rate_set(&lsm6ds3, LSM6DS3TR_C_FIFO_12Hz);
//Set XL and Gyro Output Data Rate:
lsm6ds3tr_c_xl_data_rate_set(&lsm6ds3, LSM6DS3TR_C_GY_ODR_26Hz);
lsm6ds3tr_c_gy_data_rate_set(&lsm6ds3, LSM6DS3TR_C_XL_ODR_26Hz);
#endif
return STATUS_OK;}
|