Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / drivers / barometer / barometer_spl06.h
blob096cdb7a9e2162d0106fed042bc84a4f838065b3
1 /*
2 * This file is part of INAV.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #define SPL06_I2C_ADDR 0x76
21 #define SPL06_DEFAULT_CHIP_ID 0x10
23 #define SPL06_PRESSURE_START_REG 0x00
24 #define SPL06_PRESSURE_LEN 3 // 24 bits, 3 bytes
25 #define SPL06_PRESSURE_B2_REG 0x00 // Pressure MSB Register
26 #define SPL06_PRESSURE_B1_REG 0x01 // Pressure middle byte Register
27 #define SPL06_PRESSURE_B0_REG 0x02 // Pressure LSB Register
28 #define SPL06_TEMPERATURE_START_REG 0x03
29 #define SPL06_TEMPERATURE_LEN 3 // 24 bits, 3 bytes
30 #define SPL06_TEMPERATURE_B2_REG 0x03 // Temperature MSB Register
31 #define SPL06_TEMPERATURE_B1_REG 0x04 // Temperature middle byte Register
32 #define SPL06_TEMPERATURE_B0_REG 0x05 // Temperature LSB Register
33 #define SPL06_PRESSURE_CFG_REG 0x06 // Pressure config
34 #define SPL06_TEMPERATURE_CFG_REG 0x07 // Temperature config
35 #define SPL06_MODE_AND_STATUS_REG 0x08 // Mode and status
36 #define SPL06_INT_AND_FIFO_CFG_REG 0x09 // Interrupt and FIFO config
37 #define SPL06_INT_STATUS_REG 0x0A // Interrupt and FIFO config
38 #define SPL06_FIFO_STATUS_REG 0x0B // Interrupt and FIFO config
39 #define SPL06_RST_REG 0x0C // Softreset Register
40 #define SPL06_CHIP_ID_REG 0x0D // Chip ID Register
41 #define SPL06_CALIB_COEFFS_START 0x10
42 #define SPL06_CALIB_COEFFS_END 0x21
44 #define SPL06_CALIB_COEFFS_LEN (SPL06_CALIB_COEFFS_END - SPL06_CALIB_COEFFS_START + 1)
46 // TEMPERATURE_CFG_REG
47 #define SPL06_TEMP_USE_EXT_SENSOR (1<<7)
49 // MODE_AND_STATUS_REG
50 #define SPL06_MEAS_PRESSURE (1<<0) // measure pressure
51 #define SPL06_MEAS_TEMPERATURE (1<<1) // measure temperature
53 #define SPL06_MEAS_CFG_CONTINUOUS (1<<2)
54 #define SPL06_MEAS_CFG_PRESSURE_RDY (1<<4)
55 #define SPL06_MEAS_CFG_TEMPERATURE_RDY (1<<5)
56 #define SPL06_MEAS_CFG_SENSOR_RDY (1<<6)
57 #define SPL06_MEAS_CFG_COEFFS_RDY (1<<7)
59 // INT_AND_FIFO_CFG_REG
60 #define SPL06_PRESSURE_RESULT_BIT_SHIFT (1<<2) // necessary for pressure oversampling > 8
61 #define SPL06_TEMPERATURE_RESULT_BIT_SHIFT (1<<3) // necessary for temperature oversampling > 8
63 #define SPL06_PRESSURE_OVERSAMPLING 8 // oversampling 8
64 #define SPL06_TEMPERATURE_OVERSAMPLING 8 // oversampling 8
66 #define SPL06_MEASUREMENT_TIME(oversampling) ((2 + lrintf(oversampling * 1.6)) + 1) // ms
68 bool spl06Detect(baroDev_t *baro);