A library for ADS1015 and ADS1115 from Texas Instruments.
Fork of ADS1015 by
Revision 6:71b44421e736, committed 2016-09-01
- Comitter:
- Gaku0606
- Date:
- Thu Sep 01 13:13:35 2016 +0000
- Parent:
- 5:aa277517f0ad
- Commit message:
- ??????????
Changed in this revision
Adafruit_ADS1015.cpp | Show annotated file Show diff for this revision Revisions of this file |
Adafruit_ADS1015.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r aa277517f0ad -r 71b44421e736 Adafruit_ADS1015.cpp --- a/Adafruit_ADS1015.cpp Sat Oct 11 08:45:17 2014 +0000 +++ b/Adafruit_ADS1015.cpp Thu Sep 01 13:13:35 2016 +0000 @@ -81,6 +81,7 @@ m_bitShift = 0; m_gain = GAIN_TWOTHIRDS; /* +/- 6.144V range (limited to VDD +0.3V max!) */ m_i2c = i2c; + m_i2c->frequency(400000);//1000000 } /**************************************************************************/ @@ -167,11 +168,14 @@ { // Start with default values 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_CLAT_NONLAT | // Non-latching (default val) + ADS1015_REG_CONFIG_CLAT_LATCH | ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) ADS1015_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) - ADS1015_REG_CONFIG_DR_1600SPS | // 1600(ADS1015) or 250(ADS1115) samples per second (default) - ADS1015_REG_CONFIG_MODE_SINGLE; // Single-shot mode (default) + //ADS1015_REG_CONFIG_DR_1600SPS | // 1600(ADS1015) or 250(ADS1115) samples per second (default) + ADS1015_REG_CONFIG_DR_3300SPS | //3300 or 860(ADS1115) + ADS1015_REG_CONFIG_MODE_CONTIN; + //ADS1015_REG_CONFIG_MODE_SINGLE; // Single-shot mode (default) // Set PGA/voltage range config |= m_gain; @@ -267,7 +271,7 @@ ADS1015_REG_CONFIG_CLAT_LATCH | // Latching mode ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) ADS1015_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) - ADS1015_REG_CONFIG_DR_1600SPS | // 1600(ADS1015) or 250(ADS1115) samples per second (default) + ADS1015_REG_CONFIG_DR_3300SPS | // 1600(ADS1015) or 250(ADS1115) samples per second (default) ADS1015_REG_CONFIG_MODE_CONTIN | // Continuous conversion mode ADS1015_REG_CONFIG_MODE_CONTIN; // Continuous conversion mode @@ -323,4 +327,10 @@ } return (int16_t)res; } +} + +void Adafruit_ADS1015::user(){ + + writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG , 0b0000001011101111);// + } \ No newline at end of file
diff -r aa277517f0ad -r 71b44421e736 Adafruit_ADS1015.h --- a/Adafruit_ADS1015.h Sat Oct 11 08:45:17 2014 +0000 +++ b/Adafruit_ADS1015.h Thu Sep 01 13:13:35 2016 +0000 @@ -102,8 +102,19 @@ #define ADS1015_REG_CONFIG_CQUE_2CONV (0x0001) // Assert ALERT/RDY after two conversions #define ADS1015_REG_CONFIG_CQUE_4CONV (0x0002) // Assert ALERT/RDY after four conversions #define ADS1015_REG_CONFIG_CQUE_NONE (0x0003) // Disable the comparator and put ALERT/RDY in high state (default) + + #define COMP_QUE (0b0000000000000011) + #define COMP_LAT (0b0000000000000100) + #define COMP_POL (0b0000000000001000) + #define COMP_MODE (0b0000000000000000) + #define DR (0b0000000011100000)//860sps + #define MODE (0b0000000000000000)//連続 + #define PGA (0b0000001000000000)//4.096 + #define MUX (0b0000000000000000)//0 vs 1 + // 0b0000001011101111 /*=========================================================================*/ + typedef enum { GAIN_TWOTHIRDS = ADS1015_REG_CONFIG_PGA_6_144V, GAIN_ONE = ADS1015_REG_CONFIG_PGA_4_096V, @@ -133,6 +144,7 @@ int16_t getLastConversionResults(); void setGain(adsGain_t gain); adsGain_t getGain(void); + void user(); private: uint16_t readRegister(uint8_t i2cAddress, uint8_t reg);