Adafruit_LSM6DSL.cpp 1.3 KB

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