Add ADS1015 support to ads111x lib.

This commit is contained in:
Korn 2018-08-22 19:04:18 +03:00 committed by GitHub
parent 47cc1770c5
commit b5b05286e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -93,6 +93,18 @@ int16_t ads111x_get_value(i2c_dev_t *dev)
return read_reg(dev, REG_CONVERSION);
}
int16_t ads101x_get_value(i2c_dev_t *dev)
{
uint16_t res = read_reg(dev, REG_CONVERSION) >> 4;
if (res > 0x07FF)
{
// negative number - extend the sign to 16th bit
res |= 0xF000;
}
return (int16_t)res;
}
ads111x_gain_t ads111x_get_gain(i2c_dev_t *dev)
{
return read_conf_bits(dev, PGA_OFFSET, PGA_MASK);