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_LPS2XH.h
Views: 1798
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_HAL/utility/OwnPtr.h>
10
#include <AP_Math/AP_Math.h>
11
12
#define HAL_BARO_LPS25H_I2C_BUS 0
13
14
#ifndef HAL_BARO_LPS25H_I2C_ADDR
15
# define HAL_BARO_LPS25H_I2C_ADDR 0x5D
16
#endif
17
18
19
class AP_Baro_LPS2XH : public AP_Baro_Backend
20
{
21
public:
22
enum LPS2XH_TYPE {
23
BARO_LPS22H = 0,
24
BARO_LPS25H = 1,
25
};
26
27
AP_Baro_LPS2XH(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
28
29
/* AP_Baro public interface: */
30
void update() override;
31
32
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
33
static AP_Baro_Backend *probe_InvensenseIMU(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev, uint8_t imu_address);
34
35
private:
36
virtual ~AP_Baro_LPS2XH(void) {};
37
38
bool _init(void);
39
void _timer(void);
40
void _update_temperature(void);
41
void _update_pressure(void);
42
bool _imu_i2c_init(uint8_t imu_address);
43
44
bool _check_whoami(void);
45
46
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
47
48
uint8_t _instance;
49
float _pressure_sum;
50
uint32_t _pressure_count;
51
float _temperature;
52
53
uint32_t CallTime = 0;
54
55
enum LPS2XH_TYPE _lps2xh_type;
56
};
57
58
#endif // AP_BARO_LPS2XH_ENABLED
59
60