Browse Source

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.
sbg
David Sidrane 8 years ago committed by Lorenz Meier
parent
commit
fbf6532c25
  1. 23
      src/drivers/mpu9250/mag.cpp
  2. 11
      src/drivers/mpu9250/mpu9250.cpp

23
src/drivers/mpu9250/mag.cpp

@ -297,11 +297,7 @@ MPU9250_mag::ioctl(struct file *filp, int cmd, unsigned long arg)
switch (cmd) { switch (cmd) {
case SENSORIOCRESET: case SENSORIOCRESET:
/* return ak8963_reset();
* TODO: we could implement a reset of the AK8963 registers
*/
//return reset();
return _parent->ioctl(filp, cmd, arg);
case SENSORIOCSPOLLRATE: { case SENSORIOCSPOLLRATE: {
switch (arg) { switch (arg) {
@ -508,10 +504,23 @@ MPU9250_mag::write_reg(unsigned reg, uint8_t value)
void int
MPU9250_mag::ak8963_reset(void) 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 bool

11
src/drivers/mpu9250/mpu9250.cpp

@ -720,8 +720,15 @@ MPU9250::ioctl(struct file *filp, int cmd, unsigned long arg)
{ {
switch (cmd) { switch (cmd) {
case SENSORIOCRESET: case SENSORIOCRESET: {
return reset(); int ret = reset();
if (_whoami == MPU_WHOAMI_9250) {
return (ret == OK ? _mag->ioctl(filp, cmd, arg) : ret);
}
return ret;
}
case SENSORIOCSPOLLRATE: { case SENSORIOCSPOLLRATE: {
switch (arg) { switch (arg) {

Loading…
Cancel
Save