Statistics
| Revision:

root / Ports / PortsBMP085.h

History | View | Annotate | Download (1 KB)

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