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