Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Baro/AP_Baro_DPS280.h
9743 views
1
#pragma once
2
3
#include "AP_Baro_Backend.h"
4
5
#if AP_BARO_DPS280_ENABLED
6
7
#include <AP_HAL/AP_HAL.h>
8
#include <AP_HAL/Device.h>
9
10
#ifndef HAL_BARO_DPS280_I2C_ADDR
11
#define HAL_BARO_DPS280_I2C_ADDR 0x76
12
#endif
13
#ifndef HAL_BARO_DPS280_I2C_ADDR2
14
#define HAL_BARO_DPS280_I2C_ADDR2 0x77
15
#endif
16
17
class AP_Baro_DPS280 : public AP_Baro_Backend {
18
public:
19
AP_Baro_DPS280(AP_Baro &baro, AP_HAL::Device &dev);
20
21
/* AP_Baro public interface: */
22
void update() override;
23
24
static AP_Baro_Backend *probe_280(AP_Baro &baro, AP_HAL::Device &dev) {
25
return probe(baro, dev, false);
26
}
27
28
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::Device &dev, bool _is_dps310=false);
29
30
protected:
31
bool init(bool _is_dps310);
32
bool read_calibration(void);
33
void timer(void);
34
void calculate_PT(int32_t UT, int32_t UP, float &pressure, float &temperature);
35
36
void fix_config_bits16(int16_t &v, uint8_t bits) const;
37
void fix_config_bits32(int32_t &v, uint8_t bits) const;
38
void set_config_registers(void);
39
void check_health();
40
41
AP_HAL::Device *dev;
42
43
uint8_t instance;
44
45
uint32_t count;
46
uint8_t err_count;
47
float pressure_sum;
48
float temperature_sum;
49
float last_temperature;
50
bool pending_reset;
51
bool is_dps310;
52
53
struct dps280_cal {
54
int16_t C0; // 12bit
55
int16_t C1; // 12bit
56
int32_t C00; // 20bit
57
int32_t C10; // 20bit
58
int16_t C01; // 16bit
59
int16_t C11; // 16bit
60
int16_t C20; // 16bit
61
int16_t C21; // 16bit
62
int16_t C30; // 16bit
63
uint8_t temp_source;
64
} calibration;
65
};
66
67
class AP_Baro_DPS310 : public AP_Baro_DPS280 {
68
// like DPS280 but workaround for temperature bug
69
public:
70
using AP_Baro_DPS280::AP_Baro_DPS280;
71
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::Device &dev);
72
};
73
74
75
#endif // AP_BARO_DPS280_ENABLED
76
77