mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
mpu9250:reset the mag on the reset operation
This commit fixed a bug were the mag was orphened on a reset. That resulted in MAG timeouts on reset or test operations and left the mag in a broken state.
This commit is contained in:
parent
8bd044e80e
commit
fbf6532c25
@ -297,11 +297,7 @@ MPU9250_mag::ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
switch (cmd) {
|
||||
|
||||
case SENSORIOCRESET:
|
||||
/*
|
||||
* TODO: we could implement a reset of the AK8963 registers
|
||||
*/
|
||||
//return reset();
|
||||
return _parent->ioctl(filp, cmd, arg);
|
||||
return ak8963_reset();
|
||||
|
||||
case SENSORIOCSPOLLRATE: {
|
||||
switch (arg) {
|
||||
@ -508,10 +504,23 @@ MPU9250_mag::write_reg(unsigned reg, uint8_t value)
|
||||
|
||||
|
||||
|
||||
void
|
||||
int
|
||||
MPU9250_mag::ak8963_reset(void)
|
||||
{
|
||||
write_reg(AK8963REG_CNTL2, AK8963_RESET);
|
||||
// First initialize it to use the bus
|
||||
|
||||
int rv = ak8963_setup();
|
||||
|
||||
if (rv == OK) {
|
||||
|
||||
// Now reset the mag
|
||||
write_reg(AK8963REG_CNTL2, AK8963_RESET);
|
||||
// Then re-initialize the bus/mag
|
||||
rv = ak8963_setup();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@ -720,8 +720,15 @@ MPU9250::ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
|
||||
case SENSORIOCRESET:
|
||||
return reset();
|
||||
case SENSORIOCRESET: {
|
||||
int ret = reset();
|
||||
|
||||
if (_whoami == MPU_WHOAMI_9250) {
|
||||
return (ret == OK ? _mag->ioctl(filp, cmd, arg) : ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
case SENSORIOCSPOLLRATE: {
|
||||
switch (arg) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user