diff options
Diffstat (limited to 'peripheral/libupm/src/ads1x15/ads1015.cxx')
-rw-r--r-- | peripheral/libupm/src/ads1x15/ads1015.cxx | 68 |
1 files changed, 2 insertions, 66 deletions
diff --git a/peripheral/libupm/src/ads1x15/ads1015.cxx b/peripheral/libupm/src/ads1x15/ads1015.cxx index d49b83d..1beef3d 100644 --- a/peripheral/libupm/src/ads1x15/ads1015.cxx +++ b/peripheral/libupm/src/ads1x15/ads1015.cxx @@ -21,7 +21,7 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "ads1015.hpp" +#include "ads1015.h" using namespace upm; @@ -30,63 +30,15 @@ ADS1015::setSPS(ADSSAMPLERATE rate){ updateConfigRegister((m_config_reg & ~ADS1X15_DR_MASK) | rate); } -ADS1015::ADS1015(int bus, uint8_t address, float vref) : ADS1X15(bus, address) { +ADS1015::ADS1015(int bus, uint8_t address) : ADS1X15(bus, address) { m_name = "ADS1015"; m_conversionDelay = ADS1015_CONVERSIONDELAY; m_bitShift = 4; ADS1X15::getCurrentConfig(); - if (vref < 0.0 || vref > 6.144) - UPM_THROW("vref out of range"); - else if (vref > 4.096) - setGain(GAIN_TWOTHIRDS); - else if (vref > 2.048) - setGain(GAIN_ONE); - else if (vref > 1.024) - setGain(GAIN_TWO); - else if (vref > 0.512) - setGain(GAIN_FOUR); - else if (vref > 0.256) - setGain(GAIN_EIGHT); - else - setGain(GAIN_SIXTEEN); } ADS1015::~ADS1015(){}; -const char* -ADS1015::getModuleName() { - return m_name.c_str(); -} - - -unsigned int -ADS1015::getNumInputs() { - return 4; -} - -unsigned int -ADS1015::getResolutionInBits() { - return 12; -} - -uint16_t -ADS1015::getRawValue(unsigned int input) { - ADS1X15::ADSMUXMODE mode = getMuxMode(input); - updateConfigRegister((m_config_reg & ~ADS1X15_MUX_MASK) | mode, true); - usleep(m_conversionDelay); - uint16_t value = i2c->readWordReg(ADS1X15_REG_POINTER_CONVERT); - value = value >> m_bitShift; - return swapWord(value); -} - -float -ADS1015::getVoltage(unsigned int input) { - ADSMUXMODE mode = getMuxMode(input); - return getSample(mode); -} - - - //Private functions float ADS1015::getMultiplier(void){ @@ -147,20 +99,4 @@ ADS1015::setDelay(){ } } -ADS1X15::ADSMUXMODE -ADS1015::getMuxMode(unsigned int input) { - ADS1X15::ADSMUXMODE mode; - switch (input) { - case 0: - return SINGLE_0; - case 1: - return SINGLE_1; - case 2: - return SINGLE_2; - case 3: - return SINGLE_3; - default: - UPM_THROW("Invalid input"); - } -} |