Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BMP280.h
00001 #ifndef BMP280_H 00002 #define BMP280_H 00003 00004 // Register define 00005 #define BMP280_ADDR 0xEE // BMP280 i2c address 00006 00007 #define BMP280_REG_CALIBRATION 0x88 // calibration register start 00008 #define BMP280_REG_ID 0xD0 // read out is 0x58 00009 #define BMP280_REG_RESET 0xE0 // write value 0xB6 will process power-on-reset other value is not work 00010 #define BMP280_REG_STATUS 0xF3 // indicate status of the device 00011 #define BMP280_REG_CTRL_MEAS 0xF4 // config options of the device 00012 #define BMP280_REG_CONFIG 0xF5 // set rate, filted and interface options of device 00013 #define BMP280_REG_PRESS 0xF7 // pressure measurement out data 0xF7~0xF9 00014 #define BMP280_REG_TMEP 0xFA // temperature measurment out data 0xFA~0xFC 00015 00016 // OSSR Data 00017 #define BMP280_OSSR_SKIP 0x00 // Skipped output set to 0x80000 00018 #define BMP280_OSSR_OV1 0x01 // oversampling x1 00019 #define BMP280_OSSR_OV2 0x02 // oversampling x2 00020 #define BMP280_OSSR_OV4 0x03 // oversampling x4 00021 #define BMP280_OSSR_OV8 0x04 // oversampling x8 00022 #define BMP280_OSSR_OV16 0x05 // oversampling x16 00023 00024 // wait to read out time 00025 // T_SB 00026 #define BMP280_T_SB0 0x00 // 0.5ms 00027 #define BMP280_T_SB62 0x01 // 62.5ms 00028 #define BMP280_T_SB125 0x02 // 125ms 00029 #define BMP280_T_SB250 0x03 // 250ms 00030 #define BMP280_T_SB500 0x04 // 500ms 00031 #define BMP280_T_SB1000 0x05 // 1000ms 00032 #define BMP280_T_SB2000 0x06 // 2000ms 00033 #define BMP280_T_SB4000 0x07 // 4000ms 00034 00035 // Power Mode 00036 #define BMP280_POWER_SLEEP 0b00 00037 #define BMP280_POWER_FORCE 0b01 00038 #define BMP280_POWER_NORMAL 0b11 00039 00040 00041 00042 #include "mbed.h" 00043 00044 class BMP280 { 00045 00046 public: 00047 BMP280(I2C& i2c); 00048 int init(char ctrl_meas = 0x6F, char config = 0x70); 00049 int readData(float *tempC, int *pressPa); 00050 00051 protected: 00052 I2C m_i2c; 00053 Serial pc; 00054 unsigned short dig_T1,dig_P1; 00055 short dig_T2,dig_T3,dig_P2,dig_P3,dig_P4,dig_P5,dig_P6,dig_P7,dig_P8,dig_P9; 00056 void write(char reg, char ctrl); 00057 void read(char reg, char *data, int length); 00058 00059 private: 00060 00061 }; 00062 00063 #endif
Generated on Mon Jul 25 2022 10:33:12 by
1.7.2