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 
39 #ifndef BMX280_H
40 #define BMX280_H
41 
42 #include <inttypes.h>
43 #include "saul.h"
44 #include "periph/i2c.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
55 typedef struct {
56  uint16_t dig_T1;
57  int16_t dig_T2;
58  int16_t dig_T3;
60  uint16_t dig_P1;
61  int16_t dig_P2;
62  int16_t dig_P3;
63  int16_t dig_P4;
64  int16_t dig_P5;
65  int16_t dig_P6;
66  int16_t dig_P7;
67  int16_t dig_P8;
68  int16_t dig_P9;
70  uint8_t dig_H1;
71  int16_t dig_H2;
72  uint8_t dig_H3;
73  int16_t dig_H4;
74  int16_t dig_H5;
75  int8_t dig_H6;
77 
81 typedef enum {
82  BMX280_SB_0_5 = 0,
83  BMX280_SB_62_5 = 1,
84  BMX280_SB_125 = 2,
85  BMX280_SB_250 = 3,
86  BMX280_SB_500 = 4,
87  BMX280_SB_1000 = 5,
88  BMX280_SB_10 = 6,
89  BMX280_SB_20 = 7
91 
95 typedef enum {
96  BMX280_FILTER_OFF = 0,
97  BMX280_FILTER_2 = 1,
98  BMX280_FILTER_4 = 2,
99  BMX280_FILTER_8 = 3,
100  BMX280_FILTER_16 = 4,
102 
106 typedef enum {
107  BMX280_MODE_SLEEP = 0,
108  BMX280_MODE_FORCED = 1,
109  BMX280_MODE_FORCED2 = 2, /* Same as FORCED */
110  BMX280_MODE_NORMAL = 3
111 } bmx280_mode_t;
112 
121 typedef enum {
122  BMX280_OSRS_SKIPPED = 0,
123  BMX280_OSRS_X1 = 1,
124  BMX280_OSRS_X2 = 2,
125  BMX280_OSRS_X4 = 3,
126  BMX280_OSRS_X8 = 4,
127  BMX280_OSRS_X16 = 5,
128 } bmx280_osrs_t;
129 
135 typedef struct {
136  /* I2C details */
138  uint8_t i2c_addr;
140  /* Config Register */
143  uint8_t spi3w_en;
145  /* ctrl_meas */
150  /* ctrl_hum */
153 
157 typedef struct {
160 } bmx280_t;
161 
165 enum {
166  BMX280_OK = 0,
170 };
171 
183 int bmx280_init(bmx280_t* dev, const bmx280_params_t* params);
184 
193 int16_t bmx280_read_temperature(const bmx280_t* dev);
194 
205 uint32_t bmx280_read_pressure(const bmx280_t *dev);
206 
207 #if defined(MODULE_BME280)
208 
218 uint16_t bme280_read_humidity(const bmx280_t *dev);
219 #endif
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif /* BMX280_H */
226 
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.
everything was fine
Definition: bmx280.h:166
int16_t dig_H5
H5 coefficient.
Definition: bmx280.h:74
i2c_t i2c_dev
I2C device which is used.
Definition: bmx280.h:137
bmx280_mode_t run_mode
ctrl_meas mode
Definition: bmx280.h:146
bmx280_params_t params
Device Parameters.
Definition: bmx280.h:158
uint8_t dig_H3
H3 coefficient.
Definition: bmx280.h:72
int16_t dig_H4
H4 coefficient.
Definition: bmx280.h:73
Device descriptor for the BMX280 sensor.
Definition: bmx280.h:157
int16_t dig_P6
P6 coefficient.
Definition: bmx280.h:65
int16_t dig_P4
P4 coefficient.
Definition: bmx280.h:63
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:108
int8_t dig_H6
H6 coefficient.
Definition: bmx280.h:75
uint8_t spi3w_en
Enables 3-wire SPI interface.
Definition: bmx280.h:143
did not detect BME280 or BMP280
Definition: bmx280.h:168
uint16_t dig_P1
P1 coefficient.
Definition: bmx280.h:60
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
int16_t dig_T2
T2 coefficient.
Definition: bmx280.h:57
bmx280_osrs_t press_oversample
ctrl_meas osrs_p
Definition: bmx280.h:148
error initializing the I2C bus
Definition: bmx280.h:167
bmx280_osrs_t temp_oversample
ctrl_meas osrs_t
Definition: bmx280.h:147
int16_t dig_P9
P9 coefficient.
Definition: bmx280.h:68
bmx280_calibration_t calibration
Calibration Data.
Definition: bmx280.h:159
bmx280_t_sb_t
Values for t_sb field of the BMX280 config register.
Definition: bmx280.h:81
bmx280_filter_t filter
filter coefficient
Definition: bmx280.h:142
uint16_t dig_T1
T1 coefficient.
Definition: bmx280.h:56
Adds include for missing inttype definitions.
bmx280_osrs_t
Values for oversampling settings.
Definition: bmx280.h:121
bmx280_filter_t
Values for filter field of the BMX280 config register.
Definition: bmx280.h:95
int16_t dig_P7
P7 coefficient.
Definition: bmx280.h:66
int16_t dig_P2
P2 coefficient.
Definition: bmx280.h:61
Parameters for the BMX280 sensor.
Definition: bmx280.h:135
Calibration struct for the BMX280 sensor.
Definition: bmx280.h:55
bmx280_mode_t
Values for mode field of the BMX280 ctrl_meas register.
Definition: bmx280.h:106
bmx280_t_sb_t t_sb
standby
Definition: bmx280.h:141
int16_t dig_P8
P8 coefficient.
Definition: bmx280.h:67
bmx280_osrs_t humid_oversample
ctrl_hum osrs_h
Definition: bmx280.h:151
int16_t dig_H2
H2 coefficient.
Definition: bmx280.h:71
int16_t dig_P5
P5 coefficient.
Definition: bmx280.h:64
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:70
uint8_t i2c_addr
I2C address.
Definition: bmx280.h:138
int16_t dig_P3
P3 coefficient.
Definition: bmx280.h:62
could not read calibration data
Definition: bmx280.h:169
int16_t dig_T3
T3 coefficient.
Definition: bmx280.h:58
Low-level I2C peripheral driver interface definition.