Hi Robin, Thanks for the reply. Not sure what you mean by your question, but we do something like this: void inertial_sensor_interrupt_handler_blocking(void)
{
NRF_LOG_INFO("Read blocking start");
nrf_gpio_pin_set(TOGGLE_PIN);
waiting_flag = true;
uint8_t data = 0x00;
fifo_counter++;
fifo_interrupt_time_stamp = time_stamp_get_time_since_boot();
NRF_LOG_INFO("IMU interrupt Elapsed time since boot %i", fifo_interrupt_time_stamp);
if(inertial_sensor_get_fifo_new_data_flag()){
NRF_LOG_INFO("FIFO DATA OVERWRITTEN WITHOUT READING!");
}
inertial_sensor_set_fifo_new_data_flag();
/* Disable the WM interrupt */
bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, &inertial_sensor);
/* Check what the available amount of data is prior to FIFO read out */
uint16_t available_data_pre;
available_data_pre = inertial_sensor_fifo_available_amount_of_data(&inertial_sensor);
NRF_LOG_INFO("%i bytes of available data prior to FIFO read out", available_data_pre);
/* Read data from the sensor's FIFO and store it the FIFO buffer,"fifo_buff" */
inertial_sensor_fifo_read(&inertial_sensor);
/* Enable the WM interrupt */
data = BMI160_FIFO_WATERMARK_INT_EN_MASK;
bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, &inertial_sensor);
nrf_gpio_pin_clear(TOGGLE_PIN);
NRF_LOG_INFO("Read blocking stop");
}
int8_t inertial_sensor_fifo_read(struct bmi160_dev *dev)
{
int8_t rslt = 0;
/* Modify the FIFO buffer instance and link to the device instance */
dev->fifo->length = FIFO_SIZE;
/* Initialization of variables */
uint16_t index = 0;
uint8_t gyro_index = 0;
uint8_t accel_index = 0;
uint8_t gyro_frames_req = GYR_FRAMES;
uint8_t accel_frames_req = ACC_FRAMES;
NRF_LOG_INFO("\n USER REQUESTED FIFO LENGTH : %d\n",dev->fifo->length);
/* Read the data from the FIFO buffer */
rslt = bmi160_get_fifo_data(dev);
if (rslt == BMI160_OK) {
NRF_LOG_INFO("\n AVAILABLE FIFO LENGTH : %d\n",dev->fifo->length);
/* Print the raw FIFO data */
//for (index = 0; index < dev->fifo->length; index++) {
// NRF_LOG_INFO("\n FIFO DATA INDEX[%d] = %d", index,
// dev->fifo->data[index]);
//}
NRF_LOG_INFO("\n REQUESTED GYRO DATA FRAMES : %d\n ",gyro_frames_req);
/* Parse the FIFO data to extract gyroscope data from the FIFO buffer */
rslt = bmi160_extract_gyro(&gyro_data, &gyro_frames_req, dev);
if (rslt == BMI160_OK) {
NRF_LOG_INFO("\n AVAILABLE GYRO DATA FRAMES : %d\n ",gyro_frames_req);
/* Print the parsed gyro data from the FIFO buffer */
//for (gyro_index = 0 ; gyro_index <gyro_frames_req ; gyro_index++) {
// NRF_LOG_INFO("\nFIFO GYRO FRAME[%d]",gyro_index);
//NRF_LOG_INFO("\nGYRO X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
// ,gyro_data[gyro_index].x ,gyro_data[gyro_index].y
// ,gyro_data[gyro_index].z);
//}
/*Print a sample as speed is too high*/
NRF_LOG_INFO("\nGYRO X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
,gyro_data[18].x ,gyro_data[18].y
,gyro_data[18].z);
/* Print the special FIFO frame data like sensortime */
//NRF_LOG_INFO("\n SENSOR TIME DATA : %d \n",dev->fifo->sensor_time);
//NRF_LOG_INFO("SKIPPED FRAME COUNT : %d",dev->fifo->skipped_frame_count);
} else {
NRF_LOG_INFO("\n Gyro data extraction failed");
}
NRF_LOG_INFO("\n REQUESTED ACCEL DATA FRAMES : %d\n ",accel_frames_req);
/* Parse the FIFO data to extract accelerometer data from the FIFO buffer */
rslt = bmi160_extract_accel(&accel_data, &accel_frames_req, dev);
if (rslt == BMI160_OK) {
NRF_LOG_INFO("\n AVAILABLE ACCEL DATA FRAMES : %d\n ",accel_frames_req);
/* Print the parsed accel data from the FIFO buffer */
//for (accel_index = 0; accel_index < accel_frames_req; accel_index++) {
// printf("\nFIFO ACCEL FRAME[%d]",accel_index);
// printf("\nACCEL X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
// ,accel_data[accel_index].x ,accel_data[accel_index].y
// ,accel_data[accel_index].z);
//}
/*Print a sample as speed is too high*/
NRF_LOG_INFO("\nACCEL X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
,accel_data[60].x ,accel_data[60].y
,accel_data[60].z);
/* Print the special FIFO frame data like sensortime */
//NRF_LOG_INFO("\n SENSOR TIME DATA : %d \n",dev->fifo->sensor_time);
//NRF_LOG_INFO("SKIPPED FRAME COUNT : %d",dev->fifo->skipped_frame_count);
} else {
NRF_LOG_INFO("\n Accel data extraction failed");
}
} else {
NRF_LOG_INFO("\n Reading FIFO data failed");
}
return rslt;
} I don't fully understand how that would be influenced by the sensor moving or not. Best regards, Michiel
... View more