AP_OpticalFlow: reduce lock region

Release the lock as soon as we can.
This commit is contained in:
Lucas De Marchi 2015-11-02 13:19:39 -02:00 committed by Randy Mackay
parent 70edf31ca6
commit 0d95a9c41d

View File

@ -115,6 +115,13 @@ bool AP_OpticalFlow_Linux::read(optical_flow_s* report)
memcpy(&f_integral, val, I2C_INTEGRAL_FRAME_SIZE);
}
i2c_sem->give();
// reduce error count
if (num_errors > 0) {
num_errors--;
}
report->pixel_flow_x_integral = static_cast<float>(f_integral.pixel_flow_x_integral) / 10000.0f; //convert to radians
report->pixel_flow_y_integral = static_cast<float>(f_integral.pixel_flow_y_integral) / 10000.0f; //convert to radians
report->frame_count_since_last_readout = f_integral.frame_count_since_last_readout;
@ -128,13 +135,6 @@ bool AP_OpticalFlow_Linux::read(optical_flow_s* report)
report->gyro_temperature = f_integral.gyro_temperature; // Temperature * 100 in centi-degrees Celsius
report->sensor_id = 0;
i2c_sem->give();
// reduce error count
if (num_errors > 0) {
num_errors--;
}
return true;
fail_transfer: