/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/*
IMU driver backend class. Each supported gyro/accel sensor type
needs to have an object derived from this class.
Note that drivers can implement just gyros or just accels, and can
also provide multiple gyro/accel instances.
*/
#pragma once
#include
#include
#include
#include "AP_InertialSensor.h"
#ifndef HAL_INS_HIGHRES_SAMPLE
#define HAL_INS_HIGHRES_SAMPLE 0
#endif
class AuxiliaryBus;
class AP_Logger;
class AP_InertialSensor_Backend
{
public:
AP_InertialSensor_Backend(AP_InertialSensor &imu);
AP_InertialSensor_Backend(const AP_InertialSensor_Backend &that) = delete;
// we declare a virtual destructor so that drivers can
// override with a custom destructor if need be.
virtual ~AP_InertialSensor_Backend(void) {}
/*
* Update the sensor data. Called by the frontend to transfer
* accumulated sensor readings to the frontend structure via the
* _publish_gyro() and _publish_accel() functions
*/
virtual bool update() = 0; /* front end */
/*
* optional function to accumulate more samples. This is needed for drivers that don't use a timer to gather samples
*/
virtual void accumulate() {}
/*
* Configure and start all sensors. The empty implementation allows
* subclasses to already start the sensors when it's detected
*/
virtual void start() { }
/*
* Return an AuxiliaryBus if backend has another bus it is able to export
*/
virtual AuxiliaryBus *get_auxiliary_bus() { return nullptr; }
/*
* Return the unique identifier for this backend: it's the same for
* several sensors if the backend registers more gyros/accels
*/
int16_t get_id() const { return _id; }
//Returns the Clip Limit
float get_clip_limit() const { return _clip_limit; }
// get a startup banner to output to the GCS
virtual bool get_output_banner(char* banner, uint8_t banner_len) { return false; }
#if HAL_EXTERNAL_AHRS_ENABLED
virtual void handle_external(const AP_ExternalAHRS::ins_data_message_t &pkt) {}
#endif
#if AP_INERTIALSENSOR_KILL_IMU_ENABLED
bool has_been_killed(uint8_t instance) const { return ((1U<