I am using MPU9250 to become familiar with Accelerometers and Gyroscope and eventually apply that knowledge by implementing Sensor fusion. I am using SPI to communicate with that chip.
Strangely I noticed that when
Code: Select all
spiExchangeCode: Select all
spiSendCode: Select all
spiReceiveIf I send and receive only one byte
Code: Select all
spiExchange Code: Select all
spiExchangeHere is a code that works with
Code: Select all
spiExcangeCode: Select all
WHO_AM_ICode: Select all
spiAcquireBus(&SPID2);
spiStart(&SPID2, &spiConfig);
spiSelect(&SPID2);
spiExchange(&SPID2, 2, &txbuf, &rxbuf);
chprintf(chp, "Sending data over SPI %x\n", txbuf[0]);
chprintf(chp, "Second byte : %x\n", txbuf[1]);
chprintf(chp, "Received data over SPI %x\n", rxbuf[1]);
spiUnselect(&SPID2);
spiReleaseBus(&SPID2);
chThdSleepMilliseconds(10);
The above code works as I am just reading one byte, but If i want to get Accelerometer data, then I should read 6 bytes and it only works If I use
Code: Select all
spiSendHas anybody worked with this chip(MPU9250) and will I get any advantages if I switch to
Code: Select all
spiExchangeIf further code is needed, I can share it.
Please let me know whether I need to spend time on this or I can let it go by thinking that it might be MPU9250s fault?