Double MSP (TLM and MAVLink) throughput for Gemini hardware (#3037)
[ExpressLRS.git] / src / lib / Baro / baro_bmp280.h
blob91e18124d265425477a702f5c4a7df8e3f30ccc0
1 #pragma once
3 #include "baro_base.h"
4 #include "baro_bmp280_regs.h"
6 class BMP280 : public BaroI2CBase
8 public:
9 BMP280() : BaroI2CBase(), m_calib{0} {}
11 // Detect if chip is present
12 static bool detect();
14 // BaroBase methods
15 void initialize();
16 uint8_t getTemperatureDuration();
17 void startTemperature();
18 int32_t getTemperature();
19 // Temperature and Pressure are measured at the same time
20 uint8_t getPressureDuration() { return 0; }
21 void startPressure() {}
22 uint32_t getPressure();
24 protected:
25 // Filter 4: 1x=1.2PaRMS 2x=1.0PaRMS 4x=0.8PaRMS 8x=0.6PaRMS 16x=0.5PaRMS
26 // Filter 8: 1x=0.9PaRMS 2x=0.6PaRMS 4x=0.5PaRMS 8x=0.4PaRMS 16x=0.4PaRMS
27 // 16x pressure 1x Temp = 40.925ms
28 // 8x pressure 1x Temp = 22.525ms
29 static const uint8_t FILTER_COEFF = BMP280_FILTER_COEFF_8; // 8 in iNav
30 static const uint8_t OVERSAMPLING_PRESSURE = BMP280_OVERSAMP_8X; // 8x in iNav
31 static const uint8_t OVERSAMPLING_TEMPERATURE = BMP280_OVERSAMP_1X; // 1x in iNav
32 static const uint8_t FREERUNNING_NUM_SAMPLES = 4; // Report after this number of samples complete
34 // calibration data, if initialized
35 // Packed to be able to read all at once
36 struct tagCalibrationData
38 uint16_t dig_T1;
39 int16_t dig_T2;
40 int16_t dig_T3;
41 uint16_t dig_P1;
42 int16_t dig_P2;
43 int16_t dig_P3;
44 int16_t dig_P4;
45 int16_t dig_P5;
46 int16_t dig_P6;
47 int16_t dig_P7;
48 int16_t dig_P8;
49 int16_t dig_P9;
50 } __attribute__((packed)) m_calib;
52 uint32_t m_pressureLast;