AP_Compass_LSM9DS1.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. class AP_Compass_LSM9DS1 : public AP_Compass_Backend
  9. {
  10. public:
  11. static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,
  12. enum Rotation rotation);
  13. static constexpr const char *name = "LSM9DS1";
  14. void read() override;
  15. virtual ~AP_Compass_LSM9DS1() {}
  16. private:
  17. AP_Compass_LSM9DS1(AP_HAL::OwnPtr<AP_HAL::Device> dev,
  18. enum Rotation rotation);
  19. bool init();
  20. bool _check_id(void);
  21. bool _configure(void);
  22. bool _set_scale(void);
  23. void _update(void);
  24. uint8_t _register_read(uint8_t reg);
  25. void _register_write(uint8_t reg, uint8_t val);
  26. void _register_modify(uint8_t reg, uint8_t clearbits, uint8_t setbits);
  27. bool _block_read(uint8_t reg, uint8_t *buf, uint32_t size);
  28. void _dump_registers();
  29. AP_HAL::OwnPtr<AP_HAL::Device> _dev;
  30. uint8_t _compass_instance;
  31. float _scaling;
  32. enum Rotation _rotation;
  33. };