src/LSM6.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 LSM6::readAcc(void)
{
  Wire.beginTransmission(address);
  Wire.write(OUTX_L_XL);
  Wire.endTransmission();
  Wire.requestFrom(address, (uint8_t)6);
  uint16_t millis_start = millis();
  while (Wire.available() < 6)
  {
    if (io_timeout > 0 && ((uint16_t)millis() - millis_start) > io_timeout)
    {
      did_timeout = true;
      return;
    }
  }
  uint8_t xla = Wire.read();
  uint8_t xha = Wire.read();
  uint8_t yla = Wire.read();
  uint8_t yha = Wire.read();
  uint8_t zla = Wire.read();
  uint8_t zha = Wire.read();
  a.x = (int16_t)(xha << 8 | xla);
  a.y = (int16_t)(yha << 8 | yla);
  a.z = (int16_t)(zha << 8 | zla);
}
void LSM6 :: readAcc ( void ) { Wire . beginTransmission ( address ) ; Wire . write ( OUTX_L_XL ) ; Wire . endTransmission ( ) ; Wire . requestFrom ( address , ( uint8_t ) 6 ) ; uint16_t millis_start = millis ( ) ; while ( Wire . available ( ) < 6 ) { if ( io_timeout > 0 && ( ( uint16_t ) millis ( ) - millis_start ) > io_timeout ) { did_timeout = true ; return ; } } uint8_t xla = Wire . read ( ) ; uint8_t xha = Wire . read ( ) ; uint8_t yla = Wire . read ( ) ; uint8_t yha = Wire . read ( ) ; uint8_t zla = Wire . read ( ) ; uint8_t zha = Wire . 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
// automatic increment of register address is enabled by default (IF_INC in CTRL3_C) // combine high and low bytes