APM:Libraries
AP_Compass_QMC5883L.h
Go to the documentation of this file.
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_Common/AP_Common.h>
20 #include <AP_HAL/AP_HAL.h>
21 #include <AP_HAL/I2CDevice.h>
22 #include <AP_Math/AP_Math.h>
23 
24 #include "AP_Compass.h"
25 #include "AP_Compass_Backend.h"
26 
27 #ifndef HAL_COMPASS_QMC5883L_I2C_ADDR
28 #define HAL_COMPASS_QMC5883L_I2C_ADDR 0x0D
29 #endif
30 
32 {
33 public:
36  bool force_external,
37  enum Rotation rotation = ROTATION_NONE);
38 
39  void read() override;
40 
41  static constexpr const char *name = "QMC5883L";
42 
43 private:
46  bool force_external,
47  enum Rotation rotation);
48 
49  void _dump_registers();
50  bool _check_whoami();
51  void timer();
52  bool init();
53 
55 
57  uint32_t _accum_count = 0;
58 
60  uint8_t _instance;
62 };
Vector3< float > Vector3f
Definition: vector3.h:246
Rotation
Definition: rotations.h:27
static AP_Compass_Backend * probe(Compass &compass, AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev, bool force_external, enum Rotation rotation=ROTATION_NONE)
AP_Compass_QMC5883L(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, bool force_external, enum Rotation rotation)
#define constexpr
Definition: AP_HAL_Macros.h:16
static AP_HAL::OwnPtr< AP_HAL::Device > dev
Definition: ICM20789.cpp:16
static Compass compass
Definition: AHRS_Test.cpp:20
AP_HAL::OwnPtr< AP_HAL::Device > _dev
Common definitions and utility routines for the ArduPilot libraries.
static constexpr const char * name