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_IST8308.h
Views: 1798
1
/*
2
* Copyright (C) 2018 Lucas De Marchi. 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 2 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_IST8308_ENABLED
22
23
#include <AP_Common/AP_Common.h>
24
#include <AP_HAL/AP_HAL.h>
25
#include <AP_HAL/I2CDevice.h>
26
27
#include "AP_Compass_Backend.h"
28
29
#ifndef HAL_COMPASS_IST8308_I2C_ADDR
30
#define HAL_COMPASS_IST8308_I2C_ADDR 0x0C
31
#endif
32
33
class AP_Compass_IST8308 : public AP_Compass_Backend
34
{
35
public:
36
static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev,
37
bool force_external,
38
enum Rotation rotation);
39
40
void read() override;
41
42
static constexpr const char *name = "IST8308";
43
44
private:
45
AP_Compass_IST8308(AP_HAL::OwnPtr<AP_HAL::Device> dev,
46
bool force_external,
47
enum Rotation rotation);
48
49
void timer();
50
bool init();
51
52
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
53
54
enum Rotation _rotation;
55
uint8_t _instance;
56
bool _force_external;
57
};
58
59
#endif // AP_COMPASS_IST8308_ENABLED
60
61