Path: blob/master/libraries/AP_Compass/AP_Compass_BMM150.h
9573 views
/*1* Copyright (C) 2016 Intel Corporation. All rights reserved.2*3* This file is free software: you can redistribute it and/or modify it4* under the terms of the GNU General Public License as published by the5* Free Software Foundation, either version 3 of the License, or6* (at your option) any later version.7*8* This file is distributed in the hope that it will be useful, but9* WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.11* See the GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License along14* with this program. If not, see <http://www.gnu.org/licenses/>.15*/16#pragma once1718#include "AP_Compass_config.h"1920#if AP_COMPASS_BMM150_ENABLED2122#include <AP_Common/AP_Common.h>23#include <AP_HAL/AP_HAL.h>24#include <AP_HAL/Device.h>25#include <AP_Math/AP_Math.h>2627#include "AP_Compass.h"28#include "AP_Compass_Backend.h"2930#define BMM150_I2C_ADDR_MIN 0x1031#define BMM150_I2C_ADDR_MAX 0x133233class AP_Compass_BMM150 : public AP_Compass_Backend34{35public:36static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev, bool force_external, enum Rotation rotation);3738void read() override;3940static constexpr const char *name = "BMM150";4142private:43AP_Compass_BMM150(AP_HAL::OwnPtr<AP_HAL::Device> dev, bool force_external, enum Rotation rotation);4445/**46* Device periodic callback to read data from the sensor.47*/48bool init();49void _update();50bool _load_trim_values();51int16_t _compensate_xy(int16_t xy, uint32_t rhall, int32_t txy1, int32_t txy2) const;52int16_t _compensate_z(int16_t z, uint32_t rhall) const;5354AP_HAL::OwnPtr<AP_HAL::Device> _dev;5556struct {57int8_t x1;58int8_t y1;59int8_t x2;60int8_t y2;61uint16_t z1;62int16_t z2;63int16_t z3;64int16_t z4;65uint8_t xy1;66int8_t xy2;67uint16_t xyz1;68} _dig;6970uint32_t _last_read_ms;71enum Rotation _rotation;72bool _force_external;73};7475#endif // AP_COMPASS_BMM150_ENABLED767778