APM:Libraries
AP_Compass_LIS3MDL.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/Device.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_LIS3MDL_I2C_ADDR
26 # define HAL_COMPASS_LIS3MDL_I2C_ADDR 0x1c
27 #endif
28 
29 #ifndef HAL_COMPASS_LIS3MDL_I2C_ADDR2
30 # define HAL_COMPASS_LIS3MDL_I2C_ADDR2 0x1e
31 #endif
32 
34 {
35 public:
38  bool force_external = false,
40 
41  void read() override;
42 
43  static constexpr const char *name = "LIS3MDL";
44 
45 private:
47  bool force_external,
48  enum Rotation rotation);
49 
51 
55  bool init();
56  void timer();
57 
60  uint16_t accum_count;
63 };
static AP_Compass_Backend * probe(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, bool force_external=false, enum Rotation rotation=ROTATION_NONE)
static constexpr const char * name
Rotation
Definition: rotations.h:27
AP_Compass_LIS3MDL(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, bool force_external, enum Rotation rotation)
#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