2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
24 #include "drivers/barometer/barometer.h"
25 #include "flight/position.h"
39 typedef struct barometerConfig_s
{
41 uint8_t baro_spi_device
;
42 ioTag_t baro_spi_csn
; // Also used as XCLR (positive logic) for BMP085
43 uint8_t baro_i2c_device
;
44 uint8_t baro_i2c_address
;
45 uint8_t baro_hardware
; // Barometer hardware to use
47 ioTag_t baro_xclr_tag
;
50 PG_DECLARE(barometerConfig_t
, barometerConfig
);
52 // #define TASK_BARO_DENOM 3
53 // #define TASK_BARO_RATE_HZ (TASK_ALTITUDE_RATE_HZ / TASK_BARO_DENOM)
54 #define TASK_BARO_RATE_HZ 40
56 typedef struct baro_s
{
59 int32_t baroTemperature
; // Use temperature for telemetry
60 int32_t baroPressure
; // Use pressure for telemetry
65 void baroPreInit(void);
67 bool baroIsCalibrated(void);
68 void baroStartCalibration(void);
69 void baroSetGroundLevel(void);
70 uint32_t baroUpdate(timeUs_t currentTimeUs
);
71 bool isBaroReady(void);
72 bool isBaroSampleReady(void);
73 float getBaroAltitude(void);
74 void performBaroCalibrationCycle(void);