upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bmp280_regs.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016-2017 Intel Corporation.
4  *
5  * The MIT License
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 #pragma once
27 
28 // BMP280
29 #define BMP280_DEFAULT_I2C_BUS 0
30 #define BMP280_DEFAULT_SPI_BUS 0
31 #define BMP280_DEFAULT_ADDR 0x77
32 #define BMP280_CHIPID 0x58
33 
34 // BME280
35 #define BME280_DEFAULT_I2C_BUS 0
36 #define BME280_DEFAULT_SPI_BUS 0
37 #define BME280_DEFAULT_ADDR 0x77
38 #define BME280_CHIPID 0x60
39 
40 // default sea level pressure in hPA
41 #define BMP280_SEA_LEVEL_HPA (1013.25)
42 
43 // special reset byte, same for bme280
44 #define BMP280_RESET_BYTE 0xb6
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53  typedef enum {
54  // Do not write into reserved bits.
55 
56  // read-only factory calibration data
57  BMP280_REG_CALIB00 = 0x88,
58  BMP280_REG_CALIB01 = 0x89,
59  BMP280_REG_CALIB02 = 0x8a,
60  BMP280_REG_CALIB03 = 0x8b,
61  BMP280_REG_CALIB04 = 0x8c,
62  BMP280_REG_CALIB05 = 0x8d,
63  BMP280_REG_CALIB06 = 0x8e,
64  BMP280_REG_CALIB07 = 0x8f,
65  BMP280_REG_CALIB08 = 0x90,
66  BMP280_REG_CALIB09 = 0x91,
67  BMP280_REG_CALIB10 = 0x92,
68  BMP280_REG_CALIB11 = 0x93,
69  BMP280_REG_CALIB12 = 0x94,
70  BMP280_REG_CALIB13 = 0x95,
71  BMP280_REG_CALIB14 = 0x96,
72  BMP280_REG_CALIB15 = 0x97,
73  BMP280_REG_CALIB16 = 0x98,
74  BMP280_REG_CALIB17 = 0x99,
75  BMP280_REG_CALIB18 = 0x9a,
76  BMP280_REG_CALIB19 = 0x9b,
77  BMP280_REG_CALIB20 = 0x9c,
78  BMP280_REG_CALIB21 = 0x9d,
79  BMP280_REG_CALIB22 = 0x9e,
80  BMP280_REG_CALIB23 = 0x9f,
81  BMP280_REG_CALIB24 = 0xa0,
82  BMP280_REG_CALIB25 = 0xa1,
83 
84  BMP280_REG_CHIPID = 0xd0,
85  BMP280_REG_RESET = 0xe0,
86  BMP280_REG_STATUS = 0xf3,
87  BMP280_REG_CTRL_MEAS = 0xf4,
88  BMP280_REG_CONFIG = 0xf5,
89 
90  BMP280_REG_PRESSURE_MSB = 0xf7,
91  BMP280_REG_PRESSURE_LSB = 0xf8,
92  BMP280_REG_PRESSURE_XLSB = 0xf9,
93 
94  BMP280_REG_TEMPERATURE_MSB = 0xfa,
95  BMP280_REG_TEMPERATURE_LSB = 0xfb,
96  BMP280_REG_TEMPERATURE_XLSB = 0xfc
97  } BMP280_REGS_T;
98 
102  typedef enum {
103  BMP280_CONFIG_SPI3W_EN = 0x01,
104 
105  // 0x02 reserved
106 
107  BMP280_CONFIG_FILTER0 = 0x04,
108  BMP280_CONFIG_FILTER1 = 0x08,
109  BMP280_CONFIG_FILTER2 = 0x10,
110  _BMP280_CONFIG_FILTER_MASK = 7,
111  _BMP280_CONFIG_FILTER_SHIFT = 2,
112 
113  BMP280_CONFIG_T_SB0 = 0x20,
114  BMP280_CONFIG_T_SB1 = 0x40,
115  BMP280_CONFIG_T_SB2 = 0x80,
116  _BMP280_CONFIG_T_SB_MASK = 7,
117  _BMP280_CONFIG_T_SB_SHIFT = 5
118  } BMP280_CONFIG_BITS_T;
119 
123  typedef enum {
124  BMP280_FILTER_OFF = 0, // 1 samples
125  BMP280_FILTER_2 = 1, // 2
126  BMP280_FILTER_4 = 2, // 5
127  BMP280_FILTER_8 = 3, // 11
128  BMP280_FILTER_16 = 4 // 22
129  } BMP280_FILTER_T;
130 
134  typedef enum {
135  BMP280_T_SB_0_5 = 0, // 0.5ms
136  BMP280_T_SB_62_5 = 1, // 62.5ms
137  BMP280_T_SB_125 = 2, // 125ms
138  BMP280_T_SB_250 = 3,
139  BMP280_T_SB_500 = 4,
140  BMP280_T_SB_1000 = 5,
141  BMP280_T_SB_2000 = 6, // bme280 - 10ms
142  BMP280_T_SB_4000 = 7 // bme280 - 20ms
143  } BMP280_T_SB_T;
144 
145 
149  typedef enum {
150  BMP280_CTRL_MEAS_MODE0 = 0x01,
151  BMP280_CTRL_MEAS_MODE1 = 0x02,
152  _BMP280_CTRL_MEAS_MODE_MASK = 3,
153  _BMP280_CTRL_MEAS_MODE_SHIFT = 0,
154 
155  BMP280_CTRL_MEAS_OSRS_P0 = 0x04,
156  BMP280_CTRL_MEAS_OSRS_P1 = 0x08,
157  BMP280_CTRL_MEAS_OSRS_P2 = 0x10,
158  _BMP280_CTRL_MEAS_OSRS_P_MASK = 7,
159  _BMP280_CTRL_MEAS_OSRS_P_SHIFT = 2,
160 
161  BMP280_CTRL_MEAS_OSRS_T0 = 0x04,
162  BMP280_CTRL_MEAS_OSRS_T1 = 0x08,
163  BMP280_CTRL_MEAS_OSRS_T2 = 0x10,
164  _BMP280_CTRL_MEAS_OSRS_T_MASK = 7,
165  _BMP280_CTRL_MEAS_OSRS_T_SHIFT = 5
166  } BMP280_CTRL_MEAS_T;
167 
171  typedef enum {
172  BMP280_MODE_SLEEP = 0,
173  BMP280_MODE_FORCED = 1,
174  // 2 is also FORCED mode
175  BMP280_MODE_NORMAL = 3
176  } BMP280_MODES_T;
177 
181  typedef enum {
182  BMP280_OSRS_P_SKIPPED = 0,
183  BMP280_OSRS_P_OVERSAMPLING_1 = 1, // x1
184  BMP280_OSRS_P_OVERSAMPLING_2 = 2, // x2
185  BMP280_OSRS_P_OVERSAMPLING_4 = 3,
186  BMP280_OSRS_P_OVERSAMPLING_8 = 4,
187  BMP280_OSRS_P_OVERSAMPLING_16 = 5
188  } BMP280_OSRS_P_T;
189 
193  typedef enum {
194  BMP280_OSRS_T_SKIPPED = 0,
195  BMP280_OSRS_T_OVERSAMPLING_1 = 1, // x1
196  BMP280_OSRS_T_OVERSAMPLING_2 = 2, // x2
197  BMP280_OSRS_T_OVERSAMPLING_4 = 3,
198  BMP280_OSRS_T_OVERSAMPLING_8 = 4,
199  BMP280_OSRS_T_OVERSAMPLING_16 = 5
200  } BMP280_OSRS_T_T;
201 
205  typedef enum {
206  BMP280_STATUS_IM_UPDATE = 0x01,
207  // 0x02-0x04 reserved
208  BMP280_STATUS_MEASURING = 0x08
209  // 0x10-0x80 reserved
210  } BMP280_STATUS_T;
211 
217  typedef enum {
218  BMP280_USAGE_MODE_HANDHELD_LOW_POWER = 0,
219  BMP280_USAGE_MODE_HANDHELD_DYNAMIC = 1,
220  BMP280_USAGE_MODE_WEATHER_MONITOR = 2, // lowest power consumption
221  BMP280_USAGE_MODE_FLOOR_CHG_DETECT = 3,
222  BMP280_USAGE_MODE_DROP_DETECT = 4,
223  BMP280_USAGE_MODE_INDOOR_NAV = 5 // highest resolution
224  } BMP280_USAGE_MODE_T;
225 
226  // The following are registers specific to the BME280. The BME280
227  // is identical to the BMP280 with the exception of humidity
228  // sensor support and the corresponding registers needed to
229  // support it.
230 
234  typedef enum {
235  // Do not write into reserved bits.
236 
237  // We only specify those registers specific to the BME280. The
238  // rest of them can be found in the BMP280 header file.
239 
240  // read-only factory calibration data for humidity
241 
242  BME280_REG_CALIB_DIG_H1 = 0xa1,
243 
244  BME280_REG_CALIB_DIG_H2_LSB = 0xe1,
245  BME280_REG_CALIB_DIG_H2_MSB = 0xe2,
246 
247  BME280_REG_CALIB_DIG_H3 = 0xe3,
248 
249  BME280_REG_CALIB_DIG_H4_0 = 0xe4, // bits 8 -> 11:4
250  BME280_REG_CALIB_DIG_H4_1 = 0xe5, // bits 3:0 -> 3:0
251 
252  BME280_REG_CALIB_DIG_H5_0 = 0xe5, // bits 7:4 -> 3:0
253  BME280_REG_CALIB_DIG_H5_1 = 0xe6, // bits 8 -> 11:4
254 
255  BME280_REG_CALIB_DIG_H6 = 0xe7,
256 
257  BME280_REG_CTRL_HUM = 0xf2,
258 
259  BME280_REG_HUMIDITY_MSB = 0xfd,
260  BME280_REG_HUMIDITY_LSB = 0xfe
261  } BME280_REGS_T;
262 
266  typedef enum {
267  BME280_CTRL_HUM_OSRS_H0 = 0x01,
268  BME280_CTRL_HUM_OSRS_H1 = 0x02,
269  BME280_CTRL_HUM_OSRS_H2 = 0x04,
270  _BME280_CTRL_HUM_OSRS_H_MASK = 3,
271  _BME280_CTRL_HUM_OSRS_H_SHIFT = 0
272 
273  // 0x08-0x80 reserved
274  } BME280_CTRL_HUM_T;
275 
279  typedef enum {
280  BME280_OSRS_H_SKIPPED = 0,
281  BME280_OSRS_H_OVERSAMPLING_1 = 1, // x1
282  BME280_OSRS_H_OVERSAMPLING_2 = 2, // x2
283  BME280_OSRS_H_OVERSAMPLING_4 = 3,
284  BME280_OSRS_H_OVERSAMPLING_8 = 4,
285  BME280_OSRS_H_OVERSAMPLING_16 = 5
286  } BME280_OSRS_H_T;
287 
288 #ifdef __cplusplus
289 }
290 #endif