bmx280.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kees Bakker, SODAQ
3  * 2017 Inria
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
41 #ifndef BMX280_H
42 #define BMX280_H
43 
44 #include <inttypes.h>
45 #include "saul.h"
46 #include "periph/i2c.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
57 typedef struct {
58  uint16_t dig_T1;
59  int16_t dig_T2;
60  int16_t dig_T3;
62  uint16_t dig_P1;
63  int16_t dig_P2;
64  int16_t dig_P3;
65  int16_t dig_P4;
66  int16_t dig_P5;
67  int16_t dig_P6;
68  int16_t dig_P7;
69  int16_t dig_P8;
70  int16_t dig_P9;
72  uint8_t dig_H1;
73  int16_t dig_H2;
74  uint8_t dig_H3;
75  int16_t dig_H4;
76  int16_t dig_H5;
77  int8_t dig_H6;
79 
83 typedef enum {
84  BMX280_SB_0_5 = 0,
85  BMX280_SB_62_5 = 1,
86  BMX280_SB_125 = 2,
87  BMX280_SB_250 = 3,
88  BMX280_SB_500 = 4,
89  BMX280_SB_1000 = 5,
90  BMX280_SB_10 = 6,
91  BMX280_SB_20 = 7
93 
97 typedef enum {
98  BMX280_FILTER_OFF = 0,
99  BMX280_FILTER_2 = 1,
100  BMX280_FILTER_4 = 2,
101  BMX280_FILTER_8 = 3,
102  BMX280_FILTER_16 = 4,
104 
108 typedef enum {
109  BMX280_MODE_SLEEP = 0,
110  BMX280_MODE_FORCED = 1,
111  BMX280_MODE_FORCED2 = 2, /* Same as FORCED */
112  BMX280_MODE_NORMAL = 3
113 } bmx280_mode_t;
114 
123 typedef enum {
124  BMX280_OSRS_SKIPPED = 0,
125  BMX280_OSRS_X1 = 1,
126  BMX280_OSRS_X2 = 2,
127  BMX280_OSRS_X4 = 3,
128  BMX280_OSRS_X8 = 4,
129  BMX280_OSRS_X16 = 5,
130 } bmx280_osrs_t;
131 
137 typedef struct {
138  /* I2C details */
140  uint8_t i2c_addr;
142  /* Config Register */
145  uint8_t spi3w_en;
147  /* ctrl_meas */
152  /* ctrl_hum */
155 
159 typedef struct {
162 } bmx280_t;
163 
167 enum {
168  BMX280_OK = 0,
171 };
172 
184 int bmx280_init(bmx280_t* dev, const bmx280_params_t* params);
185 
194 int16_t bmx280_read_temperature(const bmx280_t* dev);
195 
206 uint32_t bmx280_read_pressure(const bmx280_t *dev);
207 
208 #if defined(MODULE_BME280)
209 
219 uint16_t bme280_read_humidity(const bmx280_t *dev);
220 #endif
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif /* BMX280_H */
227 
int16_t bmx280_read_temperature(const bmx280_t *dev)
Read temperature value from the given BMX280 device, returned in centi °C.
uint32_t bmx280_read_pressure(const bmx280_t *dev)
Read air pressure value from the given BMX280 device, returned in PA.
int16_t dig_H5
H5 coefficient.
Definition: bmx280.h:76
i2c_t i2c_dev
I2C device which is used.
Definition: bmx280.h:139
bmx280_mode_t run_mode
ctrl_meas mode
Definition: bmx280.h:148
bmx280_params_t params
Device Parameters.
Definition: bmx280.h:160
uint8_t dig_H3
H3 coefficient.
Definition: bmx280.h:74
int16_t dig_H4
H4 coefficient.
Definition: bmx280.h:75
Device descriptor for the BMX280 sensor.
Definition: bmx280.h:159
int16_t dig_P6
P6 coefficient.
Definition: bmx280.h:67
int16_t dig_P4
P4 coefficient.
Definition: bmx280.h:65
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
int8_t dig_H6
H6 coefficient.
Definition: bmx280.h:77
uint8_t spi3w_en
Enables 3-wire SPI interface.
Definition: bmx280.h:145
uint16_t dig_P1
P1 coefficient.
Definition: bmx280.h:62
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
did not detect BME280 or BMP280
Definition: bmx280.h:169
everything was fine
Definition: bmx280.h:168
int16_t dig_T2
T2 coefficient.
Definition: bmx280.h:59
bmx280_osrs_t press_oversample
ctrl_meas osrs_p
Definition: bmx280.h:150
bmx280_osrs_t temp_oversample
ctrl_meas osrs_t
Definition: bmx280.h:149
int16_t dig_P9
P9 coefficient.
Definition: bmx280.h:70
bmx280_calibration_t calibration
Calibration Data.
Definition: bmx280.h:161
bmx280_t_sb_t
Values for t_sb field of the BMX280 config register.
Definition: bmx280.h:83
bmx280_filter_t filter
filter coefficient
Definition: bmx280.h:144
uint16_t dig_T1
T1 coefficient.
Definition: bmx280.h:58
bmx280_osrs_t
Values for oversampling settings.
Definition: bmx280.h:123
bmx280_filter_t
Values for filter field of the BMX280 config register.
Definition: bmx280.h:97
int16_t dig_P7
P7 coefficient.
Definition: bmx280.h:68
int16_t dig_P2
P2 coefficient.
Definition: bmx280.h:63
Parameters for the BMX280 sensor.
Definition: bmx280.h:137
Calibration struct for the BMX280 sensor.
Definition: bmx280.h:57
bmx280_mode_t
Values for mode field of the BMX280 ctrl_meas register.
Definition: bmx280.h:108
bmx280_t_sb_t t_sb
standby
Definition: bmx280.h:143
int16_t dig_P8
P8 coefficient.
Definition: bmx280.h:69
bmx280_osrs_t humid_oversample
ctrl_hum osrs_h
Definition: bmx280.h:153
int16_t dig_H2
H2 coefficient.
Definition: bmx280.h:73
int16_t dig_P5
P5 coefficient.
Definition: bmx280.h:66
int bmx280_init(bmx280_t *dev, const bmx280_params_t *params)
Initialize the given BMX280 device.
uint8_t dig_H1
H1 coefficient.
Definition: bmx280.h:72
uint8_t i2c_addr
I2C address.
Definition: bmx280.h:140
int16_t dig_P3
P3 coefficient.
Definition: bmx280.h:64
int16_t dig_T3
T3 coefficient.
Definition: bmx280.h:60
Low-level I2C peripheral driver interface definition.
could not read calibration data
Definition: bmx280.h:170