Path: blob/master/libraries/AP_Airspeed/AP_Airspeed_MS5525.h
9882 views
/*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/*17backend driver for airspeed from I2C18*/1920#include "AP_Airspeed_config.h"2122#if AP_AIRSPEED_MS5525_ENABLED2324#include <AP_HAL/AP_HAL.h>25#include <AP_HAL/I2CDevice.h>26#include <utility>2728#include "AP_Airspeed_Backend.h"2930class AP_Airspeed_MS5525 : public AP_Airspeed_Backend31{32public:33enum MS5525_ADDR {34MS5525_ADDR_1 = 0,35MS5525_ADDR_2 = 1,36MS5525_ADDR_AUTO = 255, // does not need to be 255, just needs to be out of the address array37};3839AP_Airspeed_MS5525(AP_Airspeed &frontend, uint8_t _instance, MS5525_ADDR address);40~AP_Airspeed_MS5525(void) {41delete dev;42}4344// probe and initialise the sensor45bool init() override;4647// return the current differential_pressure in Pascal48bool get_differential_pressure(float &pressure) override;4950// return the current temperature in degrees C, if available51bool get_temperature(float &temperature) override;5253private:54void measure();55void collect();56void timer();57bool read_prom(void);58uint16_t crc4_prom(void);59int32_t read_adc();60void calculate();6162float pressure;63float temperature;64float temperature_sum;65float pressure_sum;66uint32_t temp_count;67uint32_t press_count;6869uint32_t last_sample_time_ms;7071uint16_t prom[8];72uint8_t state;73int32_t D1;74int32_t D2;75uint32_t command_send_us;76bool ignore_next;77uint8_t cmd_sent;78MS5525_ADDR _address;7980AP_HAL::I2CDevice *dev;81};8283#endif // AP_AIRSPEED_MS5525_ENABLED848586