src/Adafruit_MSA301.cpp
/*!
 *    @brief  Sets up the hardware and initializes I2C
 *    @param  i2c_address
 *            The I2C address to be used.
 *    @param  wire
 *            The Wire object to be used for I2C connections.
 *    @return True if initialization was successful, otherwise false.
 */
@brief  Sets up the hardware and initializes I2C
@param  i2c_address
The I2C address to be used.
@param  wire
The Wire object to be used for I2C connections.
@return True if initialization was successful, otherwise false.
@brief Sets up the hardware and initializes I2C @param i2c_address The I2C address to be used . @param wire The Wire object to be used for I2C connections . @return True if initialization was successful otherwise false .
bool Adafruit_MSA301::begin(uint8_t i2c_address, TwoWire *wire) {
  i2c_dev = new Adafruit_I2CDevice(i2c_address, wire);
  if (!i2c_dev->begin()) {
    Serial.println("Failed to init i2c address");
    return false;
  }
  Adafruit_BusIO_Register chip_id =
      Adafruit_BusIO_Register(i2c_dev, MSA301_REG_PARTID, 1);
  if (chip_id.read() != 0x13) {
    return false;
  }
  enableAxes(true, true, true);
  setPowerMode(MSA301_NORMALMODE);
  setDataRate(MSA301_DATARATE_500_HZ);
  setBandwidth(MSA301_BANDWIDTH_250_HZ);
  setRange(MSA301_RANGE_4_G);
  setResolution(MSA301_RESOLUTION_14);
  return true;
}
bool Adafruit_MSA301 :: begin ( uint8_t i2c_address , TwoWire * wire ) { i2c_dev = new Adafruit_I2CDevice ( i2c_address , wire ) ; if ( ! i2c_dev -> begin ( ) ) { Serial . println ( " " ) ; return false ; } Adafruit_BusIO_Register chip_id = Adafruit_BusIO_Register ( i2c_dev , MSA301_REG_PARTID , 1 ) ; if ( chip_id . read ( ) != 0x13 ) { return false ; } enableAxes ( true , true , true ) ; setPowerMode ( MSA301_NORMALMODE ) ; setDataRate ( MSA301_DATARATE_500_HZ ) ; setBandwidth ( MSA301_BANDWIDTH_250_HZ ) ; setRange ( MSA301_RANGE_4_G ) ; setResolution ( MSA301_RESOLUTION_14 ) ; return true ; }
@brief  Sets up the hardware and initializes I2C
    @param  i2c_address
            The I2C address to be used.
@brief Sets up the hardware and initializes I2C @param i2c_address The I2C address to be used .
// Check connection // make sure we're talking to the right chip // No MSA301 detected ... return false // enable all axes // normal mode // 500Hz rate // 250Hz bw /*
  // DRDY on INT1
  writeRegister8(MSA301_REG_CTRL3, 0x10);

  // Turn on orientation config
  //writeRegister8(MSA301_REG_PL_CFG, 0x40);

  */ /*
  for (uint8_t i=0; i<0x30; i++) {
    Serial.print("$");
    Serial.print(i, HEX); Serial.print(" = 0x");
    Serial.println(readRegister8(i), HEX);
  }
  */