Closed len0rd closed 7 years ago
Looks like most of the mpu6000 init stuff I was worried about is handled in mpu6000_spi constructor. At this point i think the biggest thing to check is the spi.transfer and spi.set_ss_low/high functions.
It may be necessary to adjust the baudrate_prescaler to adhere to mpu6000 1Mhz max
now might be a good time to try configuring the nss pin as od with no pull
Running out of ideas, perhaps using spi with the mpu is spec'ed differently than I'm assuming. I hooked up the logic analyzer to SPI2, which comes out the Flex-IO port. SPI seems to work fine, the only strange thing is on this particular transfer, MOSI changes from inactive high to inactive low, despite setting it to have a PU resistor in the GPIO conf:
In the code, its this send, in the mpu6000_spi constructor:
spi->send(MPU_RA_SIGNAL_PATH_RESET, 0x07);//BIT_GYRO | BIT_ACC | BIT_TEMP);
Not sure if this could cause issue, but its certainly unexpected. Also need to test the receive function
Think I finally have this working! At least I'm getting data back, so that's good. I kind of ended up rewriting all of the spi and mpu stuff though, so its going to be a few messy commits here...
blink and spi examples are working! (vcp would be totally broken even if I didnt remove the vcp.cpp files. Planning on fixing next) Currently mpu just spits back the raw int16_t data of all the sensors, which I think is fine since this is how the breezy mpu6050 driver works. Next is getting exti working, however I think working pwm may take priority over that.
Nice!!
closing for now
Just going to use this to keep track of some thoughts, if anyone wants to join in and help.
From the F2 std_periph documentation(pg 484), I think current implementation is a little shaky on steps 2&3:
Also, reading the f4 reference, I think we want NSS to be in SPI_NSS_Hard mode:
This is the functionality required by the mpu6000. The SPI1 NSS line is connected to a pull-up resistor, so it needs to be driven low whenever we want to send/receive data.