AP_Baro_BMP280.h 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <AP_HAL/AP_HAL.h>
  3. #include <AP_HAL/Device.h>
  4. #include <AP_HAL/utility/OwnPtr.h>
  5. #include "AP_Baro_Backend.h"
  6. #ifndef HAL_BARO_BMP280_I2C_ADDR
  7. #define HAL_BARO_BMP280_I2C_ADDR (0x76)
  8. #endif
  9. #ifndef HAL_BARO_BMP280_I2C_ADDR2
  10. #define HAL_BARO_BMP280_I2C_ADDR2 (0x77)
  11. #endif
  12. class AP_Baro_BMP280 : public AP_Baro_Backend
  13. {
  14. public:
  15. AP_Baro_BMP280(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
  16. /* AP_Baro public interface: */
  17. void update() override;
  18. static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
  19. private:
  20. bool _init(void);
  21. void _timer(void);
  22. void _update_temperature(int32_t);
  23. void _update_pressure(int32_t);
  24. AP_HAL::OwnPtr<AP_HAL::Device> _dev;
  25. bool _has_sample;
  26. uint8_t _instance;
  27. int32_t _t_fine;
  28. float _pressure;
  29. float _temperature;
  30. // Internal calibration registers
  31. int16_t _t2, _t3, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9;
  32. uint16_t _t1, _p1;
  33. };