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_BMP085.h
Views: 1798
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 <AP_HAL/utility/OwnPtr.h>
10
#include <Filter/Filter.h>
11
12
#ifndef HAL_BARO_BMP085_I2C_ADDR
13
#define HAL_BARO_BMP085_I2C_ADDR (0x77)
14
#endif
15
16
class AP_Baro_BMP085 : public AP_Baro_Backend {
17
public:
18
AP_Baro_BMP085(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
19
20
/* AP_Baro public interface: */
21
void update() override;
22
23
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
24
25
26
private:
27
bool _init();
28
29
void _cmd_read_pressure();
30
void _cmd_read_temp();
31
bool _read_pressure();
32
void _read_temp();
33
void _calculate();
34
bool _data_ready();
35
36
void _timer(void);
37
38
uint16_t _read_prom_word(uint8_t word);
39
bool _read_prom(uint16_t *prom);
40
41
42
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
43
AP_HAL::DigitalSource *_eoc;
44
45
uint8_t _instance;
46
bool _has_sample;
47
48
// Boards with no EOC pin: use times instead
49
uint32_t _last_press_read_command_time;
50
uint32_t _last_temp_read_command_time;
51
52
// State machine
53
uint8_t _state;
54
55
// Internal calibration registers
56
int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
57
uint16_t ac4, ac5, ac6;
58
59
int32_t _raw_pressure;
60
int32_t _raw_temp;
61
int32_t _temp;
62
AverageIntegralFilter<int32_t, int32_t, 10> _pressure_filter;
63
64
uint8_t _vers;
65
uint8_t _type;
66
};
67
68
#endif // AP_BARO_BMP085_ENABLED
69
70