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_IIS2MDC.h
Views: 1798
1
/*
2
* This file is free software: you can redistribute it and/or modify it
3
* under the terms of the GNU General Public License as published by the
4
* Free Software Foundation, either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* This file is distributed in the hope that it will be useful, but
8
* WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
* See the GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License along
13
* with this program. If not, see <http://www.gnu.org/licenses/>.
14
*
15
*/
16
#pragma once
17
18
#include "AP_Compass_config.h"
19
20
#if AP_COMPASS_IIS2MDC_ENABLED
21
22
#include <AP_HAL/AP_HAL.h>
23
#include <AP_HAL/I2CDevice.h>
24
25
#include "AP_Compass.h"
26
#include "AP_Compass_Backend.h"
27
28
#ifndef HAL_COMPASS_IIS2MDC_I2C_ADDR
29
#define HAL_COMPASS_IIS2MDC_I2C_ADDR 0x1E
30
#endif
31
32
#ifndef HAL_COMPASS_IIS2MDC_ORIENTATION_EXTERNAL
33
#define HAL_COMPASS_IIS2MDC_ORIENTATION_EXTERNAL ROTATION_NONE
34
#endif
35
36
#ifndef HAL_COMPASS_IIS2MDC_ORIENTATION_INTERNAL
37
#define HAL_COMPASS_IIS2MDC_ORIENTATION_INTERNAL ROTATION_NONE
38
#endif
39
40
class AP_Compass_IIS2MDC : public AP_Compass_Backend
41
{
42
public:
43
static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev,
44
bool force_external,
45
enum Rotation rotation);
46
47
void read() override;
48
49
static constexpr const char *name = "IIS2MDC";
50
51
private:
52
AP_Compass_IIS2MDC(AP_HAL::OwnPtr<AP_HAL::Device> dev,
53
bool force_external,
54
enum Rotation rotation);
55
56
bool check_whoami();
57
void timer();
58
bool init();
59
60
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
61
62
enum Rotation _rotation;
63
uint8_t _instance;
64
bool _force_external;
65
};
66
67
#endif // AP_COMPASS_IIS2MDC_ENABLED
68
69