Note: I was still running into some of them having issues at startup...
And some of their (BNO080) does not make sense to me...
That is if I understand correctly, the code like: ::getData.
Does something like: _i2cPort->requestFrom(...)
It does not look at return value... Then it calls waitForI2C().
Code:
boolean BNO080::waitForI2C()
{
for (uint8_t counter = 0; counter < 100; counter++) //Don't got more than 255
{
if (_i2cPort->available() > 0)
return (true);
delay(1);
}
if (_printDebug == true)
_debugPort->println(F("I2C timeout"));
return (false);
}
Now I may be completely out to lunch (or maybe dinner
) but I don't get this function?
I believe that the requestFrom will wait for the conversation to be complete? And returns how many bytes were received over I2C.
And the read functions, indexes into this from 0 to the number o bytes received in requestFrom. And more specifically available() simply returns the count of how many bytes were transferred during the requestFrom minus the index used in the read function.
So more specifically if: if (_i2cPort->available() > 0)
fails once (i.e. available == 0), it will continue to fail every call through that counter... i.e. there is nothing still active receiving data from the device that increments some counter?
So in the case of the failure I was seing where the Start Read fails with NAK, I believe the count would be 0...
So again maybe missing something obvious...