Path: blob/master/libraries/AP_Compass/AP_Compass_QMC5883P.h
9660 views
/*1* This file is free software: you can redistribute it and/or modify it2* under the terms of the GNU General Public License as published by the3* Free Software Foundation, either version 3 of the License, or4* (at your option) any later version.5*6* This file is distributed in the hope that it will be useful, but7* WITHOUT ANY WARRANTY; without even the implied warranty of8* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.9* See the GNU General Public License for more details.10*11* You should have received a copy of the GNU General Public License along12* with this program. If not, see <http://www.gnu.org/licenses/>.13*14* Driver by Lokesh Ramina, Jan 202215*/16#pragma once1718#include <AP_HAL/AP_HAL.h>19#include <AP_HAL/Device.h>20#include <AP_Math/AP_Math.h>2122#include "AP_Compass_config.h"2324#ifdef AP_COMPASS_QMC5883P_ENABLED2526#include "AP_Compass.h"27#include "AP_Compass_Backend.h"2829#ifndef HAL_COMPASS_QMC5883P_I2C_ADDR30#define HAL_COMPASS_QMC5883P_I2C_ADDR 0x2C31#endif3233/*34setup default orientations35*/36#ifndef HAL_COMPASS_QMC5883P_ORIENTATION_EXTERNAL37#define HAL_COMPASS_QMC5883P_ORIENTATION_EXTERNAL ROTATION_ROLL_18038#endif3940#ifndef HAL_COMPASS_QMC5883P_ORIENTATION_INTERNAL41#define HAL_COMPASS_QMC5883P_ORIENTATION_INTERNAL ROTATION_ROLL_180_YAW_27042#endif4344class AP_Compass_QMC5883P : public AP_Compass_Backend45{46public:47static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,48bool force_external,49enum Rotation rotation);5051void read() override;5253static constexpr const char *name = "QMC5883P";5455private:56AP_Compass_QMC5883P(AP_HAL::OwnPtr<AP_HAL::Device> dev,57bool force_external,58enum Rotation rotation);5960void _dump_registers();61bool _check_whoami();62void timer();63bool init();6465AP_HAL::OwnPtr<AP_HAL::Device> _dev;6667enum Rotation _rotation;68bool _force_external;69};7071#endif // AP_COMPASS_QMC5883P_ENABLED727374