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_DPS280.h
Views: 1798
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
#include <AP_HAL/utility/OwnPtr.h>
10
11
#ifndef HAL_BARO_DPS280_I2C_ADDR
12
#define HAL_BARO_DPS280_I2C_ADDR 0x76
13
#endif
14
#ifndef HAL_BARO_DPS280_I2C_ADDR2
15
#define HAL_BARO_DPS280_I2C_ADDR2 0x77
16
#endif
17
18
class AP_Baro_DPS280 : public AP_Baro_Backend {
19
public:
20
AP_Baro_DPS280(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
21
22
/* AP_Baro public interface: */
23
void update() override;
24
25
static AP_Baro_Backend *probe_280(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev) {
26
return probe(baro, std::move(dev), false);
27
}
28
29
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev, bool _is_dps310=false);
30
31
protected:
32
bool init(bool _is_dps310);
33
bool read_calibration(void);
34
void timer(void);
35
void calculate_PT(int32_t UT, int32_t UP, float &pressure, float &temperature);
36
37
void fix_config_bits16(int16_t &v, uint8_t bits) const;
38
void fix_config_bits32(int32_t &v, uint8_t bits) const;
39
void set_config_registers(void);
40
void check_health();
41
42
AP_HAL::OwnPtr<AP_HAL::Device> dev;
43
44
uint8_t instance;
45
46
uint32_t count;
47
uint8_t err_count;
48
float pressure_sum;
49
float temperature_sum;
50
float last_temperature;
51
bool pending_reset;
52
bool is_dps310;
53
54
struct dps280_cal {
55
int16_t C0; // 12bit
56
int16_t C1; // 12bit
57
int32_t C00; // 20bit
58
int32_t C10; // 20bit
59
int16_t C01; // 16bit
60
int16_t C11; // 16bit
61
int16_t C20; // 16bit
62
int16_t C21; // 16bit
63
int16_t C30; // 16bit
64
uint8_t temp_source;
65
} calibration;
66
};
67
68
class AP_Baro_DPS310 : public AP_Baro_DPS280 {
69
// like DPS280 but workaround for temperature bug
70
public:
71
using AP_Baro_DPS280::AP_Baro_DPS280;
72
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
73
};
74
75
76
#endif // AP_BARO_DPS280_ENABLED
77
78