Loading...
Searching...
No Matches
bmx280.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Kees Bakker, SODAQ
3 * SPDX-FileCopyrightText: 2017 Inria
4 * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
5 * SPDX-License-Identifier: LGPL-2.1-only
6 */
7
8#pragma once
9
71
72#include <stdint.h>
73#include "saul.h"
74
75#if defined(MODULE_BME280_SPI) || defined(MODULE_BMP280_SPI)
76#define BMX280_USE_SPI
77#include "periph/spi.h"
78#else
79#include "periph/i2c.h"
80#endif
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
89#if defined(MODULE_BME280_SPI) || defined(MODULE_BME280_I2C)
90#define BMX280_RAW_LEN (8U)
91#else
92#define BMX280_RAW_LEN (6U)
93#endif
94
100typedef struct {
101 uint16_t dig_T1;
102 int16_t dig_T2;
103 int16_t dig_T3;
104
105 uint16_t dig_P1;
106 int16_t dig_P2;
107 int16_t dig_P3;
108 int16_t dig_P4;
109 int16_t dig_P5;
110 int16_t dig_P6;
111 int16_t dig_P7;
112 int16_t dig_P8;
113 int16_t dig_P9;
114
115 uint8_t dig_H1;
116 int16_t dig_H2;
117 uint8_t dig_H3;
118 int16_t dig_H4;
119 int16_t dig_H5;
120 int8_t dig_H6;
122
126typedef enum {
127 BMX280_SB_0_5 = 0x00,
128 BMX280_SB_62_5 = 0x20,
129 BMX280_SB_125 = 0x40,
130 BMX280_SB_250 = 0x60,
131 BMX280_SB_500 = 0x80,
132 BMX280_SB_1000 = 0xa0,
133 BMX280_SB_10 = 0xc0,
134 BMX280_SB_20 = 0xe0,
136
140typedef enum {
141 BMX280_FILTER_OFF = 0x00,
142 BMX280_FILTER_2 = 0x04,
143 BMX280_FILTER_4 = 0x08,
144 BMX280_FILTER_8 = 0x0c,
145 BMX280_FILTER_16 = 0x10,
147
151typedef enum {
152 BMX280_MODE_SLEEP = 0x00,
153 BMX280_MODE_FORCED = 0x01,
154 BMX280_MODE_NORMAL = 0x03,
156
165typedef enum {
166 BMX280_OSRS_SKIPPED = 0x00,
167 BMX280_OSRS_X1 = 0x01,
168 BMX280_OSRS_X2 = 0x02,
169 BMX280_OSRS_X4 = 0x03,
170 BMX280_OSRS_X8 = 0x04,
171 BMX280_OSRS_X16 = 0x05,
173
179typedef struct {
180#ifdef BMX280_USE_SPI
181 /* SPI configuration */
182 spi_t spi;
183 spi_clk_t clk;
184 gpio_t cs;
185#else
186 /* I2C details */
188 uint8_t i2c_addr;
189#endif
190
191 /* Config Register */
194
195 /* ctrl_meas */
199
200 /* ctrl_hum */
203
213
217enum {
221};
222
227
232
233#if defined(MODULE_BME280_SPI) || defined(MODULE_BME280_I2C)
237extern const saul_driver_t bme280_relative_humidity_saul_driver;
238#endif
239
250int bmx280_init(bmx280_t* dev, const bmx280_params_t* params);
251
263
281
282#if defined(MODULE_BME280_SPI) || defined(MODULE_BME280_I2C) || defined(DOXYGEN)
300#endif
301
302#ifdef __cplusplus
303}
304#endif
305
spi_clk_t
Definition periph_cpu.h:348
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
uint16_t bme280_read_humidity(bmx280_t *dev)
Read humidity value from the given BME280 device.
bmx280_osrs_t
Values for oversampling settings.
Definition bmx280.h:165
int16_t bmx280_read_temperature(bmx280_t *dev)
Read temperature value from the given BMX280 device.
const saul_driver_t bmx280_temperature_saul_driver
Export of SAUL interface for temperature sensor.
const saul_driver_t bmx280_pressure_saul_driver
Export of SAUL interface for pressure sensor.
uint32_t bmx280_read_pressure(bmx280_t *dev)
Read air pressure value from the given BMX280 device.
bmx280_mode_t
Values for mode field of the BMX280 ctrl_meas register.
Definition bmx280.h:151
int bmx280_init(bmx280_t *dev, const bmx280_params_t *params)
Initialize the given BMX280 device.
#define BMX280_RAW_LEN
Select the number or raw data bytes depending on the device type.
Definition bmx280.h:92
bmx280_t_sb_t
Values for t_sb field of the BMX280 config register.
Definition bmx280.h:126
bmx280_filter_t
Values for filter field of the BMX280 config register.
Definition bmx280.h:140
@ BMX280_ERR_BUS
bus error
Definition bmx280.h:219
@ BMX280_ERR_NODEV
did not detect BME280 or BMP280
Definition bmx280.h:220
@ BMX280_OK
everything was fine
Definition bmx280.h:218
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Low-level SPI peripheral driver interface definition.
Calibration struct for the BMX280 sensor.
Definition bmx280.h:100
int16_t dig_P8
P8 coefficient.
Definition bmx280.h:112
int16_t dig_P9
P9 coefficient.
Definition bmx280.h:113
int16_t dig_P7
P7 coefficient.
Definition bmx280.h:111
uint16_t dig_T1
T1 coefficient.
Definition bmx280.h:101
int16_t dig_T3
T3 coefficient.
Definition bmx280.h:103
uint8_t dig_H3
H3 coefficient.
Definition bmx280.h:117
uint8_t dig_H1
H1 coefficient.
Definition bmx280.h:115
int8_t dig_H6
H6 coefficient.
Definition bmx280.h:120
int16_t dig_H2
H2 coefficient.
Definition bmx280.h:116
uint16_t dig_P1
P1 coefficient.
Definition bmx280.h:105
int16_t dig_P4
P4 coefficient.
Definition bmx280.h:108
int16_t dig_T2
T2 coefficient.
Definition bmx280.h:102
int16_t dig_P2
P2 coefficient.
Definition bmx280.h:106
int16_t dig_H4
H4 coefficient.
Definition bmx280.h:118
int16_t dig_H5
H5 coefficient.
Definition bmx280.h:119
int16_t dig_P6
P6 coefficient.
Definition bmx280.h:110
int16_t dig_P3
P3 coefficient.
Definition bmx280.h:107
int16_t dig_P5
P5 coefficient.
Definition bmx280.h:109
Parameters for the BMX280 sensor.
Definition bmx280.h:179
i2c_t i2c_dev
I2C device which is used.
Definition bmx280.h:187
bmx280_osrs_t temp_oversample
ctrl_meas osrs_t
Definition bmx280.h:197
uint8_t i2c_addr
I2C address.
Definition bmx280.h:188
bmx280_mode_t run_mode
ctrl_meas mode
Definition bmx280.h:196
bmx280_t_sb_t t_sb
standby
Definition bmx280.h:192
bmx280_osrs_t humid_oversample
ctrl_hum osrs_h
Definition bmx280.h:201
bmx280_filter_t filter
filter coefficient
Definition bmx280.h:193
bmx280_osrs_t press_oversample
ctrl_meas osrs_p
Definition bmx280.h:198
Device descriptor for the BMX280 sensor.
Definition bmx280.h:207
uint8_t last_reading[BMX280_RAW_LEN]
cache the RAW data
Definition bmx280.h:211
bmx280_params_t params
Device Parameters.
Definition bmx280.h:208
int32_t t_fine
temperature compensation value
Definition bmx280.h:210
bmx280_calibration_t calibration
Calibration Data.
Definition bmx280.h:209
Definition of the RIOT actuator/sensor interface.
Definition saul.h:286