Path: blob/master/libraries/AP_Compass/AP_Compass_QMC5883L.h
9660 views
/*1* Copyright (C) 2016 Emlid Ltd. 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_QMC5883L_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#ifndef HAL_COMPASS_QMC5883L_I2C_ADDR31#define HAL_COMPASS_QMC5883L_I2C_ADDR 0x0D32#endif3334/*35setup default orientations36*/37#ifndef HAL_COMPASS_QMC5883L_ORIENTATION_EXTERNAL38#define HAL_COMPASS_QMC5883L_ORIENTATION_EXTERNAL ROTATION_ROLL_18039#endif4041#ifndef HAL_COMPASS_QMC5883L_ORIENTATION_INTERNAL42#define HAL_COMPASS_QMC5883L_ORIENTATION_INTERNAL ROTATION_ROLL_180_YAW_27043#endif4445class AP_Compass_QMC5883L : public AP_Compass_Backend46{47public:48static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,49bool force_external,50enum Rotation rotation);5152void read() override;5354static constexpr const char *name = "QMC5883L";5556private:57AP_Compass_QMC5883L(AP_HAL::OwnPtr<AP_HAL::Device> dev,58bool force_external,59enum Rotation rotation);6061void _dump_registers();62bool _check_whoami();63void timer();64bool init();6566AP_HAL::OwnPtr<AP_HAL::Device> _dev;6768enum Rotation _rotation;69bool _force_external;70};7172#endif // AP_COMPASS_QMC5883L_ENABLED737475