Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Baro/AP_Baro_BMP085.h
9751 views
1
#pragma once
2
3
#include "AP_Baro_Backend.h"
4
5
#if AP_BARO_BMP085_ENABLED
6
7
#include <AP_HAL/AP_HAL.h>
8
#include <AP_HAL/I2CDevice.h>
9
#include <Filter/Filter.h>
10
11
#ifndef HAL_BARO_BMP085_I2C_ADDR
12
#define HAL_BARO_BMP085_I2C_ADDR (0x77)
13
#endif
14
15
class AP_Baro_BMP085 : public AP_Baro_Backend {
16
public:
17
AP_Baro_BMP085(AP_Baro &baro, AP_HAL::Device &dev);
18
19
/* AP_Baro public interface: */
20
void update() override;
21
22
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::Device &dev);
23
24
25
private:
26
bool _init();
27
28
void _cmd_read_pressure();
29
void _cmd_read_temp();
30
bool _read_pressure();
31
void _read_temp();
32
void _calculate();
33
bool _data_ready();
34
35
void _timer(void);
36
37
uint16_t _read_prom_word(uint8_t word);
38
bool _read_prom(uint16_t *prom);
39
40
41
AP_HAL::Device *_dev;
42
AP_HAL::DigitalSource *_eoc;
43
44
uint8_t _instance;
45
bool _has_sample;
46
47
// Boards with no EOC pin: use times instead
48
uint32_t _last_press_read_command_time;
49
uint32_t _last_temp_read_command_time;
50
51
// State machine
52
uint8_t _state;
53
54
// Internal calibration registers
55
int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
56
uint16_t ac4, ac5, ac6;
57
58
int32_t _raw_pressure;
59
int32_t _raw_temp;
60
int32_t _temp;
61
AverageIntegralFilter<int32_t, int32_t, 10> _pressure_filter;
62
63
uint8_t _vers;
64
uint8_t _type;
65
};
66
67
#endif // AP_BARO_BMP085_ENABLED
68
69