/** Main callback to generate HAL outputs. Typically not called by library users. */ inv_error_t inv_generate_datalogger_outputs(struct inv_sensor_cal_t *sensor_cal) { memcpy(&dl_out.sc, sensor_cal, sizeof(struct inv_sensor_cal_t)); inv_get_quaternion_set(dl_out.quat, &dl_out.quat_accuracy, &dl_out.quat_timestamp); return INV_SUCCESS; }
static inv_error_t inv_generate_eMPL_outputs (struct inv_sensor_cal_t *sensor_cal) { int use_sensor; long sr = 1000; inv_get_quaternion_set(eMPL_out.quat, &eMPL_out.quat_accuracy, &eMPL_out.nine_axis_timestamp); eMPL_out.gyro_status = sensor_cal->gyro.status; eMPL_out.accel_status = sensor_cal->accel.status; eMPL_out.compass_status = sensor_cal->compass.status; /* Find the highest sample rate and tie sensor fusion timestamps to that one. */ if (sensor_cal->gyro.status & INV_SENSOR_ON) { sr = sensor_cal->gyro.sample_rate_ms; use_sensor = 0; } if ((sensor_cal->accel.status & INV_SENSOR_ON) && (sr > sensor_cal->accel.sample_rate_ms)) { sr = sensor_cal->accel.sample_rate_ms; use_sensor = 1; } if ((sensor_cal->compass.status & INV_SENSOR_ON) && (sr > sensor_cal->compass.sample_rate_ms)) { sr = sensor_cal->compass.sample_rate_ms; use_sensor = 2; } if ((sensor_cal->quat.status & INV_SENSOR_ON) && (sr > sensor_cal->quat.sample_rate_ms)) { sr = sensor_cal->quat.sample_rate_ms; use_sensor = 3; } switch (use_sensor) { default: case 0: eMPL_out.nine_axis_status = (sensor_cal->gyro.status & INV_NEW_DATA) ? 1 : 0; eMPL_out.nine_axis_timestamp = sensor_cal->gyro.timestamp; break; case 1: eMPL_out.nine_axis_status = (sensor_cal->accel.status & INV_NEW_DATA) ? 1 : 0; eMPL_out.nine_axis_timestamp = sensor_cal->accel.timestamp; break; case 2: eMPL_out.nine_axis_status = (sensor_cal->compass.status & INV_NEW_DATA) ? 1 : 0; eMPL_out.nine_axis_timestamp = sensor_cal->compass.timestamp; break; case 3: eMPL_out.nine_axis_status = (sensor_cal->quat.status & INV_NEW_DATA) ? 1 : 0; eMPL_out.nine_axis_timestamp = sensor_cal->quat.timestamp; break; } return INV_SUCCESS; }