CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Compass/AP_Compass_LSM9DS1.h
Views: 1798
1
#pragma once
2
3
#include "AP_Compass_config.h"
4
5
#if AP_COMPASS_LSM9DS1_ENABLED
6
7
#include <AP_Common/AP_Common.h>
8
#include <AP_HAL/AP_HAL.h>
9
#include <AP_HAL/Device.h>
10
#include <AP_Math/AP_Math.h>
11
12
#include "AP_Compass_Backend.h"
13
14
class AP_Compass_LSM9DS1 : public AP_Compass_Backend
15
{
16
public:
17
static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,
18
enum Rotation rotation);
19
20
static constexpr const char *name = "LSM9DS1";
21
22
void read() override;
23
24
virtual ~AP_Compass_LSM9DS1() {}
25
26
private:
27
AP_Compass_LSM9DS1(AP_HAL::OwnPtr<AP_HAL::Device> dev,
28
enum Rotation rotation);
29
bool init();
30
bool _check_id(void);
31
bool _configure(void);
32
bool _set_scale(void);
33
void _update(void);
34
35
uint8_t _register_read(uint8_t reg);
36
void _register_write(uint8_t reg, uint8_t val);
37
void _register_modify(uint8_t reg, uint8_t clearbits, uint8_t setbits);
38
bool _block_read(uint8_t reg, uint8_t *buf, uint32_t size);
39
void _dump_registers();
40
41
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
42
uint8_t _compass_instance;
43
float _scaling;
44
enum Rotation _rotation;
45
46
struct PACKED sample_regs {
47
uint8_t status;
48
int16_t val[3];
49
};
50
};
51
52
#endif
53
54