30 #include "mraa/i2c.hpp" 
   35 #define ADS1X15_ADDRESS                 (0x48)    // 1001 000 (ADDR = GND) 
   42 #define ADS1X15_REG_POINTER_MASK        (0x03) 
   43 #define ADS1X15_REG_POINTER_CONVERT     (0x00) 
   44 #define ADS1X15_REG_POINTER_CONFIG      (0x01) 
   45 #define ADS1X15_REG_POINTER_LOWTHRESH   (0x02) 
   46 #define ADS1X15_REG_POINTER_HITHRESH    (0x03) 
   53 #define ADS1X15_OS_MASK      (0x8000) 
   54 #define ADS1X15_OS_SINGLE    (0x8000)  // Write: Set to start a single-conversion 
   55 #define ADS1X15_OS_BUSY      (0x0000)  // Read: Bit = 0 when conversion is in progress 
   56 #define ADS1X15_OS_NOTBUSY   (0x8000)  // Read: Bit = 1 when device is not performing a conversion 
   58 #define ADS1X15_MUX_MASK     (0x7000) 
   59 #define ADS1X15_MUX_DIFF_0_1 (0x0000)  // Differential P = AIN0, N = AIN1 (default) 
   60 #define ADS1X15_MUX_DIFF_0_3 (0x1000)  // Differential P = AIN0, N = AIN3 
   61 #define ADS1X15_MUX_DIFF_1_3 (0x2000)  // Differential P = AIN1, N = AIN3 
   62 #define ADS1X15_MUX_DIFF_2_3 (0x3000)  // Differential P = AIN2, N = AIN3 
   63 #define ADS1X15_MUX_SINGLE_0 (0x4000)  // Single-ended AIN0 
   64 #define ADS1X15_MUX_SINGLE_1 (0x5000)  // Single-ended AIN1 
   65 #define ADS1X15_MUX_SINGLE_2 (0x6000)  // Single-ended AIN2 
   66 #define ADS1X15_MUX_SINGLE_3 (0x7000)  // Single-ended AIN3 
   68 #define ADS1X15_PGA_MASK     (0x0E00) 
   69 #define ADS1X15_PGA_6_144V   (0x0000)  // +/-6.144V range = Gain 2/3 
   70 #define ADS1X15_PGA_4_096V   (0x0200)  // +/-4.096V range = Gain 1 
   71 #define ADS1X15_PGA_2_048V   (0x0400)  // +/-2.048V range = Gain 2 (default) 
   72 #define ADS1X15_PGA_1_024V   (0x0600)  // +/-1.024V range = Gain 4 
   73 #define ADS1X15_PGA_0_512V   (0x0800)  // +/-0.512V range = Gain 8 
   74 #define ADS1X15_PGA_0_256V   (0x0A00)  // +/-0.256V range = Gain 16 
   76 #define ADS1X15_MODE_MASK    (0x0100) 
   77 #define ADS1X15_MODE_CONTIN  (0x0000)  // Continuous conversion mode 
   78 #define ADS1X15_MODE_SINGLE  (0x0100)  // Power-down single-shot mode (default) 
   80 #define ADS1X15_DR_MASK      (0x00E0) 
   82 #define ADS1X15_CMODE_MASK   (0x0010) 
   83 #define ADS1X15_CMODE_TRAD   (0x0000)  // Traditional comparator with hysteresis (default) 
   84 #define ADS1X15_CMODE_WINDOW (0x0010)  // Window comparator 
   86 #define ADS1X15_CPOL_MASK    (0x0008) 
   87 #define ADS1X15_CPOL_ACTVLOW (0x0000)  // ALERT/RDY pin is low when active (default) 
   88 #define ADS1X15_CPOL_ACTVHI  (0x0008)  // ALERT/RDY pin is high when active 
   90 #define ADS1X15_CLAT_MASK    (0x0400)  // Determines if ALERT/RDY pin latches once asserted 
   91 #define ADS1X15_CLAT_NONLAT  (0x0000)  // Non-latching comparator (default) 
   92 #define ADS1X15_CLAT_LATCH   (0x0400)  // Latching comparator 
   94 #define ADS1X15_CQUE_MASK    (0x0003) 
  130               GAIN_TWOTHIRDS    = ADS1X15_PGA_6_144V,
 
  131               GAIN_ONE          = ADS1X15_PGA_4_096V,
 
  132               GAIN_TWO          = ADS1X15_PGA_2_048V,
 
  133               GAIN_FOUR         = ADS1X15_PGA_1_024V,
 
  134               GAIN_EIGHT        = ADS1X15_PGA_0_512V,
 
  135               GAIN_SIXTEEN      = ADS1X15_PGA_0_256V
 
  153               DIFF_0_1        = ADS1X15_MUX_DIFF_0_1,  
 
  154               DIFF_0_3        = ADS1X15_MUX_DIFF_0_3,  
 
  155               DIFF_1_3        = ADS1X15_MUX_DIFF_1_3,  
 
  156               DIFF_2_3        = ADS1X15_MUX_DIFF_2_3,  
 
  157               SINGLE_0        = ADS1X15_MUX_SINGLE_0,  
 
  158               SINGLE_1        = ADS1X15_MUX_SINGLE_1,  
 
  159               SINGLE_2        = ADS1X15_MUX_SINGLE_2,  
 
  160               SINGLE_3        = ADS1X15_MUX_SINGLE_3   
 
  192                 THRESH_LOW      = ADS1X15_REG_POINTER_LOWTHRESH,
 
  193                 THRESH_HIGH     = ADS1X15_REG_POINTER_HITHRESH,
 
  194                 CONVERSION_RDY  = 0x04,
 
  195                 THRESH_DEFAULT  = 0x05
 
  217             ADS1X15(
int bus, uint8_t address);
 
  257                 return  (
ADSGAIN)(m_config_reg & ADS1X15_PGA_MASK);
 
  293                 return (
bool)(m_config_reg & ADS1X15_CMODE_MASK);
 
  312                 return (
bool)(m_config_reg & ADS1X15_CPOL_MASK);
 
  332                 return (
bool)(m_config_reg & ADS1X15_CLAT_MASK);
 
  354                 return (
ADSCOMP)(m_config_reg & ADS1X15_CQUE_MASK);
 
  375                 return !(bool)(m_config_reg & ADS1X15_MODE_MASK);
 
  411             float m_conversionDelay;
 
  413             uint16_t m_config_reg;
 
  415             virtual float getMultiplier(
void) = 0;
 
  417             virtual void setDelay(
void) = 0;
 
  418             void getCurrentConfig();
 
  419             void updateConfigRegister(uint16_t update, 
bool read = 
false);
 
  420             uint16_t swapWord(uint16_t value);
 
ADSCOMP
uint16_t enum containing values for setting ADS1X15 comparator queue modes. 
Definition: ads1x15.hpp:173
 
virtual ~ADS1X15()
Definition: ads1x15.cxx:54
 
std::string name()
Definition: ads1x15.hpp:227
 
bool getCompLatch(void)
Definition: ads1x15.hpp:331
 
float getSample(ADSMUXMODE mode=ADS1X15::DIFF_0_1)
Definition: ads1x15.cxx:57
 
void setCompPol(bool mode=false)
Definition: ads1x15.cxx:94
 
ADSTHRESH
uint8_t enum containing register addresses used for setting HI and LOW threshold values as well as se...
Definition: ads1x15.hpp:191
 
Definition: ads1x15.hpp:113
 
float getLastSample(int reg=ADS1X15_REG_POINTER_CONVERT)
Definition: ads1x15.cxx:64
 
ADSCOMP getCompQue(void)
Definition: ads1x15.hpp:353
 
bool getCompPol(void)
Definition: ads1x15.hpp:311
 
ADSMUXMODE
uint16_t enum containing values used for selecting ADS1X15 read operations. 
Definition: ads1x15.hpp:152
 
void setCompQue(ADSCOMP mode=ADS1X15::CQUE_NONE)
Definition: ads1x15.cxx:106
 
void setCompLatch(bool mode=false)
Definition: ads1x15.cxx:100
 
void setCompMode(bool mode=false)
Definition: ads1x15.cxx:88
 
void setGain(ADSGAIN gain=ADS1X15::GAIN_TWO)
Definition: ads1x15.cxx:78
 
ADSSAMPLERATE getSPS(void)
Definition: ads1x15.hpp:273
 
ADSGAIN
uint16_t enum containing values for setting gain for ADS1X15 devices. 
Definition: ads1x15.hpp:129
 
ADS1X15(int bus, uint8_t address)
Definition: ads1x15.cxx:33
 
ADSSAMPLERATE
uint16_t enum containing values representing the sample rate of the device. Will be overridden in sub...
Definition: ads1x15.hpp:207
 
bool getCompMode(void)
Definition: ads1x15.hpp:292
 
void setThresh(ADSTHRESH reg=THRESH_DEFAULT, float value=0.0)
Definition: ads1x15.cxx:123
 
void setContinuous(bool mode=false)
Definition: ads1x15.cxx:111
 
bool getContinuous(void)
Definition: ads1x15.hpp:374
 
ADSGAIN getGain()
Definition: ads1x15.hpp:256
 
virtual void setSPS(ADSSAMPLERATE rate)
Definition: ads1x15.cxx:83
 
float getThresh(ADSTHRESH reg=THRESH_LOW)
Definition: ads1x15.cxx:117