MPU9250 driver does not read mag sensor adjustment values correctly

Description

PIOS_MPU9250_Mag_Sensitivity() is severely broken and even recognized as such. It does currently hardcode adjustment values of 1.0 for all three axes.

There is also slight chance that using this incorrect SPI write sequence, mpu9250 sometimes get into unrecoverable state at system boot, fixable only by cycling power. (unfortunately not. Just got sensor to hang again).

Environment

None

Activity

Show:
TheOtherCliff
January 19, 2017, 9:02 PM

Is that why the MPU9250 has mag_transform values closer to 2.0 than to 1.0?

Vladimir Zidar
January 19, 2017, 9:12 PM

Could be. The actual values in my case are around 1.17, so this should lower the transform slightly, right?

I was also interested to find out about what happened in this function before the fix, since all SPI traffic between PIOS_MPU9250_ClaimBus() and PIOS_MPU9250_ReleaseBus() is considered as one multi byte write with automatic address increment.

The write started at register PIOS_MPU9250_I2C_SLV0_ADDR. There was actually 11 bytes written, overwriting all SLV0, SLV1, SLV2 and partially SLV3 set of registers, potentially triggering random internal I2C transfers!.

I really hope that this could be the reason for random 9250 lockups at boot, as I have observed same behavior on Sparky2, Falcon and now SPRacing F3_EVO.

Assignee

Vladimir Zidar

Reporter

Vladimir Zidar

Labels

None

Components

Fix versions

Affects versions

Priority

Medium
Configure