upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
ms5611.hpp
1 /*
2  * Author: Henry Bruce <henry.bruce@intel.com>
3  * Copyright (c) 2016 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 #include "interfaces/iPressureSensor.hpp"
26 #include "interfaces/iTemperatureSensor.hpp"
27 #include "mraa/i2c.hpp"
28 
29 namespace upm
30 {
31 
32 #define MS5611_ADDRESS 0x76
33 
62 {
63 public:
64  enum OsrMode
65  {
66  ULTRA_LOW_POWER, LOW_POWER, STANDARD, ULTRA_HIGH_RES, HIGH_RES
67  };
68 
69  MS5611(int i2cBus = 0, int address = MS5611_ADDRESS);
70  ~MS5611();
71  virtual const char* getModuleName() { return "ms5611"; }
72  void setOverSampling(OsrMode osrMode);
73  int getTemperatureCelsius();
74  int getPressurePa();
75 
76 private:
77  /* Disable implicit copy and assignment operators */
78  MS5611(const MS5611&) = delete;
79  MS5611 &operator=(const MS5611&) = delete;
80 
81  int promCrc4();
82  uint32_t readADC(int adcReg);
83  void delayms(int millisecs);
84  uint32_t readRawPressure();
85  uint32_t readRawTemperature();
86 
87  mraa::I2c* i2c;
88  int address;
89  uint16_t *prom;
90  int osr;
91  int samplePeriod;
92 };
93 
94 
95 }
96 
Interface for Temperature Sensors.
Definition: iTemperatureSensor.hpp:34
Definition: ms5611.hpp:61
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
virtual const char * getModuleName()
Definition: ms5611.hpp:71
Definition: iPressureSensor.hpp:36