12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #pragma once
- #include "AP_Baro_Backend.h"
- #include <AP_HAL/AP_HAL.h>
- #include <AP_HAL/Semaphores.h>
- #include <AP_HAL/Device.h>
- #ifndef HAL_BARO_MPM258_I2C_ADDR
- #define HAL_BARO_MPM258_I2C_ADDR 0x6D
- #endif
- class AP_Baro_MPM258 : public AP_Baro_Backend
- {
- public:
- void update() override;
- static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
- private:
- /*
- * Update @accum and @count with the new sample in @val, taking into
- * account a maximum number of samples given by @max_count; in case
- * maximum number is reached, @accum and @count are updated appropriately
- */
- void _update_and_wrap_accumulator(int32_t pressure, int32_t temperature, uint8_t max_count);
- AP_Baro_MPM258(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev);
- bool _init();
- bool _read();
- void _timer();
- AP_HAL::OwnPtr<AP_HAL::Device> _dev;
- /* Shared values between thread sampling the HW and main thread */
- struct {
- int32_t sum_pressure;
- int32_t sum_temperature;
- uint8_t num_samples;
- } _accum;
- uint8_t _state;
- uint8_t _instance;
-
- };
|