AP_Baro_DPS280.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_DPS280_I2C_ADDR
  7. #define HAL_BARO_DPS280_I2C_ADDR 0x76
  8. #endif
  9. #ifndef HAL_BARO_DPS280_I2C_ADDR2
  10. #define HAL_BARO_DPS280_I2C_ADDR2 0x77
  11. #endif
  12. class AP_Baro_DPS280 : public AP_Baro_Backend {
  13. public:
  14. AP_Baro_DPS280(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
  15. /* AP_Baro public interface: */
  16. void update() override;
  17. static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
  18. private:
  19. bool init(void);
  20. bool read_calibration(void);
  21. void timer(void);
  22. void calculate_PT(int32_t UT, int32_t UP, float &pressure, float &temperature);
  23. void fix_config_bits16(int16_t &v, uint8_t bits) const;
  24. void fix_config_bits32(int32_t &v, uint8_t bits) const;
  25. AP_HAL::OwnPtr<AP_HAL::Device> dev;
  26. uint8_t instance;
  27. uint32_t count;
  28. float pressure_sum;
  29. float temperature_sum;
  30. struct dps280_cal {
  31. int16_t C0; // 12bit
  32. int16_t C1; // 12bit
  33. int32_t C00; // 20bit
  34. int32_t C10; // 20bit
  35. int16_t C01; // 16bit
  36. int16_t C11; // 16bit
  37. int16_t C20; // 16bit
  38. int16_t C21; // 16bit
  39. int16_t C30; // 16bit
  40. uint8_t temp_source;
  41. } calibration;
  42. };