Statistics
| Revision:

root / Ports / PortsBMP085.h

History | View | Annotate | Download (1 KB)

1 7763 jcw
//>>> The latest version of this code can be found at https://github.com/jcw/ !!
2 7763 jcw
3 4727 jcw
// Port library interface to BMP085 sensors connected via I2C
4 4727 jcw
// 2009-02-17 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
5 4727 jcw
// $Id$
6 4727 jcw
7 4727 jcw
class BMP085 : public DeviceI2C {
8 4727 jcw
    int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
9 4727 jcw
    uint16_t ac4, ac5, ac6;
10 4727 jcw
11 4727 jcw
    uint16_t readWord(uint8_t last) const
12 4727 jcw
        { uint16_t v = read(0) << 8; return v | read(last); }
13 4727 jcw
    void readFromReg(uint8_t reg) const
14 4727 jcw
        { send(); write(reg); receive(); }
15 4727 jcw
16 4727 jcw
public:
17 4727 jcw
    enum { TEMP, PRES };
18 5698 jcw
    int32_t meas[2];
19 5698 jcw
    uint8_t oss;
20 4727 jcw
21 5698 jcw
    BMP085 (const PortI2C& p, uint8_t osrs =0)
22 5698 jcw
        : DeviceI2C (p, 0x77), oss (osrs) {}
23 5761 jcw
24 5761 jcw
    void setOverSampling(uint8_t osrs) { oss = osrs; }
25 4727 jcw
26 4727 jcw
    uint8_t startMeas(uint8_t type) const;
27 5698 jcw
    int32_t getResult(uint8_t type);
28 4727 jcw
29 5698 jcw
    int32_t measure(uint8_t type)
30 4727 jcw
        { delay(startMeas(type)); return getResult(type); }
31 4727 jcw
32 4727 jcw
    void getCalibData();
33 4727 jcw
    void calculate(int16_t& tval, int32_t& pval) const;
34 4727 jcw
};