Open enly1 opened 10 years ago
I have some STM32F103 boards laying around at work. Maybe I'll try it out if I have some spare time. Can't this issue fixed by ChibiOS instead? I would prefer that over adding hardware-specific code.
Its not a chibios issue as such - long running discussion, but the issue is do you read 2 bytes the one requested and another or the register before and the one after etc ... It kind of really should be dealt with in the upper layer code, but threw this in to get it going.
Not sure if this would be safe as a standard option, but for use with this i2c device it works well (so far in testing).
So it was just as much as a heads up than a planned commit suggestion.
To get the library to function and detect the MPU6050, I had to modify the I2CdevreadBytes function to add in specific support for the STM32F103 chip as in Chibios/Hardware, you are unable to read a single byte from the I2C bus.
It is reported as a hardware issue and the workaround is to read multiple bytes, so I patched the function to operate that way and the library is now functional.
Patched function code below:
int8_t I2CdevreadBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout) { //uint8_t mpu_txbuf[1], mpu_rxbuf[I2CDEV_BUFFER_LENGTH], i; msg_t rdymsg; uint8_t tmpdata[2];
if defined(STM32F1XX_I2C)
else
endif
}
Note that it could be made fractionally more efficient by wrapping uint8_t tmpdata[2]; with the #ifdef but I didn't test that before copy/pasting the code.