APM:Libraries
AP_Compass_AK09916.h
Go to the documentation of this file.
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 #pragma once
16 
17 #include <AP_Common/AP_Common.h>
18 #include <AP_HAL/AP_HAL.h>
19 #include <AP_HAL/I2CDevice.h>
20 #include <AP_Math/AP_Math.h>
21 
22 #include "AP_Compass.h"
23 #include "AP_Compass_Backend.h"
24 
25 #ifndef HAL_COMPASS_AK09916_I2C_ADDR
26 # define HAL_COMPASS_AK09916_I2C_ADDR 0x0C
27 #endif
28 
29 // the AK09916 can be connected via an ICM20948
30 #ifndef HAL_COMPASS_ICM20948_I2C_ADDR
31 # define HAL_COMPASS_ICM20948_I2C_ADDR 0x69
32 #endif
33 
35 {
36 public:
39  bool force_external = false,
41 
42  // separate probe function for when behind a ICM20948 IMU
43  static AP_Compass_Backend *probe_ICM20948(Compass &compass,
46  bool force_external = false,
48 
49  void read() override;
50 
51  static constexpr const char *name = "AK09916";
52 
53 private:
54  enum bus_type {
57  } bus_type;
58 
59  AP_Compass_AK09916(Compass &compass,
62  bool force_external,
63  enum Rotation rotation,
64  enum bus_type bus_type);
65 
68 
72  bool init();
73  void timer();
74 
77  uint16_t accum_count;
80 };
AP_HAL::OwnPtr< AP_HAL::Device > dev_icm
AP_HAL::OwnPtr< AP_HAL::Device > dev
Rotation
Definition: rotations.h:27
static AP_Compass_Backend * probe(Compass &compass, AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev, bool force_external=false, enum Rotation rotation=ROTATION_NONE)
enum Rotation rotation
#define constexpr
Definition: AP_HAL_Macros.h:16
AP_Compass_AK09916(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, AP_HAL::OwnPtr< AP_HAL::Device > dev_icm, bool force_external, enum Rotation rotation, enum bus_type bus_type)
static constexpr const char * name
static Compass compass
Definition: AHRS_Test.cpp:20
Common definitions and utility routines for the ArduPilot libraries.
static AP_Compass_Backend * probe_ICM20948(Compass &compass, AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev, AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev_icm, bool force_external=false, enum Rotation rotation=ROTATION_NONE)