コード例 #1
0
ファイル: LPS331.cpp プロジェクト: omoty/lps331-arduino
bool LPS331::autoDetectAddress(void)
{
  // try each possible address and stop if reading WHO_AM_I returns the expected response
  address = LPS331AP_ADDRESS_SA0_LOW;
  if (testWhoAmI()) return true;
  address = LPS331AP_ADDRESS_SA0_HIGH;
  if (testWhoAmI()) return true;

  return false;
}
コード例 #2
0
ファイル: LPS331.cpp プロジェクト: omoty/lps331-arduino
// sets or detects slave address; returns bool indicating success
bool LPS331::init(byte sa0)
{
  switch(sa0)
  {
    case LPS331_SA0_LOW:
      address = LPS331AP_ADDRESS_SA0_LOW;
      return testWhoAmI();

    case LPS331_SA0_HIGH:
      address = LPS331AP_ADDRESS_SA0_HIGH;
      return testWhoAmI();

    default:
      return autoDetectAddress();
  }
}
コード例 #3
0
ファイル: LPS.cpp プロジェクト: zh-lim/Data-Delivery
bool LPS::detectDevice(deviceType device)
{
  int id = testWhoAmI(address);
  
  if ((device == device_auto || device == device_25H) && id == LPS25H_WHO_ID)
  {
    _device = device_25H;
    return true;
  }
  if ((device == device_auto || device == device_331AP) && id == LPS331AP_WHO_ID)
  {
    _device = device_331AP;
    return true;
  }

  return false;
}