mpu9250:Use a cpu speed independant _reset_wait generations.

This change first pushes out the _reset_wait by 100 Ms.
   which is about 3 time longer then the code take to execute.

   Then it does the reset of the accel, gyro and mag and
   the ends the wait by setting _reset_wait to now+10 us.
This commit is contained in:
David Sidrane
2017-07-10 15:45:29 -10:00
committed by Lorenz Meier
parent 3f0d26c949
commit fc30f2906f

View File

@@ -375,9 +375,9 @@ int MPU9250::reset()
{
irqstate_t state;
// Hold off sampling for 4 ms
// Hold off sampling until done (100 MS will be shortened)
state = px4_enter_critical_section();
_reset_wait = hrt_absolute_time() + 10000;
_reset_wait = hrt_absolute_time() + 100000;
write_reg(MPUREG_PWR_MGMT_1, BIT_H_RESET);
@@ -453,6 +453,15 @@ int MPU9250::reset()
}
}
if (all_ok && _whoami == MPU_WHOAMI_9250) {
all_ok = _mag->ak8963_reset() == OK;
}
state = px4_enter_critical_section();
_reset_wait = hrt_absolute_time() + 10;
px4_leave_critical_section(state);
return all_ok ? OK : -EIO;
}
@@ -721,13 +730,7 @@ MPU9250::ioctl(struct file *filp, int cmd, unsigned long arg)
switch (cmd) {
case SENSORIOCRESET: {
int ret = reset();
if (_whoami == MPU_WHOAMI_9250) {
return (ret == OK ? _mag->ioctl(filp, cmd, arg) : ret);
}
return ret;
return reset();
}
case SENSORIOCSPOLLRATE: {