Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Compass/AP_Compass_BMM150.h
Views: 1798
/*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/I2CDevice.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::I2CDevice> 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;5556uint8_t _compass_instance;5758struct {59int8_t x1;60int8_t y1;61int8_t x2;62int8_t y2;63uint16_t z1;64int16_t z2;65int16_t z3;66int16_t z4;67uint8_t xy1;68int8_t xy2;69uint16_t xyz1;70} _dig;7172uint32_t _last_read_ms;73enum Rotation _rotation;74bool _force_external;75};7677#endif // AP_COMPASS_BMM150_ENABLED787980