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_Baro/AP_Baro_DPS280.h
Views: 1798
#pragma once12#include "AP_Baro_Backend.h"34#if AP_BARO_DPS280_ENABLED56#include <AP_HAL/AP_HAL.h>7#include <AP_HAL/Device.h>8#include <AP_HAL/utility/OwnPtr.h>910#ifndef HAL_BARO_DPS280_I2C_ADDR11#define HAL_BARO_DPS280_I2C_ADDR 0x7612#endif13#ifndef HAL_BARO_DPS280_I2C_ADDR214#define HAL_BARO_DPS280_I2C_ADDR2 0x7715#endif1617class AP_Baro_DPS280 : public AP_Baro_Backend {18public:19AP_Baro_DPS280(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);2021/* AP_Baro public interface: */22void update() override;2324static AP_Baro_Backend *probe_280(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev) {25return probe(baro, std::move(dev), false);26}2728static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev, bool _is_dps310=false);2930protected:31bool init(bool _is_dps310);32bool read_calibration(void);33void timer(void);34void calculate_PT(int32_t UT, int32_t UP, float &pressure, float &temperature);3536void fix_config_bits16(int16_t &v, uint8_t bits) const;37void fix_config_bits32(int32_t &v, uint8_t bits) const;38void set_config_registers(void);39void check_health();4041AP_HAL::OwnPtr<AP_HAL::Device> dev;4243uint8_t instance;4445uint32_t count;46uint8_t err_count;47float pressure_sum;48float temperature_sum;49float last_temperature;50bool pending_reset;51bool is_dps310;5253struct dps280_cal {54int16_t C0; // 12bit55int16_t C1; // 12bit56int32_t C00; // 20bit57int32_t C10; // 20bit58int16_t C01; // 16bit59int16_t C11; // 16bit60int16_t C20; // 16bit61int16_t C21; // 16bit62int16_t C30; // 16bit63uint8_t temp_source;64} calibration;65};6667class AP_Baro_DPS310 : public AP_Baro_DPS280 {68// like DPS280 but workaround for temperature bug69public:70using AP_Baro_DPS280::AP_Baro_DPS280;71static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);72};737475#endif // AP_BARO_DPS280_ENABLED767778