30 namespace mraa {
class I2c;}
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);
241 float getLastSample(
int reg = ADS1X15_REG_POINTER_CONVERT);
250 float getSample(ADSMUXMODE mode = ADS1X15::DIFF_0_1);
257 return (ADSGAIN)(m_config_reg & ADS1X15_PGA_MASK);
267 void setGain(ADSGAIN gain = ADS1X15::GAIN_TWO);
293 return (
bool)(m_config_reg & ADS1X15_CMODE_MASK);
303 void setCompMode(
bool mode =
false);
312 return (
bool)(m_config_reg & ADS1X15_CPOL_MASK);
323 void setCompPol(
bool mode =
false);
332 return (
bool)(m_config_reg & ADS1X15_CLAT_MASK);
342 void setCompLatch(
bool mode =
false);
354 return (
ADSCOMP)(m_config_reg & ADS1X15_CQUE_MASK);
366 void setCompQue(
ADSCOMP mode = ADS1X15::CQUE_NONE);
375 return !(bool)(m_config_reg & ADS1X15_MODE_MASK);
385 void setContinuous(
bool mode =
false);
393 float getThresh(
ADSTHRESH reg = THRESH_DEFAULT);
407 void setThresh(
ADSTHRESH reg = THRESH_DEFAULT ,
float value = 0.0);
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
std::string name()
Definition: ads1x15.hpp:227
bool getCompLatch(void)
Definition: ads1x15.hpp:331
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
ADSCOMP getCompQue(void)
Definition: ads1x15.hpp:353
bool getCompPol(void)
Definition: ads1x15.hpp:311
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
ADSMUXMODE
uint16_t enum containing values used for selecting ADS1X15 read operations.
Definition: ads1x15.hpp:152
ADSSAMPLERATE getSPS(void)
Definition: ads1x15.hpp:273
ADSGAIN
uint16_t enum containing values for setting gain for ADS1X15 devices.
Definition: ads1x15.hpp:129
ADSSAMPLERATE
uint16_t enum containing values representing the sample rate of the device. Will be overridden in sub...
Definition: ads1x15.hpp:207
Definition: ads1x15.hpp:30
bool getCompMode(void)
Definition: ads1x15.hpp:292
bool getContinuous(void)
Definition: ads1x15.hpp:374
ADSGAIN getGain()
Definition: ads1x15.hpp:256