2018-02-02 05:25:24 -04:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-19 21:05:15 -04:00
|
|
|
#include "AP_Compass_config.h"
|
|
|
|
|
|
|
|
#if AP_COMPASS_MAG3110_ENABLED
|
|
|
|
|
2018-02-02 05:25:24 -04:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
#include <AP_HAL/Device.h>
|
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
|
|
|
|
#include "AP_Compass.h"
|
|
|
|
#include "AP_Compass_Backend.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef HAL_MAG3110_I2C_ADDR
|
|
|
|
#define HAL_MAG3110_I2C_ADDR 0x0E
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class AP_Compass_MAG3110 : public AP_Compass_Backend
|
|
|
|
{
|
|
|
|
public:
|
2018-08-06 19:21:27 -03:00
|
|
|
static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,
|
2019-09-01 19:17:05 -03:00
|
|
|
enum Rotation rotation);
|
2018-02-02 05:25:24 -04:00
|
|
|
|
|
|
|
static constexpr const char *name = "MAG3110";
|
|
|
|
|
|
|
|
void read() override;
|
|
|
|
|
|
|
|
~AP_Compass_MAG3110() { }
|
|
|
|
|
|
|
|
private:
|
2018-08-06 19:21:27 -03:00
|
|
|
AP_Compass_MAG3110(AP_HAL::OwnPtr<AP_HAL::Device> dev);
|
2018-02-02 05:25:24 -04:00
|
|
|
|
|
|
|
bool init(enum Rotation rotation);
|
|
|
|
|
|
|
|
bool _read_sample();
|
|
|
|
|
|
|
|
bool _hardware_init();
|
|
|
|
void _update();
|
|
|
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
|
|
|
|
|
|
|
|
int32_t _mag_x;
|
|
|
|
int32_t _mag_y;
|
|
|
|
int32_t _mag_z;
|
|
|
|
|
|
|
|
uint8_t _compass_instance;
|
|
|
|
bool _initialised;
|
|
|
|
};
|
2023-02-19 21:05:15 -04:00
|
|
|
|
|
|
|
#endif // AP_COMPASS_MAG3110_ENABLED
|