CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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