APM:Libraries
AP_Compass_MMC3416.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_MMC3416_I2C_ADDR
26 # define HAL_COMPASS_MMC3416_I2C_ADDR 0x30
27 #endif
28 
30 {
31 public:
34  bool force_external = false,
36 
37  void read() override;
38 
39  static constexpr const char *name = "MMC3416";
40 
41 private:
43  bool force_external,
44  enum Rotation rotation);
45 
47 
48  enum {
55  } state;
56 
60  bool init();
61  void timer();
62  void accumulate_field(Vector3f &field);
63 
66  uint16_t accum_count;
69  uint16_t measure_count;
71  uint32_t refill_start_ms;
72  uint32_t last_sample_ms;
73 
74  uint16_t data0[3];
75 
77 };
AP_Compass_MMC3416(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, bool force_external, enum Rotation rotation)
static AP_Compass_Backend * probe(Compass &compass, AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev, bool force_external=false, enum Rotation rotation=ROTATION_NONE)
static constexpr const char * name
void accumulate_field(Vector3f &field)
Rotation
Definition: rotations.h:27
enum AP_Compass_MMC3416::@19 state
#define constexpr
Definition: AP_HAL_Macros.h:16
AP_HAL::OwnPtr< AP_HAL::Device > dev
static Compass compass
Definition: AHRS_Test.cpp:20
Common definitions and utility routines for the ArduPilot libraries.
enum Rotation rotation