Merge pull request #678 from k-korn/master
Add ADS1015 support to ads111x lib.
This commit is contained in:
commit
f82a420b87
2 changed files with 29 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -22,6 +22,16 @@ extern "C" {
|
|||
#define ADS111X_ADDR_SCL 0x4b
|
||||
|
||||
#define ADS111X_MAX_VALUE 0x7fff
|
||||
#define ADS101X_MAX_VALUE 0x7ff
|
||||
|
||||
// ADS101X overrides
|
||||
#define ADS101X_DATA_RATE_128 ADS111X_DATA_RATE_8
|
||||
#define ADS101X_DATA_RATE_250 ADS111X_DATA_RATE_16
|
||||
#define ADS101X_DATA_RATE_490 ADS111X_DATA_RATE_32
|
||||
#define ADS101X_DATA_RATE_920 ADS111X_DATA_RATE_64
|
||||
#define ADS101X_DATA_RATE_1600 ADS111X_DATA_RATE_128
|
||||
#define ADS101X_DATA_RATE_2400 ADS111X_DATA_RATE_250
|
||||
#define ADS101X_DATA_RATE_3300 ADS111X_DATA_RATE_475
|
||||
|
||||
/**
|
||||
* Gain amplifier
|
||||
|
@ -140,6 +150,13 @@ void ads111x_start_conversion(i2c_dev_t *dev);
|
|||
*/
|
||||
int16_t ads111x_get_value(i2c_dev_t *dev);
|
||||
|
||||
/**
|
||||
* Read last conversion result for 101x
|
||||
* @param addr
|
||||
* @return Last conversion result
|
||||
*/
|
||||
int16_t ads101x_get_value(i2c_dev_t *dev);
|
||||
|
||||
/**
|
||||
* Read the programmable gain amplifier configuration
|
||||
* (ADS1114 and ADS1115 only).
|
||||
|
|
Loading…
Reference in a new issue