Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Baro/AP_Baro_BMP388.h
9794 views
1
#pragma once
2
3
#include "AP_Baro_Backend.h"
4
5
#if AP_BARO_BMP388_ENABLED
6
7
#include <AP_HAL/AP_HAL.h>
8
#include <AP_HAL/Device.h>
9
10
#ifndef HAL_BARO_BMP388_I2C_ADDR
11
#define HAL_BARO_BMP388_I2C_ADDR (0x76)
12
#endif
13
#ifndef HAL_BARO_BMP388_I2C_ADDR2
14
#define HAL_BARO_BMP388_I2C_ADDR2 (0x77)
15
#endif
16
17
class AP_Baro_BMP388 : public AP_Baro_Backend
18
{
19
public:
20
AP_Baro_BMP388(AP_Baro &baro, AP_HAL::Device &_dev);
21
22
/* AP_Baro public interface: */
23
void update() override;
24
25
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::Device &_dev);
26
27
private:
28
29
bool init(void);
30
void timer(void);
31
void update_temperature(uint32_t);
32
void update_pressure(uint32_t);
33
34
AP_HAL::Device *dev;
35
36
uint8_t instance;
37
float pressure_sum;
38
uint32_t pressure_count;
39
float temperature;
40
41
// Internal calibration registers
42
struct PACKED {
43
int16_t nvm_par_p1; // at 0x36
44
int16_t nvm_par_p2;
45
int8_t nvm_par_p3;
46
int8_t nvm_par_p4;
47
int16_t nvm_par_p5;
48
int16_t nvm_par_p6;
49
int8_t nvm_par_p7;
50
int8_t nvm_par_p8;
51
int16_t nvm_par_p9;
52
int8_t nvm_par_p10;
53
int8_t nvm_par_p11;
54
} calib_p;
55
56
struct PACKED {
57
uint16_t nvm_par_t1; // at 0x31
58
uint16_t nvm_par_t2;
59
int8_t nvm_par_t3;
60
} calib_t;
61
62
// scaled calibration data
63
struct {
64
float par_t1;
65
float par_t2;
66
float par_t3;
67
float par_p1;
68
float par_p2;
69
float par_p3;
70
float par_p4;
71
float par_p5;
72
float par_p6;
73
float par_p7;
74
float par_p8;
75
float par_p9;
76
float par_p10;
77
float par_p11;
78
float t_lin;
79
} calib;
80
81
void scale_calibration_data(void);
82
bool read_registers(uint8_t reg, uint8_t *data, uint8_t len);
83
};
84
85
#endif // AP_BARO_BMP388_ENABLED
86
87