l3gd20: add l3gd20h chipid to ctor check as well

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson 2016-08-10 12:59:54 -06:00
parent 06ecae7212
commit e689dc175c
2 changed files with 6 additions and 2 deletions

View File

@ -134,11 +134,13 @@ L3GD20::L3GD20(int bus, int addr)
// check ChipID
uint8_t cid = getChipID();
if (cid != L3GD20_DEFAULT_CHIP_ID)
if (!(cid == L3GD20_DEFAULT_CHIP_ID || cid == L3GD20H_DEFAULT_CHIP_ID))
{
throw std::runtime_error(std::string(__FUNCTION__) +
": invalid Chip ID: expected "
": Invalid Chip ID: expected "
+ std::to_string(L3GD20_DEFAULT_CHIP_ID)
+ " or "
+ std::to_string(L3GD20H_DEFAULT_CHIP_ID)
+ ", got "
+ std::to_string(int(cid)));
return;

View File

@ -35,6 +35,8 @@
// if SDO tied to GND
#define L3GD20_DEFAULT_I2C_ADDR 0x6a
#define L3GD20_DEFAULT_CHIP_ID 0xd4
// the 'H' variant uses a different chip id
#define L3GD20H_DEFAULT_CHIP_ID 0xd7
namespace upm
{