Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Baro/AP_Baro_LPS2XH.h
9316 views
1
#pragma once
2
3
#include "AP_Baro_Backend.h"
4
5
#if AP_BARO_LPS2XH_ENABLED
6
7
#include <AP_HAL/AP_HAL.h>
8
#include <AP_HAL/Device.h>
9
#include <AP_Math/AP_Math.h>
10
11
#define HAL_BARO_LPS25H_I2C_BUS 0
12
13
#ifndef HAL_BARO_LPS25H_I2C_ADDR
14
# define HAL_BARO_LPS25H_I2C_ADDR 0x5D
15
#endif
16
17
18
class AP_Baro_LPS2XH : public AP_Baro_Backend
19
{
20
public:
21
enum LPS2XH_TYPE {
22
BARO_LPS22H = 0,
23
BARO_LPS25H = 1,
24
};
25
26
AP_Baro_LPS2XH(AP_Baro &baro, AP_HAL::Device &dev);
27
28
/* AP_Baro public interface: */
29
void update() override;
30
31
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::Device &dev);
32
static AP_Baro_Backend *probe_InvensenseIMU(AP_Baro &baro, AP_HAL::Device &dev, uint8_t imu_address);
33
34
private:
35
virtual ~AP_Baro_LPS2XH(void) {};
36
37
bool _init(void);
38
void _timer(void);
39
void _update_temperature(void);
40
void _update_pressure(void);
41
bool _imu_i2c_init(uint8_t imu_address);
42
43
bool _check_whoami(void);
44
45
AP_HAL::Device *_dev;
46
47
uint8_t _instance;
48
float _pressure_sum;
49
uint32_t _pressure_count;
50
float _temperature;
51
52
uint32_t CallTime = 0;
53
54
enum LPS2XH_TYPE _lps2xh_type;
55
};
56
57
#endif // AP_BARO_LPS2XH_ENABLED
58
59