2017-09-02 11:37:48 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
#include <AP_HAL/Device.h>
|
|
|
|
#include <AP_HAL/utility/OwnPtr.h>
|
|
|
|
|
|
|
|
#include "AP_Baro_Backend.h"
|
|
|
|
|
|
|
|
#define HAL_BARO_LPS25H_I2C_BUS 0
|
2018-08-22 21:42:06 -03:00
|
|
|
|
|
|
|
#ifndef HAL_BARO_LPS25H_I2C_ADDR
|
|
|
|
# define HAL_BARO_LPS25H_I2C_ADDR 0x5D
|
|
|
|
#endif
|
2017-09-02 11:37:48 -03:00
|
|
|
|
|
|
|
|
2018-02-06 06:39:55 -04:00
|
|
|
class AP_Baro_LPS2XH : public AP_Baro_Backend
|
2017-09-02 11:37:48 -03:00
|
|
|
{
|
|
|
|
public:
|
2018-02-06 06:39:55 -04:00
|
|
|
enum LPS2XH_TYPE {
|
|
|
|
BARO_LPS22H = 0,
|
|
|
|
BARO_LPS25H = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
AP_Baro_LPS2XH(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
|
2017-09-02 11:37:48 -03:00
|
|
|
|
|
|
|
/* AP_Baro public interface: */
|
2018-11-07 08:11:28 -04:00
|
|
|
void update() override;
|
2017-09-02 11:37:48 -03:00
|
|
|
|
|
|
|
static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
|
2018-02-15 00:00:23 -04:00
|
|
|
static AP_Baro_Backend *probe_InvensenseIMU(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev, uint8_t imu_address);
|
2018-02-06 06:39:55 -04:00
|
|
|
|
2017-09-02 11:37:48 -03:00
|
|
|
private:
|
2018-02-06 06:39:55 -04:00
|
|
|
virtual ~AP_Baro_LPS2XH(void) {};
|
2017-09-02 11:37:48 -03:00
|
|
|
|
|
|
|
bool _init(void);
|
|
|
|
void _timer(void);
|
|
|
|
void _update_temperature(void);
|
|
|
|
void _update_pressure(void);
|
2018-02-15 00:00:23 -04:00
|
|
|
bool _imu_i2c_init(uint8_t imu_address);
|
2017-09-02 11:37:48 -03:00
|
|
|
|
2018-02-15 00:00:23 -04:00
|
|
|
bool _check_whoami(void);
|
2018-02-06 06:39:55 -04:00
|
|
|
|
2017-09-02 11:37:48 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
|
|
|
|
|
|
|
|
uint8_t _instance;
|
2021-05-06 19:38:02 -03:00
|
|
|
float _pressure_sum;
|
|
|
|
uint32_t _pressure_count;
|
2017-09-02 11:37:48 -03:00
|
|
|
float _temperature;
|
2018-02-06 06:39:55 -04:00
|
|
|
|
|
|
|
uint32_t CallTime = 0;
|
|
|
|
|
2018-02-15 00:00:23 -04:00
|
|
|
enum LPS2XH_TYPE _lps2xh_type;
|
2017-09-02 11:37:48 -03:00
|
|
|
};
|