2020-12-11 19:23:00 +01:00
|
|
|
/**
|
|
|
|
* BMX280 - BME280 & BMP280 Driver for Esspressif ESP-32.
|
|
|
|
*
|
|
|
|
* MIT License
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Halit Utku Maden
|
|
|
|
* Please contact at <utkumaden@hotmail.com>
|
|
|
|
*/
|
|
|
|
|
2020-11-19 11:33:02 +01:00
|
|
|
#ifndef _BMX280_DEFAULT_H_
|
|
|
|
#define _BMX280_DEFAULT_H_
|
|
|
|
#ifndef _BMX280_H_
|
|
|
|
#error Never include "bmx280_bits.h" by itself. Remove this reference and use "bmx280.h" instead.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum bmx280_tsmpl_t {
|
|
|
|
BMX280_TEMPERATURE_OVERSAMPLING_NONE = 0x0,
|
|
|
|
BMX280_TEMPERATURE_OVERSAMPLING_X1,
|
|
|
|
BMX280_TEMPERATURE_OVERSAMPLING_X2,
|
|
|
|
BMX280_TEMPERATURE_OVERSAMPLING_X4,
|
|
|
|
BMX280_TEMPERATURE_OVERSAMPLING_X8,
|
|
|
|
BMX280_TEMPERATURE_OVERSAMPLING_X16,
|
|
|
|
} bmx280_tsmpl_t;
|
|
|
|
|
|
|
|
typedef enum bmx280_psmpl_t {
|
|
|
|
BMX280_PRESSURE_OVERSAMPLING_NONE = 0x0,
|
|
|
|
BMX280_PRESSURE_OVERSAMPLING_X1,
|
|
|
|
BMX280_PRESSURE_OVERSAMPLING_X2,
|
|
|
|
BMX280_PRESSURE_OVERSAMPLING_X4,
|
|
|
|
BMX280_PRESSURE_OVERSAMPLING_X8,
|
|
|
|
BMX280_PRESSURE_OVERSAMPLING_X16,
|
|
|
|
} bmx280_psmpl_t;
|
|
|
|
|
|
|
|
#if !(CONFIG_BMX280_EXPECT_BMP280)
|
|
|
|
typedef enum bme280_hsmpl_t {
|
|
|
|
BMX280_HUMIDITY_OVERSAMPLING_NONE = 0x0,
|
|
|
|
BMX280_HUMIDITY_OVERSAMPLING_X1,
|
|
|
|
BMX280_HUMIDITY_OVERSAMPLING_X2,
|
|
|
|
BMX280_HUMIDITY_OVERSAMPLING_X4,
|
|
|
|
BMX280_HUMIDITY_OVERSAMPLING_X8,
|
|
|
|
BMX280_HUMIDITY_OVERSAMPLING_X16,
|
|
|
|
} bme280_hsmpl_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum bmx280_tstby_t {
|
|
|
|
BMX280_STANDBY_0M5 = 0x0,
|
|
|
|
BMX280_STANDBY_62M5,
|
|
|
|
BMX280_STANDBY_125M,
|
|
|
|
BMX280_STANDBY_250M,
|
|
|
|
BMX280_STANDBY_500M,
|
|
|
|
BMX280_STANDBY_1000M,
|
|
|
|
BME280_STANDBY_10M,
|
|
|
|
BME280_STANDBY_20M,
|
|
|
|
BMP280_STANDBY_2000M = BME280_STANDBY_10M,
|
|
|
|
BMP280_STANDBY_4000M = BME280_STANDBY_20M,
|
|
|
|
} bmx280_tstby_t;
|
|
|
|
|
|
|
|
typedef enum bmx280_iirf_t {
|
|
|
|
BMX280_IIR_NONE = 0x0,
|
|
|
|
BMX280_IIR_X1,
|
|
|
|
BMX280_IIR_X2,
|
|
|
|
BMX280_IIR_X4,
|
|
|
|
BMX280_IIR_X8,
|
|
|
|
BMX280_IIR_X16,
|
|
|
|
} bmx280_iirf_t;
|
|
|
|
|
|
|
|
typedef enum bmx280_mode_t {
|
|
|
|
/** Sensor does no measurements. */
|
2020-12-11 18:40:10 +01:00
|
|
|
BMX280_MODE_SLEEP = 0,
|
2020-11-19 11:33:02 +01:00
|
|
|
/** Sensor is in a forced measurement cycle. Sleeps after finishing. */
|
2020-12-11 18:40:10 +01:00
|
|
|
BMX280_MODE_FORCE = 1,
|
2020-11-19 11:33:02 +01:00
|
|
|
/** Sensor does measurements. Never sleeps. */
|
2020-12-11 18:40:10 +01:00
|
|
|
BMX280_MODE_CYCLE = 3,
|
2020-11-19 11:33:02 +01:00
|
|
|
} bmx280_mode_t;
|
|
|
|
|
|
|
|
typedef struct bmx280_config_t {
|
|
|
|
bmx280_tsmpl_t t_sampling;
|
2021-04-28 17:05:40 +02:00
|
|
|
bmx280_psmpl_t p_sampling;
|
2020-11-19 11:33:02 +01:00
|
|
|
bmx280_tstby_t t_standby;
|
|
|
|
bmx280_iirf_t iir_filter;
|
|
|
|
#if !(CONFIG_BMX280_EXPECT_BMP280)
|
2021-04-28 17:09:21 +02:00
|
|
|
bme280_hsmpl_t h_sampling;
|
2020-11-19 11:33:02 +01:00
|
|
|
#endif
|
|
|
|
} bmx280_config_t;
|
|
|
|
|
|
|
|
#if (CONFIG_BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING_NONE)
|
|
|
|
#define BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING BMX280_TEMPERATURE_OVERSAMPLING_NONE
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING_X1)
|
|
|
|
#define BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING BMX280_TEMPERATURE_OVERSAMPLING_X1
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING_X2)
|
|
|
|
#define BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING BMX280_TEMPERATURE_OVERSAMPLING_X2
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING_X4)
|
|
|
|
#define BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING BMX280_TEMPERATURE_OVERSAMPLING_X4
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING_X8)
|
|
|
|
#define BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING BMX280_TEMPERATURE_OVERSAMPLING_X8
|
|
|
|
#else
|
|
|
|
#define BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING BMX280_TEMPERATURE_OVERSAMPLING_X16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_BMX280_DEFAULT_PRESSURE_OVERSAMPLING_NONE
|
|
|
|
#define BMX280_DEFAULT_PRESSURE_OVERSAMPLING BMX280_PRESSURE_OVERSAMPLING_NONE
|
|
|
|
#elif CONFIG_BMX280_DEFAULT_PRESSURE_OVERSAMPLING_X1
|
|
|
|
#define BMX280_DEFAULT_PRESSURE_OVERSAMPLING BMX280_PRESSURE_OVERSAMPLING_X1
|
|
|
|
#elif CONFIG_BMX280_DEFAULT_PRESSURE_OVERSAMPLING_X2
|
|
|
|
#define BMX280_DEFAULT_PRESSURE_OVERSAMPLING BMX280_PRESSURE_OVERSAMPLING_X2
|
|
|
|
#elif CONFIG_BMX280_DEFAULT_PRESSURE_OVERSAMPLING_X4
|
|
|
|
#define BMX280_DEFAULT_PRESSURE_OVERSAMPLING BMX280_PRESSURE_OVERSAMPLING_X4
|
|
|
|
#elif CONFIG_BMX280_DEFAULT_PRESSURE_OVERSAMPLING_X8
|
|
|
|
#define BMX280_DEFAULT_PRESSURE_OVERSAMPLING BMX280_PRESSURE_OVERSAMPLING_X8
|
|
|
|
#else
|
|
|
|
#define BMX280_DEFAULT_PRESSURE_OVERSAMPLING BMX280_PRESSURE_OVERSAMPLING_X16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (CONFIG_BMX280_DEFAULT_STANDBY_0M5)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_0M5
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_62M5)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_62M5
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_125M)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_125M
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_250M)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_250M
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_500M)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_500M
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_1000M)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_1000M
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_10M)
|
|
|
|
#define BMX280_DEFAULT_STANDBY BME280_STANDBY_10M
|
|
|
|
#else
|
|
|
|
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_20M
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (CONFIG_BMX280_DEFAULT_IIR_NONE)
|
|
|
|
#define BMX280_DEFAULT_IIR BMX280_IIR_NONE
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_IIR_X2)
|
|
|
|
#define BMX280_DEFAULT_IIR BMX280_IIR_X2
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_IIR_X4)
|
|
|
|
#define BMX280_DEFAULT_IIR BMX280_IIR_X4
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_IIR_X8)
|
|
|
|
#define BMX280_DEFAULT_IIR BMX280_IIR_X8
|
|
|
|
#else
|
|
|
|
#define BMX280_DEFAULT_IIR BMX280_IIR_X16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_BMX280_EXPECT_BMP280
|
2022-05-04 09:24:40 +02:00
|
|
|
#if (CONFIG_BMX280_DEFAULT_HUMIDITY_OVERSAMPLING_NONE)
|
|
|
|
#define BMX280_DEFAULT_HUMIDITY_OVERSAMPLING BMX280_HUMIDITY_OVERSAMPLING_NONE
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_HUMIDITY_OVERSAMPLING_X1)
|
|
|
|
#define BMX280_DEFAULT_HUMIDITY_OVERSAMPLING BMX280_HUMIDITY_OVERSAMPLING_X1
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_HUMIDITY_OVERSAMPLING_X2)
|
|
|
|
#define BMX280_DEFAULT_HUMIDITY_OVERSAMPLING BMX280_HUMIDITY_OVERSAMPLING_X2
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_HUMIDITY_OVERSAMPLING_X4)
|
|
|
|
#define BMX280_DEFAULT_HUMIDITY_OVERSAMPLING BMX280_HUMIDITY_OVERSAMPLING_X4
|
|
|
|
#elif (CONFIG_BMX280_DEFAULT_HUMIDITY_OVERSAMPLING_X8)
|
|
|
|
#define BMX280_DEFAULT_HUMIDITY_OVERSAMPLING BMX280_HUMIDITY_OVERSAMPLING_X8
|
|
|
|
#else
|
|
|
|
#define BMX280_DEFAULT_HUMIDITY_OVERSAMPLING BMX280_HUMIDITY_OVERSAMPLING_X16
|
|
|
|
#endif
|
2020-11-19 11:33:02 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !(CONFIG_BMX280_EXPECT_BMP280)
|
2022-05-04 09:24:40 +02:00
|
|
|
#define BMX280_DEFAULT_CONFIG ((bmx280_config_t) { BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING, BMX280_DEFAULT_PRESSURE_OVERSAMPLING, BMX280_DEFAULT_STANDBY, BMX280_DEFAULT_IIR, BMX280_DEFAULT_HUMIDITY_OVERSAMPLING })
|
2020-11-19 11:33:02 +01:00
|
|
|
#else
|
2022-05-04 09:24:40 +02:00
|
|
|
#define BMX280_DEFAULT_CONFIG ((bmx280_config_t) { BMX280_DEFAULT_TEMPERATURE_OVERSAMPLING, BMX280_DEFAULT_PRESSURE_OVERSAMPLING, BMX280_DEFAULT_STANDBY, BMX280_DEFAULT_IIR})
|
2020-11-19 11:33:02 +01:00
|
|
|
#endif
|
|
|
|
|
2022-05-04 09:27:12 +02:00
|
|
|
#endif
|