フェイルセーフ完成版

Dependencies:   HCSR04_2 MPU6050_2 mbed SDFileSystem3

Fork of Autoflight2018_53 by 航空研究会

Committer:
HARUKIDELTA
Date:
Fri Sep 07 04:11:48 2018 +0000
Revision:
0:17f575135219
SBUS_READ

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HARUKIDELTA 0:17f575135219 1 /**
HARUKIDELTA 0:17f575135219 2 * BME280 Combined humidity and pressure sensor library
HARUKIDELTA 0:17f575135219 3 *
HARUKIDELTA 0:17f575135219 4 * @author Toyomasa Watarai
HARUKIDELTA 0:17f575135219 5 * @version 1.0
HARUKIDELTA 0:17f575135219 6 * @date 06-April-2015
HARUKIDELTA 0:17f575135219 7 *
HARUKIDELTA 0:17f575135219 8 * Library for "BME280 temperature, humidity and pressure sensor module" from Switch Science
HARUKIDELTA 0:17f575135219 9 * https://www.switch-science.com/catalog/2236/
HARUKIDELTA 0:17f575135219 10 *
HARUKIDELTA 0:17f575135219 11 * For more information about the BME280:
HARUKIDELTA 0:17f575135219 12 * http://ae-bst.resource.bosch.com/media/products/dokumente/bme280/BST-BME280_DS001-10.pdf
HARUKIDELTA 0:17f575135219 13 */
HARUKIDELTA 0:17f575135219 14
HARUKIDELTA 0:17f575135219 15 #ifndef MBED_BMP280_H
HARUKIDELTA 0:17f575135219 16 #define MBED_BMP280_H
HARUKIDELTA 0:17f575135219 17
HARUKIDELTA 0:17f575135219 18 #include "mbed.h"
HARUKIDELTA 0:17f575135219 19
HARUKIDELTA 0:17f575135219 20 //#define _DEBUG
HARUKIDELTA 0:17f575135219 21 #define DEFAULT_SLAVE_ADDRESS (0x77 << 1)
HARUKIDELTA 0:17f575135219 22
HARUKIDELTA 0:17f575135219 23 #ifdef _DEBUG
HARUKIDELTA 0:17f575135219 24 extern Serial pc;
HARUKIDELTA 0:17f575135219 25 #define DEBUG_PRINT(...) pc.printf(__VA_ARGS__)
HARUKIDELTA 0:17f575135219 26 #else
HARUKIDELTA 0:17f575135219 27 #define DEBUG_PRINT(...)
HARUKIDELTA 0:17f575135219 28 #endif
HARUKIDELTA 0:17f575135219 29
HARUKIDELTA 0:17f575135219 30
HARUKIDELTA 0:17f575135219 31 /** BME280 class
HARUKIDELTA 0:17f575135219 32 *
HARUKIDELTA 0:17f575135219 33 * BME280: A library to correct environmental data using Boshe BME280 device
HARUKIDELTA 0:17f575135219 34 *
HARUKIDELTA 0:17f575135219 35 * BME280 is an environmental sensor
HARUKIDELTA 0:17f575135219 36 * @endcode
HARUKIDELTA 0:17f575135219 37 */
HARUKIDELTA 0:17f575135219 38
HARUKIDELTA 0:17f575135219 39 class BMP280
HARUKIDELTA 0:17f575135219 40 {
HARUKIDELTA 0:17f575135219 41 public:
HARUKIDELTA 0:17f575135219 42
HARUKIDELTA 0:17f575135219 43 /** Create a BME280 instance
HARUKIDELTA 0:17f575135219 44 * which is connected to specified I2C pins with specified address
HARUKIDELTA 0:17f575135219 45 *
HARUKIDELTA 0:17f575135219 46 * @param sda I2C-bus SDA pin
HARUKIDELTA 0:17f575135219 47 * @param scl I2C-bus SCL pin
HARUKIDELTA 0:17f575135219 48 * @param slave_adr (option) I2C-bus address (default: 0x76)
HARUKIDELTA 0:17f575135219 49 */
HARUKIDELTA 0:17f575135219 50 BMP280(PinName sda, PinName sck, char slave_adr = DEFAULT_SLAVE_ADDRESS);
HARUKIDELTA 0:17f575135219 51
HARUKIDELTA 0:17f575135219 52 /** Create a BME280 instance
HARUKIDELTA 0:17f575135219 53 * which is connected to specified I2C pins with specified address
HARUKIDELTA 0:17f575135219 54 *
HARUKIDELTA 0:17f575135219 55 * @param i2c_obj I2C object (instance)
HARUKIDELTA 0:17f575135219 56 * @param slave_adr (option) I2C-bus address (default: 0x76)
HARUKIDELTA 0:17f575135219 57 */
HARUKIDELTA 0:17f575135219 58 BMP280(I2C &i2c_obj, char slave_adr = DEFAULT_SLAVE_ADDRESS);
HARUKIDELTA 0:17f575135219 59
HARUKIDELTA 0:17f575135219 60 /** Destructor of BME280
HARUKIDELTA 0:17f575135219 61 */
HARUKIDELTA 0:17f575135219 62 virtual ~BMP280();
HARUKIDELTA 0:17f575135219 63
HARUKIDELTA 0:17f575135219 64 /** Initializa BME280 sensor
HARUKIDELTA 0:17f575135219 65 *
HARUKIDELTA 0:17f575135219 66 * Configure sensor setting and read parameters for calibration
HARUKIDELTA 0:17f575135219 67 *
HARUKIDELTA 0:17f575135219 68 */
HARUKIDELTA 0:17f575135219 69 void initialize(void);
HARUKIDELTA 0:17f575135219 70
HARUKIDELTA 0:17f575135219 71 /** Read the current temperature value (degree Celsius) from BME280 sensor
HARUKIDELTA 0:17f575135219 72 *
HARUKIDELTA 0:17f575135219 73 */
HARUKIDELTA 0:17f575135219 74 float getTemperature(void);
HARUKIDELTA 0:17f575135219 75
HARUKIDELTA 0:17f575135219 76 /** Read the current pressure value (hectopascal)from BME280 sensor
HARUKIDELTA 0:17f575135219 77 *
HARUKIDELTA 0:17f575135219 78 */
HARUKIDELTA 0:17f575135219 79 float getPressure(void);
HARUKIDELTA 0:17f575135219 80
HARUKIDELTA 0:17f575135219 81 /** Read the current humidity value (humidity %) from BME280 sensor
HARUKIDELTA 0:17f575135219 82 *
HARUKIDELTA 0:17f575135219 83 */
HARUKIDELTA 0:17f575135219 84 // float getHumidity(void);
HARUKIDELTA 0:17f575135219 85
HARUKIDELTA 0:17f575135219 86 private:
HARUKIDELTA 0:17f575135219 87
HARUKIDELTA 0:17f575135219 88 I2C *i2c_p;
HARUKIDELTA 0:17f575135219 89 I2C &i2c;
HARUKIDELTA 0:17f575135219 90 char address;
HARUKIDELTA 0:17f575135219 91 uint16_t dig_T1;
HARUKIDELTA 0:17f575135219 92 int16_t dig_T2, dig_T3;
HARUKIDELTA 0:17f575135219 93 uint16_t dig_P1;
HARUKIDELTA 0:17f575135219 94 int16_t dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9;
HARUKIDELTA 0:17f575135219 95 uint16_t dig_H1, dig_H3;
HARUKIDELTA 0:17f575135219 96 int16_t dig_H2, dig_H4, dig_H5, dig_H6;
HARUKIDELTA 0:17f575135219 97 int32_t t_fine;
HARUKIDELTA 0:17f575135219 98
HARUKIDELTA 0:17f575135219 99 };
HARUKIDELTA 0:17f575135219 100
HARUKIDELTA 0:17f575135219 101 #endif // MBED_BME280_H