Library for the ADS1015 and ADS1115 ADCS
Fork of ADS1015 by
Diff: Adafruit_ADS1015.cpp
- Revision:
- 20:277793ce35b2
- Parent:
- 18:4b4e3446cdd4
- Child:
- 21:1ed94c2550b2
--- a/Adafruit_ADS1015.cpp Thu Jun 21 12:51:54 2018 +0000 +++ b/Adafruit_ADS1015.cpp Thu Jun 21 15:49:53 2018 +0000 @@ -103,67 +103,6 @@ return m_gain; } -int16_t * Adafruit_ADS1015::readADC_Differential_DoubleEnded(){ - - int16_t temp_res; - int16_t results[2]; - - uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE | // Disable the comparator (default val) - ADS1015_REG_CONFIG_CLAT_NONLAT | // Non-latching (default val) - ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) - ADS1015_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) - ADS1015_REG_CONFIG_DR_3300SPS | // 1600(ADS1015) or 250(ADS1115) samples per second (default) - ADS1015_REG_CONFIG_MODE_SINGLE; // Single-shot mode (default) - - // Set PGA/voltage range - config |= m_gain; - - // Set channels - config |= ADS1015_REG_CONFIG_MUX_DIFF_0_3; // AIN0 = P, AIN1 = N - - // Set 'start single-conversion' bit - config |= ADS1015_REG_CONFIG_OS_SINGLE; - - // Read the first - temp_res = readRegister(m_i2cAddress, ADS1015_REG_POINTER_CONVERT) >> m_bitShift; - - if (m_bitShift != 0) { - // Shift 12-bit results right 4 bits for the ADS1015, - // making sure we keep the sign bit intact - if (temp_res > 0x07FF) { - // negative number - extend the sign to 16th bit - temp_res |= 0xF000; - } - } - results[0] = temp_res; - - - // Write config register to the ADC - writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config); - - // Wait for the conversion to complete - wait_us(m_conversionDelay); - - // Read the conversion results - temp_res = readRegister(m_i2cAddress, ADS1015_REG_POINTER_CONVERT) >> m_bitShift; - - if (m_bitShift != 0) { - // Shift 12-bit results right 4 bits for the ADS1015, - // making sure we keep the sign bit intact - if (temp_res > 0x07FF) { - // negative number - extend the sign to 16th bit - temp_res |= 0xF000; - } - } - results[1] |= temp_res; - - config |= ADS1015_REG_CONFIG_MUX_DIFF_1_3; - - // Write config register to the ADC - writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config); - - return results; -} /**************************************************************************/ /*!