Line data Source code
1 : #pragma once 2 : 3 : #include "AP_Baro.h" 4 : 5 : class AP_Baro_Backend 6 : { 7 : public: 8 : AP_Baro_Backend(class AP_Baro &baro); 9 82 : virtual ~AP_Baro_Backend(void) {}; 10 : 11 : // each driver must provide an update method to copy accumulated 12 : // data to the frontend 13 : virtual void update() = 0; 14 : 15 : void backend_update(uint8_t instance); 16 : 17 : // Check that the baro valid by using a mean filter. 18 : // If the value further that filter_range from mean value, it is rejected. 19 : bool pressure_ok(float press); 20 : uint32_t get_error_count() const { return _error_count; } 21 : 22 : #if AP_BARO_MSP_ENABLED 23 0 : virtual void handle_msp(const MSP::msp_baro_data_message_t &pkt) {} 24 : #endif 25 : 26 : #if AP_BARO_EXTERNALAHRS_ENABLED 27 257118 : virtual void handle_external(const AP_ExternalAHRS::baro_data_message_t &pkt) {} 28 : #endif 29 : 30 : /* 31 : device driver IDs. These are used to fill in the devtype field 32 : of the device ID, which shows up as BARO_DEVID* parameters to 33 : users. 34 : */ 35 : enum DevTypes { 36 : DEVTYPE_BARO_SITL = 0x01, 37 : DEVTYPE_BARO_BMP085 = 0x02, 38 : DEVTYPE_BARO_BMP280 = 0x03, 39 : DEVTYPE_BARO_BMP388 = 0x04, 40 : DEVTYPE_BARO_DPS280 = 0x05, 41 : DEVTYPE_BARO_DPS310 = 0x06, 42 : DEVTYPE_BARO_FBM320 = 0x07, 43 : DEVTYPE_BARO_ICM20789 = 0x08, 44 : DEVTYPE_BARO_KELLERLD = 0x09, 45 : DEVTYPE_BARO_LPS2XH = 0x0A, 46 : DEVTYPE_BARO_MS5611 = 0x0B, 47 : DEVTYPE_BARO_SPL06 = 0x0C, 48 : DEVTYPE_BARO_UAVCAN = 0x0D, 49 : DEVTYPE_BARO_MSP = 0x0E, 50 : DEVTYPE_BARO_ICP101XX = 0x0F, 51 : DEVTYPE_BARO_ICP201XX = 0x10, 52 : DEVTYPE_BARO_MS5607 = 0x11, 53 : DEVTYPE_BARO_MS5837_30BA = 0x12, 54 : DEVTYPE_BARO_MS5637 = 0x13, 55 : DEVTYPE_BARO_BMP390 = 0x14, 56 : DEVTYPE_BARO_BMP581 = 0x15, 57 : DEVTYPE_BARO_SPA06 = 0x16, 58 : DEVTYPE_BARO_AUAV = 0x17, 59 : DEVTYPE_BARO_MS5837_02BA = 0x18, 60 : }; 61 : 62 : protected: 63 : // reference to frontend object 64 : AP_Baro &_frontend; 65 : 66 : void _copy_to_frontend(uint8_t instance, float pressure, float temperature); 67 : 68 : // semaphore for access to shared frontend data 69 : HAL_Semaphore _sem; 70 : 71 : virtual void update_healthy_flag(uint8_t instance); 72 : 73 : // mean pressure for range filter 74 : float _mean_pressure; 75 : // number of dropped samples. Not used for now, but can be usable to choose more reliable sensor 76 : uint32_t _error_count; 77 : 78 : // set bus ID of this instance, for BARO_DEVID parameters 79 : void set_bus_id(uint8_t instance, uint32_t id); 80 : };