APM:Libraries
AP_Compass_BMM150.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Intel Corporation. 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 
28 {
29 public:
32 
33  void read() override;
34 
35  static constexpr const char *name = "BMM150";
36 
37 private:
39 
43  bool init();
44  void _update();
45  bool _load_trim_values();
46  int16_t _compensate_xy(int16_t xy, uint32_t rhall, int32_t txy1, int32_t txy2);
47  int16_t _compensate_z(int16_t z, uint32_t rhall);
48 
50 
52  uint32_t _accum_count;
53 
55 
56  struct {
57  int8_t x1;
58  int8_t y1;
59  int8_t x2;
60  int8_t y2;
61  uint16_t z1;
62  int16_t z2;
63  int16_t z3;
64  int16_t z4;
65  uint8_t xy1;
66  int8_t xy2;
67  uint16_t xyz1;
68  } _dig;
69 
70  uint32_t _last_read_ms;
72 };
AP_Compass_BMM150(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev)
static AP_Compass_Backend * probe(Compass &compass, AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev)
int16_t _compensate_xy(int16_t xy, uint32_t rhall, int32_t txy1, int32_t txy2)
int16_t _compensate_z(int16_t z, uint32_t rhall)
struct AP_Compass_BMM150::@18 _dig
AP_HAL::OwnPtr< AP_HAL::Device > _dev
void read() override
#define constexpr
Definition: AP_HAL_Macros.h:16
void * perf_counter_t
Definition: Util.h:101
static AP_HAL::OwnPtr< AP_HAL::Device > dev
Definition: ICM20789.cpp:16
static constexpr const char * name
AP_HAL::Util::perf_counter_t _perf_err
static Compass compass
Definition: AHRS_Test.cpp:20
Common definitions and utility routines for the ArduPilot libraries.