• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef BAROMETER_BMP180_H
10 #define BAROMETER_BMP180_H
11 
12 #include "sensor_barometer_driver.h"
13 #include "sensor_config_parser.h"
14 
15 #define BMP180_REG_CHIP_ID         0xD0
16 
17 // i2c address
18 
19 #define BMP180_ADDR                0x77
20 
21 // Define calibration register address
22 
23 #define BMP180_AC1_MSB_ADDR        0xAA
24 #define BMP180_AC1_LSB_ADDR        0xAB
25 #define BMP180_AC2_MSB_ADDR        0xAC
26 #define BMP180_AC2_LSB_ADDR        0xAD
27 #define BMP180_AC3_MSB_ADDR        0xAE
28 #define BMP180_AC3_LSB_ADDR        0xAF
29 #define BMP180_AC4_MSB_ADDR        0xB0
30 #define BMP180_AC4_LSB_ADDR        0xB1
31 #define BMP180_AC5_MSB_ADDR        0xB2
32 #define BMP180_AC5_LSB_ADDR        0xB3
33 #define BMP180_AC6_MSB_ADDR        0xB4
34 #define BMP180_AC6_LSB_ADDR        0xB5
35 #define BMP180_B1_MSB_ADDR         0xB6
36 #define BMP180_B1_LSB_ADDR         0xB7
37 #define BMP180_B2_MSB_ADDR         0xB8
38 #define BMP180_B2_LSB_ADDR         0xB9
39 #define BMP180_MB_MSB_ADDR         0xBA
40 #define BMP180_MB_LSB_ADDR         0xBB
41 #define BMP180_MC_MSB_ADDR         0xBC
42 #define BMP180_MC_LSB_ADDR         0xBD
43 #define BMP180_MD_MSB_ADDR         0xBE
44 #define BMP180_MD_LSB_ADDR         0xBf
45 
46 // Control register
47 
48 #define BMP180_CONTROL_REG_ADDR    0xF4
49 #define BMP180_COVERT_TEMP         0x2E
50 #define BMP180_COVERT_PRES_0       0x34
51 #define BMP180_COVERT_PRES_1       0x74
52 #define BMP180_COVERT_PRES_2       0xB4
53 #define BMP180_COVERT_PRES_3       0xF4
54 
55 #define BMP180_OUT_MSB_ADDR        0xF6
56 #define BMP180_OUT_LSB_ADDR        0xF7
57 #define BMP180_OUT_XLSB_ADDR       0xF8
58 
59 #define BMP180_STATUS_ADDR         0X20
60 #define BMP180_STATUS_JUDGE        0X00
61 
62 #define SENSOR_DATA_WIDTH_16_BIT   16
63 
64 #define OSSETTING                  1
65 #define DELAY_0                    5
66 #define DELAY_1                    8
67 #define OSS_TIME_MS	               26
68 
69 #define BMP180_CONSTANT_0          (-7357)
70 #define BMP180_CONSTANT_1          1
71 #define BMP180_CONSTANT_2          2
72 #define BMP180_CONSTANT_3          4
73 #define BMP180_CONSTANT_4          8
74 #define BMP180_CONSTANT_5          11
75 #define BMP180_CONSTANT_6          12
76 #define BMP180_CONSTANT_7          13
77 #define BMP180_CONSTANT_8          15
78 #define BMP180_CONSTANT_9          16
79 #define BMP180_CONSTANT_10         3038
80 #define BMP180_CONSTANT_11         3791
81 #define BMP180_CONSTANT_12         4000
82 #define BMP180_CONSTANT_13         32768
83 #define BMP180_CONSTANT_14         50000
84 #define BMP180_CONSTANT_15         0x80000000
85 
86 
87 int32_t DetectBarometerBmp180Chip(struct SensorCfgData *data);
88 int32_t ReadBmp180Data(struct SensorCfgData *data);
89 
90 struct Bmp180DrvData {
91     struct IDeviceIoService ioService;
92     struct HdfDeviceObject *device;
93     struct SensorCfgData *sensorCfg;
94 };
95 
96 #endif /*  BAROMETER_BMP180_H */