Path: blob/master/libraries/AP_Compass/AP_Compass_LIS2MDL.h
6351 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#pragma once1516#include "AP_Compass_config.h"1718#if AP_COMPASS_LIS2MDL_ENABLED1920#include <AP_Common/AP_Common.h>21#include <AP_HAL/AP_HAL.h>22#include <AP_HAL/Device.h>23#include <AP_Math/AP_Math.h>2425#include "AP_Compass.h"26#include "AP_Compass_Backend.h"2728// LIS2MDL has a fixed I2C address29#define HAL_COMPASS_LIS2MDL_I2C_ADDR 0x1E3031class AP_Compass_LIS2MDL : public AP_Compass_Backend32{33public:34static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,35bool force_external,36enum Rotation rotation);3738void read() override;3940static constexpr const char *name = "LIS2MDL";4142private:43AP_Compass_LIS2MDL(AP_HAL::OwnPtr<AP_HAL::Device> dev,44bool force_external,45enum Rotation rotation);4647AP_HAL::OwnPtr<AP_HAL::Device> dev;4849/**50* @brief Initialize the sensor51* @return True if successful, false otherwise.52*/53bool init();5455/**56* @brief Device periodic callback to read data from the sensor.57*/58void timer();5960bool force_external;61enum Rotation rotation;62};6364#endif // AP_COMPASS_LIS2MDL_ENABLED656667