Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Airspeed/AP_Airspeed_SDP3X.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/14#pragma once1516#include "AP_Airspeed_config.h"1718#if AP_AIRSPEED_SDP3X_ENABLED1920/*21backend driver for airspeed from I2C22*/2324#include <AP_HAL/AP_HAL.h>25#include <AP_HAL/utility/OwnPtr.h>26#include <AP_HAL/I2CDevice.h>27#include <utility>2829#include "AP_Airspeed_Backend.h"30#include "AP_Airspeed.h"3132/*33* Thanks to PX4 for registers definitions34*/3536class AP_Airspeed_SDP3X : public AP_Airspeed_Backend37{38public:3940using AP_Airspeed_Backend::AP_Airspeed_Backend;4142// probe and initialise the sensor43bool init() override;4445// return the current differential_pressure in Pascal46bool get_differential_pressure(float &pressure) override;4748// return the current temperature in degrees C, if available49bool get_temperature(float &temperature) override;5051private:52void _timer();53bool _send_command(uint16_t cmd);54bool _crc(const uint8_t data[], uint8_t size, uint8_t checksum);55float _correct_pressure(float press);5657float _temp;58float _press;59uint16_t _temp_count;60uint16_t _press_count;61float _temp_sum;62float _press_sum;63uint32_t _last_sample_time_ms;64uint16_t _scale;6566AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;67};686970#endif // AP_AIRSPEED_SDP3X_ENABLED717273