Path: blob/master/libraries/AP_Compass/AP_Compass_IST8310.h
9635 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_IST8310_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_Backend.h"2829#ifndef HAL_COMPASS_IST8310_I2C_ADDR30#define HAL_COMPASS_IST8310_I2C_ADDR 0x0E31#endif3233#ifndef AP_COMPASS_IST8310_DEFAULT_ROTATION34#define AP_COMPASS_IST8310_DEFAULT_ROTATION ROTATION_PITCH_18035#endif3637class AP_Compass_IST8310 : public AP_Compass_Backend38{39public:40static AP_Compass_Backend *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev,41bool force_external,42enum Rotation rotation);4344void read() override;4546static constexpr const char *name = "IST8310";4748private:49AP_Compass_IST8310(AP_HAL::OwnPtr<AP_HAL::Device> dev,50bool force_external,51enum Rotation rotation);5253void timer();54bool init();55void start_conversion();5657AP_HAL::OwnPtr<AP_HAL::Device> _dev;58AP_HAL::Device::PeriodicHandle _periodic_handle;5960enum Rotation _rotation;61bool _ignore_next_sample;62bool _force_external;63};6465#endif // AP_COMPASS_IST8310_ENABLED666768