AP_Baro_KellerLD.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. * Driver for 4 LD ... 9 LD line of pressure transducers from Keller:
  13. * http://www.keller-druck.com/home_e/paprod_e/4ld_e.asp
  14. *
  15. * These sensors operate on I2C and come in a variety of form factors.
  16. * The measurement range is between 0-200 bar depbending on the model.
  17. * They are definitely not the worlds smallest pressure transmitter.
  18. *
  19. * Default address is 0x40.
  20. */
  21. #pragma once
  22. #include "AP_Baro_Backend.h"
  23. #include <AP_HAL/AP_HAL.h>
  24. #include <AP_HAL/Semaphores.h>
  25. #include <AP_HAL/Device.h>
  26. #ifndef HAL_BARO_KELLERLD_I2C_ADDR
  27. #define HAL_BARO_KELLERLD_I2C_ADDR 0x40
  28. #endif
  29. class AP_Baro_KellerLD : public AP_Baro_Backend
  30. {
  31. public:
  32. void update() override;
  33. static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
  34. private:
  35. AP_Baro_KellerLD(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
  36. bool _init();
  37. void _timer();
  38. bool _read();
  39. void _update_and_wrap_accumulator(uint16_t pressure, uint16_t temperature, uint8_t max_count);
  40. AP_HAL::OwnPtr<AP_HAL::Device> _dev;
  41. /* Shared values between thread sampling the HW and main thread */
  42. /* These are raw outputs, not calculated values */
  43. struct {
  44. uint32_t sum_pressure;
  45. uint32_t sum_temperature;
  46. uint8_t num_samples;
  47. } _accum;
  48. uint8_t _instance;
  49. // measurement range parameters used in pressure calculation
  50. // varies based on model, stored in ROM on device
  51. float _p_min;
  52. float _p_max;
  53. };