AP_Compass_MAG3110.h 919 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <AP_Common/AP_Common.h>
  3. #include <AP_HAL/AP_HAL.h>
  4. #include <AP_HAL/Device.h>
  5. #include <AP_Math/AP_Math.h>
  6. #include "AP_Compass.h"
  7. #include "AP_Compass_Backend.h"
  8. #ifndef HAL_MAG3110_I2C_ADDR
  9. #define HAL_MAG3110_I2C_ADDR 0x0E
  10. #endif
  11. class AP_Compass_MAG3110 : public AP_Compass_Backend
  12. {
  13. public:
  14. static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,
  15. enum Rotation rotation);
  16. static constexpr const char *name = "MAG3110";
  17. void read() override;
  18. ~AP_Compass_MAG3110() { }
  19. private:
  20. AP_Compass_MAG3110(AP_HAL::OwnPtr<AP_HAL::Device> dev);
  21. bool init(enum Rotation rotation);
  22. bool _read_sample();
  23. bool _hardware_init();
  24. void _update();
  25. AP_HAL::OwnPtr<AP_HAL::Device> _dev;
  26. int32_t _mag_x;
  27. int32_t _mag_y;
  28. int32_t _mag_z;
  29. uint8_t _compass_instance;
  30. bool _initialised;
  31. };