user31592: I'm trying (for sport...) to use an MPU-9250 in SPI mode as it should be faster, and wasn't able to talk to the embedded magnetometer in my code.
I've gone through the documentation (RM-MPU-9250A-00 v1.4) which is a bit spartan on that subject but gives the rough idea, it should work by enabling the built-in I2C master feature and using "proxy" I2C registers; I've tried to "do as it says" to communicate with the magnetometer; I'm querying the magnetometer identification register, and I only see 0x00 in there.
I searched in nature, and couldn't find an example of F/LOSS software using an external sensor plugged on the MPU.
Perhaps I've done something wrong but I can't see it, so here's a bottle in the ocean :)

user31592: It turns out that my mistake was in the SPI communication code, but nevertheless here is some info because it's not very obvious.
I went over the top and:

Review the electrical interface to see whether by any chance, my chip was badly hooked-up. Everything was fine.
Enabled register read-back and saw that... owww, it was bad.
Reviewing PS-MPU-9250A-01 § 7.5 SPI Interface I saw that I had made a stupid copy&paste error in my code... when copying my read code over to the write I forgot to adjust the MSB of the first spi byte.

Then:

I2C_MST_P_NSR=1 seems important or we get zeros
basic config in there, currently using the I2C proxy to read the magnetometer, and I don't like having a sleep to wait for I2C transfers to happen or not, but this is a WIP and the code won't go anywhere.


31592: <p>I'm trying (for sport...) to use an MPU-9250 in SPI mode as it should be faster, and wasn't able to talk to the embedded magnetometer <a href="https://github.com/exmakhina/libimu/commit/27fc4e7bbfda87061ca8e1bfd4b0121ef318199b" rel="nofollow noreferrer">in my code</a>.</p>

<p>I've gone through the documentation (RM-MPU-9250A-00 v1.4) which is a bit spartan on that subject but gives the rough idea, it should work by enabling the built-in I2C master feature and using "proxy" I2C registers; I've tried to "do as it says" to communicate with the magnetometer; I'm querying the magnetometer identification register, and I only see 0x00 in there.</p>

<p>I searched in nature, and couldn't find an example of F/LOSS software using an external sensor plugged on the MPU.</p>

<p>Perhaps I've done something wrong but I can't see it, so here's a bottle in the ocean :)</p>
 31592: <p>It turns out that my mistake was in the SPI communication code, but nevertheless here is some info because it's not very obvious.</p>

<p>I went over the top and:</p>

<ul>
<li>Review the electrical interface to see whether by any chance, my chip was badly hooked-up. Everything was fine.</li>
<li>Enabled register read-back and saw that... owww, it was bad.</li>
<li>Reviewing <em>PS-MPU-9250A-01 § 7.5 SPI Interface</em> I saw that I had made a stupid copy&amp;paste error in my code... when copying my read code over to the write I forgot to adjust the MSB of the first spi byte.</li>
</ul>

<p>Then:</p>

<ul>
<li>I2C_MST_P_NSR=1 seems important or we get zeros</li>
<li>basic config <a href="https://github.com/exmakhina/libimu/blob/c68e38c897b8604e30da9afb25a6dd070bb98458/imu_mpu9250.i#L346" rel="nofollow noreferrer">in there</a>, currently using the I2C proxy to read the magnetometer, and I don't like having a sleep to wait for I2C transfers to happen or not, but this is a WIP and the code won't go anywhere.</li>
</ul>
