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.
Dependents: Barometer-Example IOT_Repository
BMP085.h
00001 /** 00002 * Bosch BMP085 Barometer driver 00003 */ 00004 00005 #ifndef BMP085_H 00006 #define BMP085_H 00007 00008 #include <stdint.h> 00009 #include "mbed.h" 00010 00011 #define BMP085_ADDR (0x77<<1) 00012 00013 typedef enum { 00014 BMP085_CAL_AC1 = 0xAA, 00015 BMP085_CAL_AC2 = 0xAC, 00016 BMP085_CAL_AC3 = 0xAE, 00017 BMP085_CAL_AC4 = 0xB0, 00018 BMP085_CAL_AC5 = 0xB2, 00019 BMP085_CAL_AC6 = 0xB4, 00020 BMP085_CAL_B1 = 0xB6, 00021 BMP085_CAL_B2 = 0xB8, 00022 BMP085_CAL_MB = 0xBA, 00023 BMP085_CAL_MC = 0xBC, 00024 BMP085_CAL_MD = 0xBE, 00025 BMP085_CHIPID = 0xD0, 00026 BMP085_VERSION = 0xD1, 00027 BMP085_SOFTRESET = 0xE0, 00028 BMP085_CTRL = 0xF4, 00029 BMP085_DATA_TEMP = 0xF6, 00030 BMP085_DATA_PRESSURE = 0xF6, 00031 BMP085_CMD_READ_TEMP = 0x2E, 00032 BMP085_CMD_READ_PRESSURE = 0x34 00033 } BMP085_Register; 00034 00035 typedef enum { 00036 BMP085_MODE_ULTRA_LOW_POWER = 0, 00037 BMP085_MODE_STANDARD = 1, 00038 BMP085_MODE_HIGH_RESOLUTION = 2, 00039 BMP085_MODE_ULTRA_HIGH_RESOLUTION = 3 00040 } BMP085_Mode; 00041 00042 typedef enum { 00043 BMP085_IDLE, 00044 BMP085_BUSY 00045 } BMP085_State; 00046 00047 typedef struct { 00048 int16_t ac1; 00049 int16_t ac2; 00050 int16_t ac3; 00051 uint16_t ac4; 00052 uint16_t ac5; 00053 uint16_t ac6; 00054 int16_t b1; 00055 int16_t b2; 00056 int16_t mb; 00057 int16_t mc; 00058 int16_t md; 00059 } BMP085_Calibration_Data; 00060 00061 class BMP085 { 00062 public: 00063 BMP085(PinName sda, PinName scl, BMP085_Mode mode = BMP085_MODE_STANDARD) : _i2c(sda, scl), _mode(mode), _state(BMP085_IDLE) { init(); }; 00064 BMP085(I2C & i2c, BMP085_Mode mode = BMP085_MODE_STANDARD) : _i2c(i2c), _mode(mode), _state(BMP085_IDLE) { init(); }; 00065 00066 float get_temperature(void) { return _temperature; }; 00067 float get_pressure(void) { return _pressure; }; 00068 void measure(); 00069 void _callback_handler(); 00070 protected: 00071 void init(void); 00072 uint16_t read_cal_register(BMP085_Register reg); 00073 uint16_t read_uc_temperature(void); 00074 uint32_t read_uc_pressure(void); 00075 I2C _i2c; 00076 BMP085_Mode _mode; 00077 BMP085_State _state; 00078 float _temperature; 00079 float _pressure; 00080 BMP085_Calibration_Data _cal_data; 00081 private: 00082 event_callback_t _callback; 00083 void _callback_handler(int event); 00084 uint8_t _tx_buf[2]; 00085 uint8_t _rx_buf[3]; 00086 }; 00087 00088 #endif /* BMP085_H */
Generated on Wed Jul 13 2022 23:37:06 by
