123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- #ifndef __BMP280_H__
- #define __BMP280_H__
- #include <stdint.h>
- #include <stdbool.h>
- #define BMP280_I2C_ADDRESS_0 0x76
- #define BMP280_I2C_ADDRESS_1 0x77
- #define BMP280_CHIP_ID 0x58
- #define BME280_CHIP_ID 0x60
- typedef enum {
- BMP280_MODE_SLEEP = 0,
- BMP280_MODE_FORCED = 1,
- BMP280_MODE_NORMAL = 3
- } BMP280_Mode;
- typedef enum {
- BMP280_FILTER_OFF = 0,
- BMP280_FILTER_2 = 1,
- BMP280_FILTER_4 = 2,
- BMP280_FILTER_8 = 3,
- BMP280_FILTER_16 = 4
- } BMP280_Filter;
- typedef enum {
- BMP280_SKIPPED = 0,
- BMP280_ULTRA_LOW_POWER = 1,
- BMP280_LOW_POWER = 2,
- BMP280_STANDARD = 3,
- BMP280_HIGH_RES = 4,
- BMP280_ULTRA_HIGH_RES = 5
- } BMP280_Oversampling;
- typedef enum {
- BMP280_STANDBY_05 = 0,
- BMP280_STANDBY_62 = 1,
- BMP280_STANDBY_125 = 2,
- BMP280_STANDBY_250 = 3,
- BMP280_STANDBY_500 = 4,
- BMP280_STANDBY_1000 = 5,
- BMP280_STANDBY_2000 = 6,
- BMP280_STANDBY_4000 = 7,
- } BMP280_StandbyTime;
- typedef struct {
- BMP280_Mode mode;
- BMP280_Filter filter;
- BMP280_Oversampling oversampling_pressure;
- BMP280_Oversampling oversampling_temperature;
- BMP280_StandbyTime standby;
- } bmp280_params_t;
- typedef struct {
- uint16_t dig_T1;
- int16_t dig_T2;
- int16_t dig_T3;
- uint16_t dig_P1;
- int16_t dig_P2;
- int16_t dig_P3;
- int16_t dig_P4;
- int16_t dig_P5;
- int16_t dig_P6;
- int16_t dig_P7;
- int16_t dig_P8;
- int16_t dig_P9;
-
- uint8_t dig_H1;
- int16_t dig_H2;
- uint8_t dig_H3;
- int16_t dig_H4;
- int16_t dig_H5;
- int8_t dig_H6;
- bmp280_params_t params;
- uint8_t id;
- } BMP280_HandleTypedef;
- void bmp280_init_default_params(bmp280_params_t *params);
- bool bmp280_init(BMP280_HandleTypedef *dev, bmp280_params_t *params);
- bool bmp280_force_measurement(void);
- bool bmp280_is_measuring(void);
- bool bmp280_read_fixed(BMP280_HandleTypedef *dev, int32_t *temperature,
- uint32_t *pressure);
- bool bmp280_read_float(BMP280_HandleTypedef *dev, float *temperature,
- float *pressure, float* asl);
- #endif
|