/* Reads three signed 16 bit values over I2C.  */
err_t lsm303magRead48(uint8_t addr, uint8_t reg, uint8_t buffer[6])
/* Reads three signed 16 bit values over I2C.  */
err_t lsm303magRead48(uint8_t addr, uint8_t reg, uint8_t buffer[6])
{
  I2CWriteLength = 2;
  I2CReadLength = 0;
  I2CMasterBuffer[0] = addr;
  I2CMasterBuffer[1] = reg | (0x80);
  i2cEngine();
  I2CWriteLength = 0;
  I2CReadLength = 6;
  I2CMasterBuffer[0] = addr | 0x01;
  ASSERT_I2C_STATUS(i2cEngine());
  uint8_t i;
  for (i = 0; i < 6; i++)
  {
    buffer[i] = I2CSlaveBuffer[i];
  }
  return ERROR_NONE;
}