Not all I2C devices automatically increment the address like that - take a look at the datasheet...
Edit: Ahha! Here, pg 33, second paragraph:
In order to read multiple bytes, it is necessary to assert the most significant bit of the subaddress
field. In other words, SUB(7) must be equal to 1 while SUB(6-0) represents the
address of first register to be read.
And in sparkfun's code that's just what they do:
void LSM9DS0::I2CreadBytes(uint8_t address, uint8_t subAddress, uint8_t * dest, uint8_t count)
{
Wire.beginTransmission(address); // Initialize the Tx buffer
// Next send the register to be read. OR with 0x80 to indicate multi-read.
Wire.write(subAddress | 0x80); // Put slave register address in Tx buffer
Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive
uint8_t i = 0;
Wire.requestFrom(address, count); // Read bytes from slave register address
while (Wire.available())
{
dest[i++] = Wire.read(); // Put read results in the Rx buffer
}
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Not all I2C devices automatically increment the address like that - take a look at the datasheet...
Edit: Ahha! Here, pg 33, second paragraph:
And in sparkfun's code that's just what they do: