Adafruit_LSM6DS3.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*!
  2. * @file Adafruit_LSM6DS3.cpp Adafruit LSM6DS3 6-DoF Accelerometer
  3. * and Gyroscope library
  4. *
  5. * Bryan Siepert for Adafruit Industries
  6. * BSD (see license.txt)
  7. */
  8. #include "Arduino.h"
  9. #include <Wire.h>
  10. #include "Adafruit_LSM6DS3.h"
  11. /*!
  12. * @brief Instantiates a new LSM6DS3 class
  13. */
  14. Adafruit_LSM6DS3::Adafruit_LSM6DS3(void) {}
  15. bool Adafruit_LSM6DS3::_init(int32_t sensor_id) {
  16. // make sure we're talking to the right chip
  17. if (chipID() != LSM6DS3_CHIP_ID) {
  18. return false;
  19. }
  20. _sensorid_accel = sensor_id;
  21. _sensorid_gyro = sensor_id + 1;
  22. _sensorid_temp = sensor_id + 2;
  23. temperature_sensitivity = 16.0;
  24. reset();
  25. // call base class _init()
  26. Adafruit_LSM6DS::_init(sensor_id);
  27. return true;
  28. }
  29. /**************************************************************************/
  30. /*!
  31. @brief Enables and disables the I2C master bus pulllups.
  32. @param enable_pullups true to enable the I2C pullups, false to disable.
  33. */
  34. void Adafruit_LSM6DS3::enableI2CMasterPullups(bool enable_pullups) {
  35. Adafruit_BusIO_Register master_config = Adafruit_BusIO_Register(
  36. i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, LSM6DS3_MASTER_CONFIG);
  37. Adafruit_BusIO_RegisterBits i2c_master_pu_en =
  38. Adafruit_BusIO_RegisterBits(&master_config, 1, 3);
  39. i2c_master_pu_en.write(enable_pullups);
  40. }