upm  0.8.0
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ads1015.hpp
1 /*
2  * Author: Marc Graham <marc@m2ag.net>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 /*=========================================================================*/
25 
26 #pragma once
27 
28 #include "ads1x15.hpp"
29 #include "upm/iADC.hpp"
30 
31 #define ADS1015_VREF 2.048
32 
33 /*=========================================================================
34  CONVERSION DELAY (in microS)
35  -----------------------------------------------------------------------*/
36  #define ADS1015_CONVERSIONDELAY (8000)
37 /*=========================================================================*/
38 
39 
40 /*=========================================================================
41  CONFIG REGISTER
42 
43  -----------------------------------------------------------------------*/
44 
45 #define ADS1015_DR_MASK (0x00E0)
46 #define ADS1015_DR_128SPS (0x0000) // 128 samples per second
47 #define ADS1015_DR_250SPS (0x0020) // 250 samples per second
48 #define ADS1015_DR_490SPS (0x0040) // 490 samples per second
49 #define ADS1015_DR_920SPS (0x0060) // 920 samples per second
50 #define ADS1015_DR_1600SPS (0x0080) // 1600 samples per second (default)
51 #define ADS1015_DR_2400SPS (0x00A0) // 2400 samples per second
52 #define ADS1015_DR_3300SPS (0x00C0) // 3300 samples per second
53 
54 /*=========================================================================*/
55 
56 namespace upm {
86  class ADS1015 : public ADS1X15, public IADC {
87 
88  public:
89 
103  typedef enum ADSSAMPLERATE {
104  SPS_128 = ADS1015_DR_128SPS,
105  SPS_250 = ADS1015_DR_250SPS,
106  SPS_490 = ADS1015_DR_490SPS,
107  SPS_920 = ADS1015_DR_920SPS,
108  SPS_1600 = ADS1015_DR_1600SPS,
109  SPS_2400 = ADS1015_DR_2400SPS,
110  SPS_3300 = ADS1015_DR_3300SPS
111  } ADSSAMPLERATE;
112 
113 
124  ADS1015 (int bus, uint8_t address = 0x48, float vref = ADS1015_VREF);
125 
129  ~ADS1015 ();
130 
138  void setSPS(ADSSAMPLERATE rate = SPS_1600);
139 
145  unsigned int getNumInputs();
146 
152  uint16_t getRawValue(unsigned int input);
153 
159  float getVoltage(unsigned int input);
160 
166  unsigned int getResolutionInBits();
167 
173  const char* getModuleName();
174 
175 
176  protected:
177  float getMultiplier(void);
178  void setDelay(void);
179 
180  private:
181  ADS1X15::ADSMUXMODE getMuxMode(unsigned int input);
182 
183  };
184 }
ADSSAMPLERATE
uint16_t enum containing values representing the sample rate of the device.
Definition: ads1015.hpp:103
unsigned int getResolutionInBits()
Definition: ads1015.cxx:68
unsigned int getNumInputs()
Definition: ads1015.cxx:63
uint16_t getRawValue(unsigned int input)
Definition: ads1015.cxx:73
Definition: ads1x15.hpp:113
void setSPS(ADSSAMPLERATE rate=SPS_1600)
Definition: ads1015.cxx:29
ADS1015(int bus, uint8_t address=0x48, float vref=ADS1015_VREF)
Definition: ads1015.cxx:33
API for ADS1015.
Definition: ads1015.hpp:86
ADSMUXMODE
uint16_t enum containing values used for selecting ADS1X15 read operations.
Definition: ads1x15.hpp:152
~ADS1015()
Definition: ads1015.cxx:54
Interface for ADC Sensors.
Definition: iADC.hpp:38
float getVoltage(unsigned int input)
Definition: ads1015.cxx:83
const char * getModuleName()
Definition: ads1015.cxx:57