Multiple Byte Read from Accelerometer via i2c

Hi guys,

I am reading the H3lis100dl sensor (www.st.com/resource/en/datasheet/h3lis100dl.pdf). Here is the code I am using:

for(int i = 0; i < 6; i++)  
{    
// Start I2C Transmission    
Wire.beginTransmission(Addr);    
// Select data register    
Wire.write((40+i));    
// Stop I2C Transmission    
Wire.endTransmission();
// Request 1 byte of data    
Wire.requestFrom(Addr, 1);    
// Read 6 bytes of data    
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb    
if(Wire.available() == 1)    
{      
data[i] = Wire.read();    
}  
}

This is how I read the 6 byte data containing the LSB and MSB of each axis. Here I have to start, send the register add, read and end and this has to be done six times.

But what I want is to start the communication, send the register address and wait until I have read all the 6 bytes and then end the communication. From what I have read from the datasheet at page 19/38 it seems possible. But it would be great if someone could help with visualization of the code.

Here is my attempt at it. I have made the 7th bit high and thus the address becomes 104.

Wire.beginTransmission(Addr);    
// Select data register    
Wire.write(104);    
// Request 6 byte of data    
Wire.requestFrom(Addr, 6);    
// Read 6 bytes of data    
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb    
if(Wire.available() == 1)    
{      
//data[i] = Wire.read();  //  Not sure how to do the read for 6 bytes
}  
Wire.endTransmission();
  1. define char xyz[3]; // char is -128 .. +127 (2's compl)

  2. start transm.. set up sensor .. set pointer to register 0x29 // the put_x

  3. request 6 bytes (but store 3 of then only.

for (byte i=0; i<3; i++)
{ xyz[ i ] = Wire.read(); Wire.read(); }

..use the values as numbers

==========
addition from datasheet

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.