-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBMP180Module.h
More file actions
118 lines (96 loc) · 2.61 KB
/
Copy pathBMP180Module.h
File metadata and controls
118 lines (96 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* BMP180Module.h
*
* Created on: Feb 20, 2014
* Author: Saminda
*/
#ifndef BMP180MODULE_H_
#define BMP180MODULE_H_
#include "Template.h"
#include "BMP180Representation.h"
#include "hw_bmp180.h"
//*****************************************************************************
//
// Define BMP180 I2C Address.
//
//*****************************************************************************
#define BMP180_I2C_ADDRESS 0x77
MODULE(BMP180Module)
PROVIDES(BMP180Representation)
END_MODULE
class BMP180Module: public BMP180ModuleBase
{
private:
class BMP180
{
public:
//
// The I2C address of the BMP180.
//
uint8_t ui8Addr;
//
// The AC1 calibration from the BMP180.
//
int16_t i16AC1;
//
// The AC2 calibration from the BMP180.
//
int16_t i16AC2;
//
// The AC3 calibration from the BMP180.
//
int16_t i16AC3;
//
// The AC4 calibration from the BMP180.
//
uint16_t ui16AC4;
//
// The AC5 calibration from the BMP180.
//
uint16_t ui16AC5;
//
// The AC6 calibration from the BMP180.
//
uint16_t ui16AC6;
//
// The B1 calibration from the BMP180.
//
int16_t i16B1;
//
// The B2 calibration from the BMP180.
//
int16_t i16B2;
//
// The MC calibration from the BMP180.
//
int16_t i16MC;
//
// The MD calibration from the BMP180.
//
int16_t i16MD;
//
// The sampling mode to be used by the BMP180.
//
uint8_t ui8Mode;
//
// The data buffer used for sending/receiving data to/from the BMP180.
//
uint8_t pui8Data[3];
BMP180() :
ui8Addr(BMP180_I2C_ADDRESS), i16AC1(0), i16AC2(0), i16AC3(0), ui16AC4(0), ui16AC5(0), ui16AC6(
0), i16B1(0), i16B2(0), i16MC(0), i16MD(0), ui8Mode(0)
{
}
};
BMP180 parameters;
public:
void init();
void update(BMP180Representation& theBMP180Representation);
private:
void calibration();
void calculation(BMP180Representation& theBMP180Representation);
// read 16-bits from I2C (signed and unsigned)
void I2CMRead(const uint8_t& addr, const uint8_t& bytes = 2);
void cmdI2CMRead(const uint8_t& cmd, const uint8_t& addr, const uint8_t& bytes);
};
#endif /* BMP180MODULE_H_ */