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 
60 #ifndef BMX280_H
61 #define BMX280_H
62 
63 #include <inttypes.h>
64 #include "saul.h"
65 #include "periph/i2c.h"
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
76 typedef struct {
77  uint16_t dig_T1;
78  int16_t dig_T2;
79  int16_t dig_T3;
81  uint16_t dig_P1;
82  int16_t dig_P2;
83  int16_t dig_P3;
84  int16_t dig_P4;
85  int16_t dig_P5;
86  int16_t dig_P6;
87  int16_t dig_P7;
88  int16_t dig_P8;
89  int16_t dig_P9;
91  uint8_t dig_H1;
92  int16_t dig_H2;
93  uint8_t dig_H3;
94  int16_t dig_H4;
95  int16_t dig_H5;
96  int8_t dig_H6;
98 
102 typedef enum {
103  BMX280_SB_0_5 = 0,
104  BMX280_SB_62_5 = 1,
105  BMX280_SB_125 = 2,
106  BMX280_SB_250 = 3,
107  BMX280_SB_500 = 4,
108  BMX280_SB_1000 = 5,
109  BMX280_SB_10 = 6,
110  BMX280_SB_20 = 7
111 } bmx280_t_sb_t;
112 
116 typedef enum {
117  BMX280_FILTER_OFF = 0,
118  BMX280_FILTER_2 = 1,
119  BMX280_FILTER_4 = 2,
120  BMX280_FILTER_8 = 3,
121  BMX280_FILTER_16 = 4,
123 
127 typedef enum {
128  BMX280_MODE_SLEEP = 0,
129  BMX280_MODE_FORCED = 1,
130  BMX280_MODE_FORCED2 = 2, /* Same as FORCED */
131  BMX280_MODE_NORMAL = 3
132 } bmx280_mode_t;
133 
142 typedef enum {
143  BMX280_OSRS_SKIPPED = 0,
144  BMX280_OSRS_X1 = 1,
145  BMX280_OSRS_X2 = 2,
146  BMX280_OSRS_X4 = 3,
147  BMX280_OSRS_X8 = 4,
148  BMX280_OSRS_X16 = 5,
149 } bmx280_osrs_t;
150 
156 typedef struct {
157  /* I2C details */
159  uint8_t i2c_addr;
161  /* Config Register */
164  uint8_t spi3w_en;
166  /* ctrl_meas */
171  /* ctrl_hum */
174 
178 typedef struct {
181 } bmx280_t;
182 
186 enum {
187  BMX280_OK = 0,
190 };
191 
203 int bmx280_init(bmx280_t* dev, const bmx280_params_t* params);
204 
213 int16_t bmx280_read_temperature(const bmx280_t* dev);
214 
225 uint32_t bmx280_read_pressure(const bmx280_t *dev);
226 
227 #if defined(MODULE_BME280) || defined(DOXYGEN)
228 
238 uint16_t bme280_read_humidity(const bmx280_t *dev);
239 #endif
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 #endif /* BMX280_H */
246 
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:95
i2c_t i2c_dev
I2C device which is used.
Definition: bmx280.h:158
bmx280_mode_t run_mode
ctrl_meas mode
Definition: bmx280.h:167
bmx280_params_t params
Device Parameters.
Definition: bmx280.h:179
uint8_t dig_H3
H3 coefficient.
Definition: bmx280.h:93
int16_t dig_H4
H4 coefficient.
Definition: bmx280.h:94
Device descriptor for the BMX280 sensor.
Definition: bmx280.h:178
int16_t dig_P6
P6 coefficient.
Definition: bmx280.h:86
int16_t dig_P4
P4 coefficient.
Definition: bmx280.h:84
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
int8_t dig_H6
H6 coefficient.
Definition: bmx280.h:96
uint8_t spi3w_en
Enables 3-wire SPI interface.
Definition: bmx280.h:164
uint16_t dig_P1
P1 coefficient.
Definition: bmx280.h:81
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
did not detect BME280 or BMP280
Definition: bmx280.h:188
everything was fine
Definition: bmx280.h:187
int16_t dig_T2
T2 coefficient.
Definition: bmx280.h:78
uint16_t bme280_read_humidity(const bmx280_t *dev)
Read humidity value from the given BME280 device, returned in centi RH.
bmx280_osrs_t press_oversample
ctrl_meas osrs_p
Definition: bmx280.h:169
bmx280_osrs_t temp_oversample
ctrl_meas osrs_t
Definition: bmx280.h:168
int16_t dig_P9
P9 coefficient.
Definition: bmx280.h:89
bmx280_calibration_t calibration
Calibration Data.
Definition: bmx280.h:180
bmx280_t_sb_t
Values for t_sb field of the BMX280 config register.
Definition: bmx280.h:102
bmx280_filter_t filter
filter coefficient
Definition: bmx280.h:163
uint16_t dig_T1
T1 coefficient.
Definition: bmx280.h:77
bmx280_osrs_t
Values for oversampling settings.
Definition: bmx280.h:142
bmx280_filter_t
Values for filter field of the BMX280 config register.
Definition: bmx280.h:116
int16_t dig_P7
P7 coefficient.
Definition: bmx280.h:87
int16_t dig_P2
P2 coefficient.
Definition: bmx280.h:82
Parameters for the BMX280 sensor.
Definition: bmx280.h:156
Calibration struct for the BMX280 sensor.
Definition: bmx280.h:76
bmx280_mode_t
Values for mode field of the BMX280 ctrl_meas register.
Definition: bmx280.h:127
bmx280_t_sb_t t_sb
standby
Definition: bmx280.h:162
int16_t dig_P8
P8 coefficient.
Definition: bmx280.h:88
bmx280_osrs_t humid_oversample
ctrl_hum osrs_h
Definition: bmx280.h:172
int16_t dig_H2
H2 coefficient.
Definition: bmx280.h:92
int16_t dig_P5
P5 coefficient.
Definition: bmx280.h:85
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:91
uint8_t i2c_addr
I2C address.
Definition: bmx280.h:159
int16_t dig_P3
P3 coefficient.
Definition: bmx280.h:83
int16_t dig_T3
T3 coefficient.
Definition: bmx280.h:79
Low-level I2C peripheral driver interface definition.
could not read calibration data
Definition: bmx280.h:189