src/LSM6.cpp
// Reads the 3 gyro channels and stores them in vector g
Reads the 3 gyro channels and stores them in vector g
Reads the 3 gyro channels and stores them in vector g
void LSM6::readGyro(void)
{
  Wire.beginTransmission(address);
  Wire.write(OUTX_L_G);
  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 xlg = Wire.read();
  uint8_t xhg = Wire.read();
  uint8_t ylg = Wire.read();
  uint8_t yhg = Wire.read();
  uint8_t zlg = Wire.read();
  uint8_t zhg = Wire.read();
  g.x = (int16_t)(xhg << 8 | xlg);
  g.y = (int16_t)(yhg << 8 | ylg);
  g.z = (int16_t)(zhg << 8 | zlg);
  dps.x = g.x * mdps / 1000.;
  dps.y = g.y * mdps / 1000.;
  dps.z = g.z * mdps / 1000.;
}
void LSM6 :: readGyro ( void ) { Wire . beginTransmission ( address ) ; Wire . write ( OUTX_L_G ) ; 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 xlg = Wire . read ( ) ; uint8_t xhg = Wire . read ( ) ; uint8_t ylg = Wire . read ( ) ; uint8_t yhg = Wire . read ( ) ; uint8_t zlg = Wire . read ( ) ; uint8_t zhg = Wire . read ( ) ; g . x = ( int16_t ) ( xhg << 8 | xlg ) ; g . y = ( int16_t ) ( yhg << 8 | ylg ) ; g . z = ( int16_t ) ( zhg << 8 | zlg ) ; dps . x = g . x * mdps / 1000. ; dps . y = g . y * mdps / 1000. ; dps . z = g . z * mdps / 1000. ; }
Reads the 3 gyro channels and stores them in vector g
Reads the 3 gyro channels and stores them in vector g
// automatic increment of register address is enabled by default (IF_INC in CTRL3_C) // combine high and low bytes