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_ICP101XX.h
Views: 1798
#pragma once12#include "AP_Baro_Backend.h"34#if AP_BARO_ICP101XX_ENABLED56#include <AP_HAL/AP_HAL.h>7#include <AP_HAL/Semaphores.h>8#include <AP_HAL/Device.h>910class AP_Baro_ICP101XX : public AP_Baro_Backend11{12public:13void update() override;1415static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);1617private:18AP_Baro_ICP101XX(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);1920bool init();21bool send_cmd16(uint16_t cmd);22bool read_measure_results(uint8_t *buf, uint8_t len);23bool read_response(uint16_t cmd, uint8_t *buf, uint8_t len);24bool send_command(uint16_t cmd);25bool send_command(uint16_t cmd, uint8_t *data, uint8_t len);26int8_t cal_crc(uint8_t seed, uint8_t data);27bool start_measure(uint16_t mode);28bool read_calibration_data(void);29void convert_data(uint32_t Praw, uint32_t Traw);30void calculate_conversion_constants(const float p_Pa[3], const float p_LUT[3],31float &A, float &B, float &C);32float get_pressure(uint32_t p_LSB, uint32_t T_LSB);33void timer(void);3435// calibration data36int16_t sensor_constants[4];3738uint8_t instance;3940AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;4142// time last read command was sent43uint32_t last_measure_us;4445// accumulation structure, protected by _sem46struct {47float tsum;48float psum;49uint32_t count;50} accum;5152// conversion constants. Thanks to invensense for including python53// sample code in the datasheet!54const float p_Pa_calib[3] = {45000.0, 80000.0, 105000.0};55const float LUT_lower = 3.5 * (1U<<20);56const float LUT_upper = 11.5 * (1U<<20);57const float quadr_factor = 1 / 16777216.0;58const float offst_factor = 2048.0;59uint32_t measure_interval = 0;60};6162#endif // AP_BARO_ICP101XX_ENABLED636465