2016-04-25 12:04:23 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
|
|
class AP_Compass_LSM9DS1 : 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,
|
2016-11-11 09:38:54 -04:00
|
|
|
enum Rotation rotation = ROTATION_NONE);
|
2016-04-25 12:04:23 -03:00
|
|
|
|
2016-05-13 13:47:05 -03:00
|
|
|
static constexpr const char *name = "LSM9DS1";
|
|
|
|
|
2016-04-25 12:04:23 -03:00
|
|
|
void read() override;
|
|
|
|
|
|
|
|
virtual ~AP_Compass_LSM9DS1() {}
|
|
|
|
|
|
|
|
private:
|
2018-08-06 19:21:27 -03:00
|
|
|
AP_Compass_LSM9DS1(AP_HAL::OwnPtr<AP_HAL::Device> dev,
|
2016-11-11 09:38:54 -04:00
|
|
|
enum Rotation rotation = ROTATION_NONE);
|
2016-11-09 07:33:38 -04:00
|
|
|
bool init();
|
2016-04-25 12:04:23 -03:00
|
|
|
bool _check_id(void);
|
|
|
|
bool _configure(void);
|
|
|
|
bool _set_scale(void);
|
2017-01-13 15:26:14 -04:00
|
|
|
void _update(void);
|
2016-04-25 12:04:23 -03:00
|
|
|
|
|
|
|
uint8_t _register_read(uint8_t reg);
|
|
|
|
void _register_write(uint8_t reg, uint8_t val);
|
|
|
|
void _register_modify(uint8_t reg, uint8_t clearbits, uint8_t setbits);
|
|
|
|
bool _block_read(uint8_t reg, uint8_t *buf, uint32_t size);
|
|
|
|
void _dump_registers();
|
|
|
|
|
2016-11-03 21:27:36 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
|
|
|
|
uint8_t _compass_instance;
|
|
|
|
float _scaling;
|
2016-11-11 09:38:54 -04:00
|
|
|
enum Rotation _rotation;
|
2016-04-25 12:04:23 -03:00
|
|
|
};
|