MAV'RIC
|
00001 /******************************************************************************* 00002 * Copyright (c) 2009-2016, MAV'RIC Development Team 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of the copyright holder nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software without 00017 * specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 ******************************************************************************/ 00031 00032 /******************************************************************************* 00033 * \file barometer_bmp085.hpp 00034 * 00035 * \author MAV'RIC Team 00036 * \author Felix Schill 00037 * \author Julien Lecoeur 00038 * 00039 * \brief Driver for the BMP085 barometer 00040 * 00041 ******************************************************************************/ 00042 00043 00044 #ifndef BAROMETER_BMP085_HPP_ 00045 #define BAROMETER_BMP085_HPP_ 00046 00047 #include <cstdint> 00048 #include <cstdbool> 00049 00050 #include "hal/common/i2c.hpp" 00051 #include "drivers/barometer.hpp" 00052 00053 00057 typedef enum 00058 { 00059 BMP085_IDLE, 00060 BMP085_GET_TEMP, 00061 BMP085_GET_PRESSURE 00062 } bmp085_state_t; 00063 00064 00068 class Barometer_BMP085: public Barometer 00069 { 00070 public: 00076 Barometer_BMP085(I2c& i2c); 00077 00078 00084 bool init(void); 00085 00086 00092 bool read_eprom_calibration(void); 00093 00094 00101 bool update(void); 00102 00108 uint64_t last_update_us(void) const; 00109 00110 00116 float pressure(void) const; 00117 00118 00126 float altitude_gf(void) const; 00127 00128 00136 float altitude_gf_raw(void) const; 00137 00138 00146 float vertical_speed_lf(void) const; 00147 00148 00156 float vertical_speed_lf_raw(void) const; 00157 00158 00164 float temperature(void) const; 00165 00166 00167 private: 00168 I2c& i2c_; 00169 00170 int16_t ac1_; 00171 int16_t ac2_; 00172 int16_t ac3_; 00173 uint16_t ac4_; 00174 uint16_t ac5_; 00175 uint16_t ac6_; 00176 int16_t mb_; 00177 int16_t mc_; 00178 int16_t md_; 00179 int16_t b1_; 00180 int16_t b2_; 00181 00182 uint8_t raw_pressure_[3]; 00183 uint8_t raw_temperature_[2]; 00184 00185 float altitude_raw_; 00186 float altitude_gf_raw_; 00187 float speed_lf_raw_; 00188 00189 float pressure_; 00190 float temperature_; 00191 float altitude_gf_; 00192 float altitude_filtered; 00193 float speed_lf_; 00194 00195 float last_altitudes_[3]; 00196 00197 float last_update_us_; 00198 float last_state_update_us_; 00199 float dt_s_; 00200 00201 bmp085_state_t state_; 00202 }; 00203 00204 #endif /* BAROMETER_BMP085_HPP_ */