Arduino/LSM303Soft/LSM303Soft.cpp
// Reads the 3 accelerometer channels and stores them in vector a

Reads the 3 accelerometer channels and stores them in vector a
Reads the 3 accelerometer channels and stores them in vector a
void LSM303Soft::readAcc(void)
{
  SoftWire.beginTransmission(acc_address);
  SoftWire.write(OUT_X_L_A | (1 << 7));
  last_status = SoftWire.endTransmission();
  SoftWire.requestFrom(acc_address, (byte)6);
  unsigned int millis_start = millis();
  while (SoftWire.available() < 6) {
    if (io_timeout > 0 && ((unsigned int)millis() - millis_start) > io_timeout)
    {
      did_timeout = true;
      return;
    }
  }
  byte xla = SoftWire.read();
  byte xha = SoftWire.read();
  byte yla = SoftWire.read();
  byte yha = SoftWire.read();
  byte zla = SoftWire.read();
  byte zha = SoftWire.read();
  a.x = (int16_t)(xha << 8 | xla);
  a.y = (int16_t)(yha << 8 | yla);
  a.z = (int16_t)(zha << 8 | zla);
}
void LSM303Soft :: readAcc ( void ) { SoftWire . beginTransmission ( acc_address ) ; SoftWire . write ( OUT_X_L_A | ( 1 << 7 ) ) ; last_status = SoftWire . endTransmission ( ) ; SoftWire . requestFrom ( acc_address , ( byte ) 6 ) ; unsigned int millis_start = millis ( ) ; while ( SoftWire . available ( ) < 6 ) { if ( io_timeout > 0 && ( ( unsigned int ) millis ( ) - millis_start ) > io_timeout ) { did_timeout = true ; return ; } } byte xla = SoftWire . read ( ) ; byte xha = SoftWire . read ( ) ; byte yla = SoftWire . read ( ) ; byte yha = SoftWire . read ( ) ; byte zla = SoftWire . read ( ) ; byte zha = SoftWire . read ( ) ; a . x = ( int16_t ) ( xha << 8 | xla ) ; a . y = ( int16_t ) ( yha << 8 | yla ) ; a . z = ( int16_t ) ( zha << 8 | zla ) ; }
Reads the 3 accelerometer channels and stores them in vector a
Reads the 3 accelerometer channels and stores them in vector a
// assert the MSB of the address to get the accelerometer
 // to do slave-transmit subaddress updating.
 // combine high and low bytes
 // This no longer drops the lowest 4 bits of the readings from the DLH/DLM/DLHC, which are always 0
 // (12-bit resolution, left-aligned). The D has 16-bit resolution
