mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 05:51:36 +08:00
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:
committed by
Lorenz Meier
parent
3f0d26c949
commit
fc30f2906f
@@ -375,9 +375,9 @@ int MPU9250::reset()
|
|||||||
{
|
{
|
||||||
irqstate_t state;
|
irqstate_t state;
|
||||||
|
|
||||||
// Hold off sampling for 4 ms
|
// Hold off sampling until done (100 MS will be shortened)
|
||||||
state = px4_enter_critical_section();
|
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);
|
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;
|
return all_ok ? OK : -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,13 +730,7 @@ MPU9250::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
||||||
case SENSORIOCRESET: {
|
case SENSORIOCRESET: {
|
||||||
int ret = reset();
|
return reset();
|
||||||
|
|
||||||
if (_whoami == MPU_WHOAMI_9250) {
|
|
||||||
return (ret == OK ? _mag->ioctl(filp, cmd, arg) : ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SENSORIOCSPOLLRATE: {
|
case SENSORIOCSPOLLRATE: {
|
||||||
|
|||||||
Reference in New Issue
Block a user